// Create the keyboard shortcuts.
QShortcut *aShortcutPointer = new QShortcut(QKeySequence(i18nc("The add cookie key shortcut.", "a")), this);
- QShortcut *eShortcutPointer = new QShortcut(QKeySequence(i18nc("The edit cookie key shorcut.", "e")), this);
+ QShortcut *eShortcutPointer = new QShortcut(QKeySequence(i18nc("The edit cookie key shortcut.", "e")), this);
QShortcut *dShortcutPointer = new QShortcut(QKeySequence(i18nc("The delete cookie key shortcut.", "d")), this);
QShortcut *deleteShortcutPointer = new QShortcut(QKeySequence::Delete, this);
QShortcut *lShortcutPointer = new QShortcut(QKeySequence(i18nc("The delete all key shortcut.", "l")), this);
<entry name="zoomFactor" type="Double">
<default>1.00</default>
</entry>
+
+ <entry name="fullScreenHideMenuBar" type="Bool">
+ <default>true</default>
+ </entry>
+
+ <entry name="fullScreenHideToolBars" type="Bool">
+ <default>true</default>
+ </entry>
+
+ <entry name="fullScreenHideStatusBar" type="Bool">
+ <default>true</default>
+ </entry>
</group>
</kcfg>
<class>GeneralSettings</class>
<widget class="QWidget">
- <layout class="QFormLayout">
- <!-- Homepage. -->
- <item row="0" column="0">
- <widget class="QLabel" name="homepageLabel">
- <property name="text">
- <string>Homepage</string>
- </property>
-
- <property name="toolTip">
- <string>The default is https://www.mojeek.com/.</string>
- </property>
- </widget>
- </item>
-
- <item row="0" column="1">
- <widget class="KLineEdit" name="kcfg_homepage" />
- </item>
-
- <!-- Search engine. -->
- <item row="1" column="0">
- <widget class="QLabel">
- <property name="text">
- <string>Search engine</string>
- </property>
-
- <property name="toolTip">
- <string>The default is Mojeek.</string>
- </property>
- </widget>
- </item>
-
- <item row="1" column="1">
- <widget class="QComboBox" name="kcfg_searchEngine">
- <property name="sizePolicy">
- <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
- <horstretch>0</horstretch>
- <verstretch>0</verstretch>
- </sizepolicy>
- </property>
-
- <property name="editable">
- <bool>true</bool>
- </property>
-
- <item>
- <property name="text">
- <string>Mojeek</string>
- </property>
+ <layout class="QVBoxLayout">
+ <item>
+ <layout class="QFormLayout">
+ <!-- Homepage. -->
+ <item row="0" column="0">
+ <widget class="QLabel" name="homepageLabel">
+ <property name="text">
+ <string>Homepage</string>
+ </property>
+
+ <property name="toolTip">
+ <string>The default is https://www.mojeek.com/.</string>
+ </property>
+ </widget>
</item>
- <item>
- <property name="text">
- <string>Monocles</string>
- </property>
+ <item row="0" column="1">
+ <widget class="KLineEdit" name="kcfg_homepage" />
</item>
- <item>
- <property name="text">
- <string>MetaGer</string>
- </property>
+ <!-- Search engine. -->
+ <item row="1" column="0">
+ <widget class="QLabel">
+ <property name="text">
+ <string>Search engine</string>
+ </property>
+
+ <property name="toolTip">
+ <string>The default is Mojeek.</string>
+ </property>
+ </widget>
</item>
- <item>
- <property name="text">
- <string>Google</string>
- </property>
+ <item row="1" column="1">
+ <widget class="QComboBox" name="kcfg_searchEngine">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Expanding" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+
+ <property name="editable">
+ <bool>true</bool>
+ </property>
+
+ <item>
+ <property name="text">
+ <string>Mojeek</string>
+ </property>
+ </item>
+
+ <item>
+ <property name="text">
+ <string>Monocles</string>
+ </property>
+ </item>
+
+ <item>
+ <property name="text">
+ <string>MetaGer</string>
+ </property>
+ </item>
+
+ <item>
+ <property name="text">
+ <string>Google</string>
+ </property>
+ </item>
+
+ <item>
+ <property name="text">
+ <string>Bing</string>
+ </property>
+ </item>
+
+ <item>
+ <property name="text">
+ <string>Yahoo</string>
+ </property>
+ </item>
+ </widget>
</item>
- <item>
- <property name="text">
- <string>Bing</string>
- </property>
+ <item row="2" column="1">
+ <widget class="QLabel" name="searchEngineLabel">
+ <property name="textInteractionFlags">
+ <set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
+ </property>
+ </widget>
</item>
- <item>
- <property name="text">
- <string>Yahoo</string>
- </property>
+ <!-- Zoom factor. -->
+ <item row="3" column="0">
+ <widget class="QLabel" name="zoomFactorLabel">
+ <property name="text">
+ <string>Zoom factor</string>
+ </property>
+
+ <property name="toolTip">
+ <string>Valid values for the zoom factor are between 0.25 and 5.00. The default is 1.00.</string>
+ </property>
+ </widget>
</item>
- </widget>
- </item>
- <item row="2" column="1">
- <widget class="QLabel" name="searchEngineLabel">
- <property name="textInteractionFlags">
- <set>Qt::TextSelectableByKeyboard|Qt::TextSelectableByMouse</set>
- </property>
- </widget>
- </item>
+ <item row="3" column="1">
+ <widget class="QDoubleSpinBox" name="kcfg_zoomFactor">
+ <property name="minimum">
+ <double>0.250000000000000</double>
+ </property>
- <!-- Zoom factor. -->
- <item row="3" column="0">
- <widget class="QLabel" name="zoomFactorLabel">
- <property name="text">
- <string>Zoom factor</string>
- </property>
+ <property name="maximum">
+ <double>5.000000000000000</double>
+ </property>
- <property name="toolTip">
- <string>Valid values for the zoom factor are between 0.25 and 5.00. The default is 1.00.</string>
- </property>
- </widget>
+ <property name="singleStep">
+ <double>0.250000000000000</double>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
- <item row="3" column="1">
- <widget class="QDoubleSpinBox" name="kcfg_zoomFactor">
-
- <property name="minimum">
- <double>0.250000000000000</double>
+ <!-- Full screen browsing. -->
+ <item>
+ <widget class="QGroupBox">
+ <property name="title">
+ <string>Full Screen Browsing</string>
</property>
- <property name="maximum">
- <double>5.000000000000000</double>
- </property>
+ <layout class="QVBoxLayout">
+ <!-- Hide menu bar. -->
+ <item>
+ <widget class="QCheckBox" name="kcfg_fullScreenHideMenuBar">
+ <property name="text">
+ <string>Hide menu bar</string>
+ </property>
+
+ <property name="toolTip">
+ <string>Hide the menu bar when browsing full screen. The default is enabled.</string>
+ </property>
+ </widget>
+ </item>
+
+ <!-- Hide toolbars. -->
+ <item>
+ <widget class="QCheckBox" name="kcfg_fullScreenHideToolBars">
+ <property name="text">
+ <string>Hide toolbars</string>
+ </property>
+
+ <property name="toolTip">
+ <string>Hide the toolbars when browsing full screen. The default is enabled.</string>
+ </property>
+ </widget>
+ </item>
+
+ <!-- Hide status bar. -->
+ <item>
+ <widget class="QCheckBox" name="kcfg_fullScreenHideStatusBar">
+ <property name="text">
+ <string>Hide status bar</string>
+ </property>
+
+ <property name="toolTip">
+ <string>Hide the status bar when browsing full screen. The default is enabled.</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
- <property name="singleStep">
- <double>0.250000000000000</double>
+ <!-- Spacer. -->
+ <item>
+ <spacer>
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
</property>
- </widget>
+ </spacer>
</item>
</layout>
</widget>
// Set the WebEngine page.
webEngineViewPointer->setPage(webEnginePagePointer);
+ // Handle full screen requests.
+ connect(webEnginePagePointer, SIGNAL(fullScreenRequested(QWebEngineFullScreenRequest)), this, SLOT(fullScreenRequested(QWebEngineFullScreenRequest)));
+
// Get handles for the aspects of the WebEngine.
webEngineHistoryPointer = webEnginePagePointer->history();
webEngineSettingsPointer = webEngineViewPointer->settings();
webEngineViewPointer->forward();
}
+void BrowserView::fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest) const
+{
+ // Make it so.
+ emit fullScreenRequested(fullScreenRequest.toggleOn());
+
+ // Accept the request.
+ fullScreenRequest.accept();
+}
+
void BrowserView::home() const
{
// Load the homepage.
// Qt toolkit headers.
#include <QPushButton>
+#include <QWebEngineFullScreenRequest>
#include <QWebEngineHistory>
#include <QWebEngineProfile>
#include <QWebEngineSettings>
void addCookie(const QNetworkCookie &cookie) const;
void removeCookie(const QNetworkCookie &cookie) const;
void clearUrlLineEditFocus() const;
+ void fullScreenRequested(const bool toggleOn) const;
void hideProgressBar() const;
void linkHovered(const QString &linkUrl) const;
void showProgressBar(const int &progress) const;
// The private slots.
void cookieAdded(const QNetworkCookie &cookie) const;
void cookieRemoved(const QNetworkCookie &cookie) const;
+ void fullScreenRequested(QWebEngineFullScreenRequest fullScreenRequest) const;
void loadFinished() const;
void loadProgress(const int &progress) const;
void loadStarted() const;
#include <QInputDialog>
#include <QNetworkCookie>
#include <QMenuBar>
+#include <QShortcut>
#include <QStatusBar>
// Construct the class.
KActionCollection *actionCollectionPointer = this->actionCollection();
// Add the standard actions.
+ KStandardAction::openNew(this, SLOT(fileNew()), actionCollectionPointer);
+ KStandardAction::quit(qApp, SLOT(closeAllWindows()), actionCollectionPointer);
+ KStandardAction::redisplay(this, SLOT(refresh()), actionCollectionPointer);
+ fullScreenActionPointer = KStandardAction::fullScreen(this, SLOT(toggleFullScreen()), this, actionCollectionPointer);
QAction *backActionPointer = KStandardAction::back(this, SLOT(back()), actionCollectionPointer);
QAction *forwardActionPointer = KStandardAction::forward(this, SLOT(forward()), actionCollectionPointer);
KStandardAction::home(this, SLOT(home()), actionCollectionPointer);
- KStandardAction::openNew(this, SLOT(fileNew()), actionCollectionPointer);
- KStandardAction::quit(qApp, SLOT(closeAllWindows()), actionCollectionPointer);
KStandardAction::preferences(this, SLOT(settingsConfigure()), actionCollectionPointer);
- KStandardAction::redisplay(this, SLOT(refresh()), actionCollectionPointer);
// Add the custom actions.
userAgentPrivacyBrowserActionPointer = actionCollectionPointer->addAction(QStringLiteral("user_agent_privacy_browser"));
userAgentMenuActionPointer = userAgentMenuPointer->menuAction();
searchEngineMenuActionPointer = searchEngineMenuPointer->menuAction();
- // Get a handle for the URL toolbar.
- KToolBar *urlToolBarPointer = toolBar(QStringLiteral("url_toolbar"));
+ // Get handles for the toolbars.
+ navigationToolBarPointer = toolBar(QStringLiteral("navigation_toolbar"));
+ urlToolBarPointer = toolBar(QStringLiteral("url_toolbar"));
// Create a URL line edit.
urlLineEditPointer = new KLineEdit();
connect(browserViewPointer, SIGNAL(addCookie(QNetworkCookie)), this, SLOT(addCookieToList(QNetworkCookie)));
connect(browserViewPointer, SIGNAL(removeCookie(QNetworkCookie)), this, SLOT(removeCookieFromList(QNetworkCookie)));
+ // Process full screen requests.
+ connect(browserViewPointer, SIGNAL(fullScreenRequested(bool)), this, SLOT(fullScreenRequested(bool)));
+
+ // Create keyboard shortcuts.
+ QShortcut *f11ShortcutPointer = new QShortcut(QKeySequence(i18nc("The toggle full screen shortcut.", "F11")), this);
+ QShortcut *escapeShortcutPointer = new QShortcut(QKeySequence::Cancel, this);
+
+ // Connect the keyboard shortcuts to the actions.
+ connect(f11ShortcutPointer, SIGNAL(activated()), fullScreenActionPointer, SLOT(trigger()));
+ connect(escapeShortcutPointer, SIGNAL(activated()), this, SLOT(escape()));
+
// Load the initial website.
browserViewPointer->loadInitialWebsite();
}
urlLineEditPointer->clearFocus();
}
+void BrowserWindow::escape() const
+{
+ // Exit full screen browsing if it is enabled.
+ if (fullScreenActionPointer->isChecked())
+ fullScreenActionPointer->trigger();
+}
+
void BrowserWindow::fileNew() const
{
// Display a new instance of Privacy Browser.
browserViewPointer->forward();
}
+void BrowserWindow::fullScreenRequested(const bool toggleOn)
+{
+ // Toggle full screen mode.
+ if (toggleOn) // Turn full screen mode on.
+ {
+ // Set the window to be full screen.
+ fullScreenActionPointer->setFullScreen(window(), true);
+
+ // Hide all the bars.
+ menuBar()->setVisible(false);
+ navigationToolBarPointer->setVisible(false);
+ urlToolBarPointer->setVisible(false);
+ statusBar()->setVisible(false);
+ }
+ else // Turn full screen mode off.
+ {
+ // Set the window to not be full screen.
+ fullScreenActionPointer->setFullScreen(window(), false);
+
+ // Show all the bars.
+ menuBar()->setVisible(true);
+ navigationToolBarPointer->setVisible(true);
+ urlToolBarPointer->setVisible(true);
+ statusBar()->setVisible(true);
+ }
+}
+
void BrowserWindow::getZoomFactorFromUser()
{
// Create an OK flag.
}
}
-void BrowserWindow::toggleLocalStorage() const
+void BrowserWindow::toggleDomStorage() const
{
- // Remove the focus from teh URL line edit.
+ // Remove the focus from the URL line edit.
urlLineEditPointer->clearFocus();
- // Toggle local storage.
- browserViewPointer->toggleLocalStorage();
+ // Toggle DOM storage.
+ browserViewPointer->toggleDomStorage();
}
void BrowserWindow::toggleJavaScript() const
browserViewPointer->toggleJavaScript();
}
-void BrowserWindow::toggleDomStorage() const
+void BrowserWindow::toggleLocalStorage() const
{
// Remove the focus from the URL line edit.
urlLineEditPointer->clearFocus();
- // Toggle DOM storage.
- browserViewPointer->toggleDomStorage();
+ // Toggle local storage.
+ browserViewPointer->toggleLocalStorage();
+}
+
+void BrowserWindow::toggleFullScreen()
+{
+ // Toggle the full screen status.
+ if (fullScreenActionPointer->isChecked()) // Enable full screen browsing mode.
+ {
+ // Enable full screen mode.
+ fullScreenActionPointer->setFullScreen(window(), true);
+
+ // Hide the menu bar if specified.
+ if (Settings::fullScreenHideMenuBar())
+ menuBar()->setVisible(false);
+
+ // Hide the toolbars if specified.
+ if (Settings::fullScreenHideToolBars())
+ {
+ navigationToolBarPointer->setVisible(false);
+ urlToolBarPointer->setVisible(false);
+ }
+
+ // Hide the status bar if specified.
+ if (Settings::fullScreenHideStatusBar())
+ statusBar()->setVisible(false);
+ }
+ else // Disable full screen browsing mode.
+ {
+ // Disable full screen mode.
+ fullScreenActionPointer->setFullScreen(window(), false);
+
+ // Show the menu bar.
+ menuBar()->setVisible(true);
+
+ // Show the toolbars.
+ navigationToolBarPointer->setVisible(true);
+ urlToolBarPointer->setVisible(true);
+
+ // Show the status bar.
+ statusBar()->setVisible(true);
+ }
}
void BrowserWindow::updateDomStorageAction(const bool &isEnabled) const
// KDE Frameworks headers.
#include <KConfigDialog>
+#include <KToggleFullScreenAction>
#include <KXmlGuiWindow>
// Qt toolkit headers.
void addOrEditDomainSettings() const;
void back() const;
void clearUrlLineEditFocus() const;
+ void escape() const;
void fileNew() const;
void forward() const;
+ void fullScreenRequested(const bool toggleOn);
void getZoomFactorFromUser();
void home() const;
void loadUrlFromLineEdit(const QString &url) const;
void toggleDomStorage() const;
void toggleJavaScript() const;
void toggleLocalStorage() const;
+ void toggleFullScreen();
void updateDomStorageAction(const bool &isEnabled) const;
void updateDomainSettingsIndicator(const bool &status, const QString &domainSettingsDomain);
void updateJavaScriptAction(const bool &isEnabled);
bool customUserAgentEnabled;
QAction *domStorageActionPointer;
QPalette domainSettingsPalette;
+ KToggleFullScreenAction *fullScreenActionPointer;
QAction *javaScriptActionPointer;
bool javaScriptEnabled;
QAction *localStorageActionPointer;
bool localStorageEnabled;
+ KToolBar *navigationToolBarPointer;
QPalette noDomainSettingsPalette;
QProgressBar *progressBarPointer;
QLabel *searchEngineLabelPointer;
QAction *userAgentSafariMacosActionPointer;
QAction *userAgentCustomActionPointer;
KLineEdit *urlLineEditPointer;
+ KToolBar *urlToolBarPointer;
QAction *zoomFactorActionPointer;
};
#endif