Skip to content

Commit

Permalink
Refs #95. Removed context menu from WebLoginDialog (and others).
Browse files Browse the repository at this point in the history
  • Loading branch information
SBriere committed Oct 9, 2024
1 parent c4d4051 commit 2d6519a
Show file tree
Hide file tree
Showing 9 changed files with 34 additions and 7 deletions.
9 changes: 7 additions & 2 deletions client/src/dialogs/AboutDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ AboutDialog::AboutDialog(ComManager* comManager, QWidget *parent) :

// Initialize web engine view
m_webEngine = new QWebEngineView(ui->wdgWebView);
m_webEngine->setContextMenuPolicy(Qt::NoContextMenu);
m_webPage = new AboutDialogPage();
m_webEngine->setPage(m_webPage);

Expand Down Expand Up @@ -53,11 +54,14 @@ void AboutDialog::on_lblAbout_clicked()
{
if (m_webEngine){
m_webEngine->setUrl(QUrl("chrome://dino"));
ui->wdgWebView->setFocus();

}
}

void AboutDialog::onPageLoaded()
{
ui->wdgWebView->setFocus();
}

void AboutDialog::processServerSettings(QVariantHash settings)
{
if (settings.contains(WEB_QUERY_DEVICE_REGISTER_KEY)){
Expand All @@ -69,5 +73,6 @@ void AboutDialog::processServerSettings(QVariantHash settings)

void AboutDialog::connectSignals()
{
connect(m_webEngine, &QWebEngineView::loadFinished, this, &AboutDialog::onPageLoaded);
connect(m_comManager, &ComManager::serverSettingsReceived, this, &AboutDialog::processServerSettings);
}
1 change: 1 addition & 0 deletions client/src/dialogs/AboutDialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ class AboutDialog : public QDialog
private slots:
void on_btnOk_clicked();
void on_lblAbout_clicked();
void onPageLoaded();

void processServerSettings(QVariantHash settings);

Expand Down
10 changes: 5 additions & 5 deletions client/src/dialogs/AboutDialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
<height>300</height>
</rect>
</property>
<property name="focusPolicy">
<enum>Qt::FocusPolicy::StrongFocus</enum>
</property>
<property name="windowTitle">
<string>À propos d'OpenTera...</string>
</property>
Expand All @@ -33,9 +36,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="focusPolicy">
<enum>Qt::StrongFocus</enum>
</property>
</widget>
</item>
<item>
Expand Down Expand Up @@ -64,14 +64,14 @@
<string>Inconnue</string>
</property>
<property name="textInteractionFlags">
<set>Qt::TextSelectableByMouse</set>
<set>Qt::TextInteractionFlag::TextSelectableByMouse</set>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<enum>Qt::Orientation::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
Expand Down
13 changes: 13 additions & 0 deletions client/src/dialogs/AboutDialogPage.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
#include "AboutDialogPage.h"
#include <QWebEngineCertificateError>
#include <QDesktopServices>

AboutDialogPage::AboutDialogPage()
{
Expand All @@ -15,3 +16,15 @@ void AboutDialogPage::onCertificateError(const QWebEngineCertificateError &certi
auto mutableError = const_cast<QWebEngineCertificateError&>(certificateError);
mutableError.acceptCertificate();
}

bool AboutDialogPage::acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame)
{
if (type == NavigationTypeLinkClicked){
// Open links in external browser
QDesktopServices::openUrl(url);

return false;
}

return true;
}
4 changes: 4 additions & 0 deletions client/src/dialogs/AboutDialogPage.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ class AboutDialogPage : public QWebEnginePage
protected slots:

void onCertificateError(const QWebEngineCertificateError &certificateError);

// QWebEnginePage interface
protected:
bool acceptNavigationRequest(const QUrl &url, NavigationType type, bool isMainFrame) override;
};

#endif // ABOUTDIALOGPAGE_H
1 change: 1 addition & 0 deletions client/src/dialogs/WebLoginDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ WebLoginDialog::WebLoginDialog(ConfigManagerClient *config, QWidget *parent)

//Create Web View
m_webView = new QWebEngineView(ui->centralWidget);
m_webView->setContextMenuPolicy(Qt::NoContextMenu);
ui->lblError->hide();
ui->centralWidget->hide();

Expand Down
1 change: 1 addition & 0 deletions client/src/kit/KitVideoRehabWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ void KitVideoRehabWidget::initUi()
m_loadingIcon->start();

m_webEngine = new QWebEngineView(ui->wdgWebEngine);
m_webEngine->setContextMenuPolicy(Qt::NoContextMenu);
connect(m_webEngine, &QWebEngineView::loadFinished, this, &KitVideoRehabWidget::webPageLoaded);

// Create a new page
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ void VideoRehabSetupWidget::initUI()

//// Web engine setup
m_webEngine = new QWebEngineView(ui->wdgWebEngine);
m_webEngine->setContextMenuPolicy(Qt::NoContextMenu);
connect(m_webEngine, &QWebEngineView::loadFinished, this, &VideoRehabSetupWidget::webPageLoaded);

//Create a new page
Expand Down
1 change: 1 addition & 0 deletions client/src/services/VideoRehabService/VideoRehabWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ void VideoRehabWidget::initUI()
m_loadingIcon->start();

m_webEngine = new QWebEngineView(/*ui->wdgWebEngine*/);
m_webEngine->setContextMenuPolicy(Qt::NoContextMenu);
connect(m_webEngine, &QWebEngineView::loadFinished, this, &VideoRehabWidget::webPageLoaded);

// Create a new page
Expand Down

0 comments on commit 2d6519a

Please sign in to comment.