X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserPC.git;a=blobdiff_plain;f=src%2Fwindows%2FBrowserWindow.cpp;fp=src%2Fwindows%2FBrowserWindow.cpp;h=e84f9574835bdf1ad6c04df0304e518d1ee7c9cb;hp=d3800ad8e1674c93b7c54e77c0be5618c62eed6f;hb=ab3422aabe802b11f4ddf32df6a2a33e1fff9c96;hpb=83e7c484d2440bfff54e8d02b2d532c2aba755ef diff --git a/src/windows/BrowserWindow.cpp b/src/windows/BrowserWindow.cpp index d3800ad..e84f957 100644 --- a/src/windows/BrowserWindow.cpp +++ b/src/windows/BrowserWindow.cpp @@ -36,6 +36,7 @@ #include #include #include +#include #include // Construct the class. @@ -56,13 +57,14 @@ BrowserWindow::BrowserWindow() : KXmlGuiWindow() 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")); @@ -219,8 +221,9 @@ BrowserWindow::BrowserWindow() : KXmlGuiWindow() 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(); @@ -273,6 +276,17 @@ BrowserWindow::BrowserWindow() : KXmlGuiWindow() 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(); } @@ -340,6 +354,13 @@ void BrowserWindow::clearUrlLineEditFocus() const 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. @@ -355,6 +376,33 @@ void BrowserWindow::forward() const 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. @@ -539,13 +587,13 @@ void BrowserWindow::settingsConfigure() } } -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 @@ -557,13 +605,53 @@ 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