<number>0</number>
</property>
- <!-- URL bar. -->
- <item>
- <layout class="QHBoxLayout">
- <!-- Back button. -->
- <item>
- <widget class="QPushButton" name="backButton">
- <property name="icon">
- <iconset theme="arrow-left" />
- </property>
-
- <property name="iconSize">
- <size>
- <height>24</height>
- <width>24</width>
- </size>
- </property>
-
- <property name="flat">
- <bool>true</bool>
- </property>
- </widget>
- </item>
-
- <!-- Forward button. -->
- <item>
- <widget class="QPushButton" name="forwardButton">
- <property name="icon">
- <iconset theme="arrow-right" />
- </property>
-
- <property name="iconSize">
- <size>
- <height>24</height>
- <width>24</width>
- </size>
- </property>
-
- <property name="flat">
- <bool>true</bool>
- </property>
- </widget>
- </item>
-
- <!-- Refresh button. -->
- <item>
- <widget class="QPushButton" name="refreshButton">
- <property name="icon">
- <iconset theme="view-refresh" />
- </property>
-
- <property name="iconSize">
- <size>
- <height>24</height>
- <width>24</width>
- </size>
- </property>
-
- <property name="flat">
- <bool>true</bool>
- </property>
- </widget>
- </item>
-
- <!-- Home button. -->
- <item>
- <widget class="QPushButton" name="homeButton">
- <property name="icon">
- <iconset theme="home" />
- </property>
-
- <property name="iconSize">
- <size>
- <height>24</height>
- <width>24</width>
- </size>
- </property>
-
- <property name="flat">
- <bool>true</bool>
- </property>
- </widget>
- </item>
-
- <!-- URL line edit. -->
- <item>
- <widget class="KLineEdit" name="urlLineEdit" />
- </item>
-
- <!-- JavaScript. -->
- <item>
- <widget class="QPushButton" name="javaScript">
- <property name="iconSize">
- <size>
- <height>24</height>
- <width>24</width>
- </size>
- </property>
-
- <property name="flat">
- <bool>true</bool>
- </property>
- </widget>
- </item>
-
- <!-- Domain Settings. -->
- <item>
- <widget class="QPushButton" name="domainSettingsButton">
- <property name="icon">
- <iconset theme="network-server-symbolic" />
- </property>
-
- <property name="iconSize">
- <size>
- <height>24</height>
- <width>24</width>
- </size>
- </property>
-
- <property name="flat">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- </layout>
- </item>
-
<!-- WebEngine view. -->
<item>
<widget class="QWebEngineView" name="webEngineView" />
#include "Settings.h"
#include "ui_BrowserView.h"
#include "UrlRequestInterceptor.h"
-#include "dialogs/DomainSettingsDialog.h"
#include "helpers/DomainsDatabaseHelper.h"
#include "helpers/SearchEngineHelper.h"
#include "helpers/UserAgentHelper.h"
browserViewUi.setupUi(this);
// Get handles for the views.
- backButtonPointer = browserViewUi.backButton;
- forwardButtonPointer = browserViewUi.forwardButton;
- QPushButton *refreshButtonPointer = browserViewUi.refreshButton;
- QPushButton *homeButtonPointer = browserViewUi.homeButton;
- urlLineEditPointer = browserViewUi.urlLineEdit;
- javaScriptButtonPointer = browserViewUi.javaScript;
- QPushButton *domainSettingsButtonPointer = browserViewUi.domainSettingsButton;
webEngineViewPointer = browserViewUi.webEngineView;
// Get handles for the aspects of the WebEngine.
webEngineProfilePointer = webEnginePagePointer->profile();
webEngineSettingsPointer = webEngineViewPointer->settings();
- // Update the webengine view from the URL line edit. TODO. Remove.
- connect(urlLineEditPointer, SIGNAL(returnKeyPressed(const QString)), this, SLOT(loadUrlFromLineEdit(const QString)));
-
// Update the URL line edit from the webengine view.
connect(webEngineViewPointer, SIGNAL(loadStarted()), this, SLOT(updateInterface()));
connect(webEngineViewPointer, SIGNAL(loadProgress(const int)), this, SLOT(updateInterface()));
connect(webEngineViewPointer, SIGNAL(loadFinished(const bool)), this, SLOT(updateInterface()));
- // Setup the URL bar buttons. TODO. Remove.
- connect(backButtonPointer, SIGNAL(clicked()), webEngineViewPointer, SLOT(back()));
- connect(forwardButtonPointer, SIGNAL(clicked()), webEngineViewPointer, SLOT(forward()));
- connect(refreshButtonPointer, SIGNAL(clicked()), webEngineViewPointer, SLOT(reload()));
- connect(homeButtonPointer, SIGNAL(clicked()), this, SLOT(home()));
- connect(javaScriptButtonPointer, SIGNAL(clicked()), this, SLOT(toggleJavaScript()));
- connect(domainSettingsButtonPointer, SIGNAL(clicked()), this, SLOT(openDomainSettings()));
-
- // Get the URL line edit palettes. TODO. Remove.
- noDomainSettingsPalette = urlLineEditPointer->palette();
- domainSettingsPalette = urlLineEditPointer->palette();
-
- // Modify the domain settings palette. TODO. Remove.
- domainSettingsPalette.setColor(QPalette::Base, QColor("#C8E6C9"));
-
- // Instantiate the mouse event pointer.
+ // Instantiate the mouse event filter pointer.
MouseEventFilter *mouseEventFilterPointer = new MouseEventFilter(webEngineViewPointer);
// Install the mouse event filter.
webEngineViewPointer->setZoomFactor(Settings::zoomFactor());
// Apply the domain settings palette to the URL line edit.
- urlLineEditPointer->setPalette(domainSettingsPalette); // TODO. Remove.
emit updateDomainSettingsIndicator(true);
}
else // The hostname does not have domain settings.
webEngineViewPointer->setZoomFactor(Settings::zoomFactor());
// Apply the no domain settings palette to the URL line edit.
- urlLineEditPointer->setPalette(noDomainSettingsPalette); // TODO. Remove.
emit updateDomainSettingsIndicator(false);
}
- // Update the JavaScript button.
- if (webEngineSettingsPointer->testAttribute(QWebEngineSettings::JavascriptEnabled))
- {
- javaScriptButtonPointer->setIcon(QIcon(":/icons/javascript-warning"));
- }
- else
- {
- javaScriptButtonPointer->setIcon(QIcon(":/icons/privacy-mode"));
- }
-
// Emit the on-the-fly menu update signals.
+ emit updateJavaScriptAction(webEngineSettingsPointer->testAttribute(QWebEngineSettings::JavascriptEnabled));
emit userAgentUpdated(webEngineProfilePointer->httpUserAgent());
emit zoomFactorUpdated(Settings::zoomFactor());
void BrowserView::loadUrlFromLineEdit(QString url) const
{
- // Remove the focus from the URL line edit. TODO. Remove.
- urlLineEditPointer->clearFocus();
-
// Decide if the text is more likely to be a URL or a search.
if (url.contains(".")) // The text is likely a URL.
{
}
}
-void BrowserView::openDomainSettings() const
-{
- // Instantiate the domain settings window.
- DomainSettingsDialog *domainSettingsDialogPointer = new DomainSettingsDialog();
-
- // Set the dialog window title.
- domainSettingsDialogPointer->setWindowTitle(i18nc("The domain settings dialog title", "Domain Settings"));
-
- // Set the modality.
- domainSettingsDialogPointer->setWindowModality(Qt::WindowModality::WindowModal);;
-
- // Show the dialog.
- domainSettingsDialogPointer->show();
-
- // Reload the tabs when domain settings are updated.
- connect(domainSettingsDialogPointer, SIGNAL(domainSettingsUpdated()), this, SLOT(applyDomainSettingsAndReload()));
-}
-
void BrowserView::pageLinkHovered(const QString &linkUrl) const
{
// Emit a signal so that the browser window can update the status bar.
// Toggle JavaScript.
webEngineSettingsPointer->setAttribute(QWebEngineSettings::JavascriptEnabled, !webEngineSettingsPointer->testAttribute(QWebEngineSettings::JavascriptEnabled));
- // Update the JavaScript button.
- if (webEngineSettingsPointer->testAttribute(QWebEngineSettings::JavascriptEnabled))
- {
- javaScriptButtonPointer->setIcon(QIcon(":/icons/javascript-warning"));
- }
- else
- {
- javaScriptButtonPointer->setIcon(QIcon(":/icons/privacy-mode"));
- }
+ // Update the JavaScript icon.
+ emit updateJavaScriptAction(webEngineSettingsPointer->testAttribute(QWebEngineSettings::JavascriptEnabled));
// Reload the website.
webEngineViewPointer->reload();
void BrowserView::updateInterface() const
{
- // Update the URL line edit if it does not have focus. TODO. Remove block.
- if (!urlLineEditPointer->hasFocus())
- {
- // Update the URL line edit.
- urlLineEditPointer->setText(webEngineViewPointer->url().toString());
- }
-
// Update the URL line edit.
emit updateUrlLineEdit(webEngineViewPointer->url().toString());
// Update the status of the forward and back buttons.
- backButtonPointer->setEnabled(webEngineHistoryPointer->canGoBack()); // TODO Remove.
emit updateBackAction(webEngineHistoryPointer->canGoBack());
- forwardButtonPointer->setEnabled(webEngineHistoryPointer->canGoForward()); // TODO Remove.
emit updateForwardAction(webEngineHistoryPointer->canGoForward());
// Reapply the zoom factor. This is a bug in QWebEngineView that resets the zoom with every load. Hopefully it will be fixed in Qt6. <https://bugreports.qt.io/browse/QTBUG-51992>
signals:
// The signals.
void linkHovered(const QString &linkUrl) const;
- void userAgentUpdated(const QString &userAgent) const;
- void searchEngineUpdated(const QString &searchEngine) const;
+ void userAgentUpdated(const QString &userAgent) const; // TODO. Possibly rename.
+ void searchEngineUpdated(const QString &searchEngine) const; //TODO. Possibly rename.
void updateBackAction(const bool &isEnabled) const;
void updateDomainSettingsIndicator(const bool status) const;
void updateForwardAction(const bool &isEnabled) const;
+ void updateJavaScriptAction(const bool &isEnabled) const;
void updateUrlLineEdit(const QString &newUrl) const;
- void zoomFactorUpdated(const double &zoomFactor) const;
+ void zoomFactorUpdated(const double &zoomFactor) const; //TODO. Possibly rename.
public Q_SLOTS:
// The public slots.
void forward() const;
void home() const;
void loadUrlFromLineEdit(QString url) const;
+ void toggleJavaScript() const;
void refresh() const;
private Q_SLOTS:
// The private slots.
void pageLinkHovered(const QString &linkUrl) const;
- void toggleJavaScript() const;
- void openDomainSettings() const;
void updateInterface() const;
private:
// The private variables.
- QPushButton *backButtonPointer;
- QPalette domainSettingsPalette; // TODO. Remove.
- QPushButton *forwardButtonPointer;
- QPushButton *javaScriptButtonPointer;
- QPalette noDomainSettingsPalette; // TODO. Remove.
QString searchEngineUrl;
- KLineEdit *urlLineEditPointer;
QWebEngineHistory *webEngineHistoryPointer;
QWebEngineProfile *webEngineProfilePointer;
QWebEngineSettings *webEngineSettingsPointer;
#include "Settings.h"
#include "ui_SettingsPrivacy.h"
#include "ui_SettingsGeneral.h"
+#include "dialogs/DomainSettingsDialog.h"
#include "helpers/SearchEngineHelper.h"
#include "helpers/UserAgentHelper.h"
forwardActionPointer = actionCollectionPointer->addAction(QStringLiteral("forward"));
refreshActionPointer = actionCollectionPointer->addAction(QStringLiteral("refresh"));
homeActionPointer = actionCollectionPointer->addAction(QStringLiteral("home"));
+ javaScriptActionPointer = actionCollectionPointer->addAction(QStringLiteral("javascript"));
+ domainSettingsActionPointer = actionCollectionPointer->addAction(QStringLiteral("domain_settings"));
// Create the action groups
QActionGroup *userAgentActionGroupPointer = new QActionGroup(this);
forwardActionPointer->setText(i18nc("Forward button", "Forward"));
refreshActionPointer->setText(i18nc("Refresh button", "Refresh"));
homeActionPointer->setText(i18nc("Home button", "Home"));
+ javaScriptActionPointer->setText(i18nc("JavaScript button", "JavaScript"));
+ domainSettingsActionPointer->setText(i18nc("Domain Settings button", "Domain Settings"));
// Set the action icons.
backActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("arrow-left")));
forwardActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("arrow-right")));
refreshActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("view-refresh")));
homeActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("home")));
+ domainSettingsActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("network-server-symbolic")));
// Update the on-the-fly menus.
connect(browserViewPointer, SIGNAL(userAgentUpdated(QString)), this, SLOT(updateOnTheFlyUserAgent(QString)));
connect(forwardActionPointer, SIGNAL(triggered()), this, SLOT(forward()));
connect(refreshActionPointer, SIGNAL(triggered()), this, SLOT(refresh()));
connect(homeActionPointer, SIGNAL(triggered()), this, SLOT(home()));
+ connect(javaScriptActionPointer, SIGNAL(triggered()), this, SLOT(toggleJavaScript()));
+ connect(domainSettingsActionPointer, SIGNAL(triggered()), this, SLOT(openDomainSettings()));
// Update the URL toolbar actions.
connect(browserViewPointer, SIGNAL(updateBackAction(bool)), backActionPointer, SLOT(setEnabled(bool)));
connect(browserViewPointer, SIGNAL(updateForwardAction(bool)), forwardActionPointer, SLOT(setEnabled(bool)));
+ connect(browserViewPointer, SIGNAL(updateJavaScriptAction(bool)), this, SLOT(updateJavaScriptAction(bool)));
// Setup the GUI based on the browser_ui.rc file.
setupGUI(StandardWindowOption::Default, ("browser_ui.rc"));
// Create a URL line edit.
urlLineEditPointer = new KLineEdit();
- // Add the URL line edit to the URL toolbar.
+ // Populate the URL toolbar.
urlToolBarPointer->addWidget(urlLineEditPointer);
+ urlToolBarPointer->addAction(javaScriptActionPointer);
+ urlToolBarPointer->addAction(domainSettingsActionPointer);
// Load a new URL from the URL line edit.
connect(urlLineEditPointer, SIGNAL(returnKeyPressed(const QString)), this, SLOT(loadUrlFromLineEdit(const QString)));
browserViewPointer->loadUrlFromLineEdit(url);
}
+void BrowserWindow::openDomainSettings() const
+{
+ // Remove the focus from the URL line edit.
+ urlLineEditPointer->clearFocus();
+
+ // Instantiate the domain settings window.
+ DomainSettingsDialog *domainSettingsDialogPointer = new DomainSettingsDialog();
+
+ // Set the dialog window title.
+ domainSettingsDialogPointer->setWindowTitle(i18nc("The domain settings dialog title", "Domain Settings"));
+
+ // Set the modality.
+ domainSettingsDialogPointer->setWindowModality(Qt::WindowModality::WindowModal);;
+
+ // Show the dialog.
+ domainSettingsDialogPointer->show();
+
+ // Reload the tabs when domain settings are updated.
+ connect(domainSettingsDialogPointer, SIGNAL(domainSettingsUpdated()), browserViewPointer, SLOT(applyDomainSettingsAndReload()));
+}
+
void BrowserWindow::refresh() const
{
// Remove the focus from the URL line edit.
browserViewPointer->refresh();
}
+void BrowserWindow::toggleJavaScript() const
+{
+ // Remove the focus from the URL line edit.
+ urlLineEditPointer->clearFocus();
+
+ // Toggle JavaScript.
+ browserViewPointer->toggleJavaScript();
+}
+
void BrowserWindow::settingsConfigure()
{
// Check to make sure the dialog box isn't already displayed.
}
}
-void BrowserWindow::updateDomainSettingsIndicator(const bool status) const
+void BrowserWindow::updateDomainSettingsIndicator(const bool &status) const
{
// Set the domain palette according to the status.
if (status) urlLineEditPointer->setPalette(domainSettingsPalette);
else urlLineEditPointer->setPalette(noDomainSettingsPalette);
}
+void BrowserWindow::updateJavaScriptAction(const bool &isEnabled) const
+{
+ // Set the icon according to the status.
+ if (isEnabled) javaScriptActionPointer->setIcon(QIcon(":/icons/javascript-warning"));
+ else javaScriptActionPointer->setIcon(QIcon(":/icons/privacy-mode"));
+}
+
void BrowserWindow::updateOnTheFlySearchEngine(const QString &searchEngine) const
{
// Initialize the custom search engine flag.
void getZoomFactorFromUser();
void home() const;
void loadUrlFromLineEdit(const QString &url) const;
+ void openDomainSettings() const;
void refresh() const;
void settingsConfigure();
- void updateDomainSettingsIndicator(const bool status) const;
+ void toggleJavaScript() const;
+ void updateDomainSettingsIndicator(const bool &status) const;
+ void updateJavaScriptAction(const bool &isEnabled) const;
void updateOnTheFlySearchEngine(const QString &searchEngine) const;
void updateOnTheFlyUserAgent(const QString &userAgent) const;
void updateOnTheFlyZoomFactor(const double &zoomFactor);
QAction *backActionPointer;
BrowserView *browserViewPointer;
KConfigDialog *configDialogPointer;
+ QAction *domainSettingsActionPointer;
QPalette domainSettingsPalette;
double currentZoomFactor;
QAction *forwardActionPointer;
QAction *homeActionPointer;
+ QAction *javaScriptActionPointer;
QPalette noDomainSettingsPalette;
QLabel *searchEngineLabelPointer;
QAction *searchEngineMojeekActionPointer;