X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=src%2Fwindows%2FBrowserWindow.cpp;h=effb0918b0faeca5b1bace2b017300e6dae7a1d7;hb=77a3805e3b7c6ee7daeb2db660bb4b2789b33da2;hp=3958c88cbacf3bea314cbf118479b9a19a2523b5;hpb=93a1583163ca580a2218ba81836a17c3a6586ccf;p=PrivacyBrowserPC.git diff --git a/src/windows/BrowserWindow.cpp b/src/windows/BrowserWindow.cpp index 3958c88..effb091 100644 --- a/src/windows/BrowserWindow.cpp +++ b/src/windows/BrowserWindow.cpp @@ -59,7 +59,6 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow() KActionCollection *actionCollectionPointer = this->actionCollection(); // Add the standard actions. - KStandardAction::openNew(this, SLOT(fileNew()), actionCollectionPointer); KStandardAction::print(tabWidgetPointer, SLOT(print()), actionCollectionPointer); KStandardAction::printPreview(tabWidgetPointer, SLOT(printPreview()), actionCollectionPointer); KStandardAction::quit(qApp, SLOT(closeAllWindows()), actionCollectionPointer); @@ -74,6 +73,8 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow() findPreviousActionPointer = KStandardAction::findPrev(this, SLOT(findPrevious()), actionCollectionPointer); // Add the custom actions. + QAction *newTabActionPointer = actionCollectionPointer->addAction(QLatin1String("new_tab")); + QAction *newWindowActionPointer = actionCollectionPointer->addAction(QLatin1String("new_window")); userAgentPrivacyBrowserActionPointer = actionCollectionPointer->addAction(QLatin1String("user_agent_privacy_browser")); userAgentWebEngineDefaultActionPointer = actionCollectionPointer->addAction(QLatin1String("user_agent_webengine_default")); userAgentFirefoxLinuxActionPointer = actionCollectionPointer->addAction(QLatin1String("user_agent_firefox_linux")); @@ -147,6 +148,8 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow() UserAgentHelper *userAgentHelperPointer = new UserAgentHelper(); // Set the action text. + newTabActionPointer->setText(i18nc("New tab action", "New Tab")); + newWindowActionPointer->setText(i18nc("New window action", "New Window")); userAgentPrivacyBrowserActionPointer->setText(userAgentHelperPointer->PRIVACY_BROWSER_TRANSLATED); userAgentWebEngineDefaultActionPointer->setText(userAgentHelperPointer->WEB_ENGINE_DEFAULT_TRANSLATED); userAgentFirefoxLinuxActionPointer->setText(userAgentHelperPointer->FIREFOX_LINUX_TRANSLATED); @@ -170,6 +173,8 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow() hideFindTextActionPointer->setText(i18nc("Hide Find Text action", "Hide Find Text")); // Set the action icons. + newTabActionPointer->setIcon(QIcon::fromTheme(QLatin1String("tab-new"))); + newWindowActionPointer->setIcon(QIcon::fromTheme(QLatin1String("window-new"))); userAgentPrivacyBrowserActionPointer->setIcon(QIcon(":/icons/privacy-mode")); userAgentWebEngineDefaultActionPointer->setIcon(QIcon::fromTheme(QLatin1String("user-group-properties"))); userAgentFirefoxLinuxActionPointer->setIcon(QIcon::fromTheme(QLatin1String("firefox-esr"))); @@ -193,6 +198,21 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow() findCaseSensitiveActionPointer->setIcon(QIcon::fromTheme(QLatin1String("format-text-lowercase"))); hideFindTextActionPointer->setIcon(QIcon::fromTheme(QLatin1String("window-close-symbolic"))); + // Create the key sequences. + QKeySequence ctrlTKeySequence = QKeySequence(i18nc("The open new tab key sequence.", "Ctrl+T")); + QKeySequence ctrlNKeySequence = QKeySequence(i18nc("The open new window key sequence.", "Ctrl+N")); + + // Set the action key sequences. + newTabActionPointer->setShortcut(ctrlTKeySequence); + newWindowActionPointer->setShortcut(ctrlNKeySequence); + + // Execute the actions. + connect(newTabActionPointer, SIGNAL(triggered()), tabWidgetPointer, SLOT(addTab())); + connect(newWindowActionPointer, SIGNAL(triggered()), this, SLOT(newWindow())); + connect(zoomFactorActionPointer, SIGNAL(triggered()), this, SLOT(getZoomFactorFromUser())); + connect(cookiesActionPointer, SIGNAL(triggered()), this, SLOT(showCookiesDialog())); + connect(domainSettingsActionPointer, SIGNAL(triggered()), this, SLOT(showDomainSettingsDialog())); + // Update the on-the-fly menus. connect(tabWidgetPointer, SIGNAL(updateUserAgentActions(QString, bool)), this, SLOT(updateUserAgentActions(QString, bool))); connect(tabWidgetPointer, SIGNAL(updateZoomFactorAction(double)), this, SLOT(updateZoomFactorAction(double))); @@ -205,11 +225,6 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow() // Process cookie changes. connect(tabWidgetPointer, SIGNAL(updateCookiesAction(int)), this, SLOT(updateCookiesAction(int))); - // Display dialogs. - connect(zoomFactorActionPointer, SIGNAL(triggered()), this, SLOT(getZoomFactorFromUser())); - connect(cookiesActionPointer, SIGNAL(triggered()), this, SLOT(showCookiesDialog())); - connect(domainSettingsActionPointer, SIGNAL(triggered()), this, SLOT(showDomainSettingsDialog())); - // Connect the URL toolbar actions. connect(javaScriptActionPointer, SIGNAL(triggered()), this, SLOT(toggleJavaScript())); connect(localStorageActionPointer, SIGNAL(triggered()), this, SLOT(toggleLocalStorage())); @@ -353,12 +368,10 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow() connect(tabWidgetPointer, SIGNAL(fullScreenRequested(bool)), this, SLOT(fullScreenRequested(bool))); // Create keyboard shortcuts. - QShortcut *ctrlTShortcutPointer = new QShortcut(QKeySequence(i18nc("The open new tab shortcut.", "Ctrl+t")), this); 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(ctrlTShortcutPointer, SIGNAL(activated()), tabWidgetPointer, SLOT(addTab())); + // Connect the keyboard shortcuts. connect(f11ShortcutPointer, SIGNAL(activated()), fullScreenActionPointer, SLOT(trigger())); connect(escapeShortcutPointer, SIGNAL(activated()), this, SLOT(escape())); @@ -434,7 +447,7 @@ void BrowserWindow::escape() const // Exit full screen browsing. fullScreenActionPointer->trigger(); } - else if (!findTextLineEditPointer->text().isEmpty()) // Find text is activated. + else if (!findTextLineEditPointer->text().isEmpty()) // Find text is populated. { // Clear the text in the line edit. findTextLineEditPointer->clear(); @@ -442,12 +455,11 @@ void BrowserWindow::escape() const // Clear the search in the WebEngine. tabWidgetPointer->findText(QStringLiteral("")); } -} - -void BrowserWindow::fileNew() const -{ - // Display a new instance of Privacy Browser. - (new BrowserWindow)->show(); + else if (findTextLineEditActionPointer->isVisible()) // Find text actions are visible. + { + // Hide the find text actions. + hideFindTextActions(); + } } void BrowserWindow::findNext() const @@ -561,6 +573,12 @@ void BrowserWindow::loadUrlFromLineEdit(const QString &url) const tabWidgetPointer->loadUrlFromLineEdit(url); } +void BrowserWindow::newWindow() const +{ + // Display a new instance of Privacy Browser. + (new BrowserWindow)->show(); +} + void BrowserWindow::refresh() const { // Remove the focus from the URL line edit.