]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/commitdiff
Hide the find text actions by default. https://redmine.stoutner.com/issues/960
authorSoren Stoutner <soren@stoutner.com>
Wed, 8 Feb 2023 18:53:21 +0000 (11:53 -0700)
committerSoren Stoutner <soren@stoutner.com>
Wed, 8 Feb 2023 18:53:21 +0000 (11:53 -0700)
src/ui.rcs/browserwindowui.rc
src/widgets/TabWidget.cpp
src/windows/BrowserWindow.cpp
src/windows/BrowserWindow.h

index d0e664de4b3f0b7008d11caeb7c9affc69c180c7..2ee3cd775f455a136a9a961c70d2005904b32ae1 100644 (file)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 
 <!--
-  Copyright 2022 Soren Stoutner <soren@stoutner.com>.
+  Copyright 2022-2023 Soren Stoutner <soren@stoutner.com>.
 
   This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
 
@@ -85,5 +85,6 @@
         <Action name="edit_find_next" />
         <Action name="edit_find_prev" />
         <Action name="find_case_sensitive" />
+        <Action name="hide_find_actions" />
     </ToolBar>
 </gui>
index a5ecefc3b96579b75f1e0b5404b7753f2c720322..5b5a08c630cbae3985ef41b42711d6ba88459bef 100644 (file)
@@ -219,6 +219,14 @@ PrivacyWebEngineView* TabWidget::addTab(const bool removeUrlLineEditFocus, const
             emit hideProgressBar();
     });
 
+    // Update the zoom factor when changed by CTRL-Scrolling.  This can be modified when <https://redmine.stoutner.com/issues/845> is fixed.
+    connect(webEnginePagePointer, &QWebEnginePage::contentsSizeChanged, [webEnginePagePointer, this] ()
+    {
+        // Only update the zoom factor action text if this is the current tab.
+        if (webEnginePagePointer == currentWebEnginePagePointer)
+            emit updateZoomFactorAction(webEnginePagePointer->zoomFactor());
+    });
+
     // Display find text results.
     connect(webEnginePagePointer, SIGNAL(findTextFinished(const QWebEngineFindTextResult &)), this, SLOT(findTextFinished(const QWebEngineFindTextResult &)));
 
index efa87ab0ea6fe57d710ea04a6984251a93cec00c..3958c88cbacf3bea314cbf118479b9a19a2523b5 100644 (file)
@@ -69,34 +69,35 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow()
     QAction *forwardActionPointer = KStandardAction::forward(this, SLOT(forward()), actionCollectionPointer);
     KStandardAction::home(this, SLOT(home()), actionCollectionPointer);
     KStandardAction::preferences(this, SLOT(showSettingsDialog()), actionCollectionPointer);
-    KStandardAction::find(this, SLOT(focusFindLineEdit()), actionCollectionPointer);
-    QAction *findNextActionPointer = KStandardAction::findNext(this, SLOT(findNext()), actionCollectionPointer);
-    KStandardAction::findPrev(this, SLOT(findPrevious()), actionCollectionPointer);
+    KStandardAction::find(this, SLOT(showFindTextActions()), actionCollectionPointer);
+    findNextActionPointer = KStandardAction::findNext(this, SLOT(findNext()), actionCollectionPointer);
+    findPreviousActionPointer = KStandardAction::findPrev(this, SLOT(findPrevious()), actionCollectionPointer);
 
     // Add the custom actions.
-    userAgentPrivacyBrowserActionPointer = actionCollectionPointer->addAction(QStringLiteral("user_agent_privacy_browser"));
-    userAgentWebEngineDefaultActionPointer = actionCollectionPointer->addAction(QStringLiteral("user_agent_webengine_default"));
-    userAgentFirefoxLinuxActionPointer = actionCollectionPointer->addAction(QStringLiteral("user_agent_firefox_linux"));
-    userAgentChromiumLinuxActionPointer = actionCollectionPointer->addAction(QStringLiteral("user_agent_chromium_linux"));
-    userAgentFirefoxWindowsActionPointer = actionCollectionPointer->addAction(QStringLiteral("user_agent_firefox_windows"));
-    userAgentChromeWindowsActionPointer = actionCollectionPointer->addAction(QStringLiteral("user_agent_chrome_windows"));
-    userAgentEdgeWindowsActionPointer = actionCollectionPointer->addAction(QStringLiteral("user_agent_edge_windows"));
-    userAgentSafariMacosActionPointer = actionCollectionPointer->addAction(QStringLiteral("user_agent_safari_macos"));
-    userAgentCustomActionPointer = actionCollectionPointer->addAction(QStringLiteral("user_agent_custom"));
-    zoomFactorActionPointer = actionCollectionPointer->addAction(QStringLiteral("zoom_factor"));
-    searchEngineMojeekActionPointer = actionCollectionPointer->addAction(QStringLiteral("search_engine_mojeek"));
-    searchEngineMonoclesActionPointer = actionCollectionPointer->addAction(QStringLiteral("search_engine_monocles"));
-    searchEngineMetagerActionPointer = actionCollectionPointer->addAction(QStringLiteral("search_engine_metager"));
-    searchEngineGoogleActionPointer = actionCollectionPointer->addAction(QStringLiteral("search_engine_google"));
-    searchEngineBingActionPointer = actionCollectionPointer->addAction(QStringLiteral("search_engine_bing"));
-    searchEngineYahooActionPointer = actionCollectionPointer->addAction(QStringLiteral("search_engine_yahoo"));
-    searchEngineCustomActionPointer = actionCollectionPointer->addAction(QStringLiteral("search_engine_custom"));
-    QAction *domainSettingsActionPointer = actionCollectionPointer->addAction(QStringLiteral("domain_settings"));
-    cookiesActionPointer = actionCollectionPointer->addAction(QStringLiteral("cookies"));
-    javaScriptActionPointer = actionCollectionPointer->addAction(QStringLiteral("javascript"));
-    localStorageActionPointer = actionCollectionPointer->addAction(QStringLiteral("local_storage"));
-    domStorageActionPointer = actionCollectionPointer->addAction(QStringLiteral("dom_storage"));
-    findCaseSensitiveActionPointer = actionCollectionPointer->addAction(QStringLiteral("find_case_sensitive"));
+    userAgentPrivacyBrowserActionPointer = actionCollectionPointer->addAction(QLatin1String("user_agent_privacy_browser"));
+    userAgentWebEngineDefaultActionPointer = actionCollectionPointer->addAction(QLatin1String("user_agent_webengine_default"));
+    userAgentFirefoxLinuxActionPointer = actionCollectionPointer->addAction(QLatin1String("user_agent_firefox_linux"));
+    userAgentChromiumLinuxActionPointer = actionCollectionPointer->addAction(QLatin1String("user_agent_chromium_linux"));
+    userAgentFirefoxWindowsActionPointer = actionCollectionPointer->addAction(QLatin1String("user_agent_firefox_windows"));
+    userAgentChromeWindowsActionPointer = actionCollectionPointer->addAction(QLatin1String("user_agent_chrome_windows"));
+    userAgentEdgeWindowsActionPointer = actionCollectionPointer->addAction(QLatin1String("user_agent_edge_windows"));
+    userAgentSafariMacosActionPointer = actionCollectionPointer->addAction(QLatin1String("user_agent_safari_macos"));
+    userAgentCustomActionPointer = actionCollectionPointer->addAction(QLatin1String("user_agent_custom"));
+    zoomFactorActionPointer = actionCollectionPointer->addAction(QLatin1String("zoom_factor"));
+    searchEngineMojeekActionPointer = actionCollectionPointer->addAction(QLatin1String("search_engine_mojeek"));
+    searchEngineMonoclesActionPointer = actionCollectionPointer->addAction(QLatin1String("search_engine_monocles"));
+    searchEngineMetagerActionPointer = actionCollectionPointer->addAction(QLatin1String("search_engine_metager"));
+    searchEngineGoogleActionPointer = actionCollectionPointer->addAction(QLatin1String("search_engine_google"));
+    searchEngineBingActionPointer = actionCollectionPointer->addAction(QLatin1String("search_engine_bing"));
+    searchEngineYahooActionPointer = actionCollectionPointer->addAction(QLatin1String("search_engine_yahoo"));
+    searchEngineCustomActionPointer = actionCollectionPointer->addAction(QLatin1String("search_engine_custom"));
+    QAction *domainSettingsActionPointer = actionCollectionPointer->addAction(QLatin1String("domain_settings"));
+    cookiesActionPointer = actionCollectionPointer->addAction(QLatin1String("cookies"));
+    javaScriptActionPointer = actionCollectionPointer->addAction(QLatin1String("javascript"));
+    localStorageActionPointer = actionCollectionPointer->addAction(QLatin1String("local_storage"));
+    domStorageActionPointer = actionCollectionPointer->addAction(QLatin1String("dom_storage"));
+    findCaseSensitiveActionPointer = actionCollectionPointer->addAction(QLatin1String("find_case_sensitive"));
+    hideFindTextActionPointer = actionCollectionPointer->addAction(QLatin1String("hide_find_actions"));
 
     // Create the action groups
     QActionGroup *userAgentActionGroupPointer = new QActionGroup(this);
@@ -166,29 +167,31 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow()
     localStorageActionPointer->setText(i18nc("The Local Storage action", "Local Storage"));
     domStorageActionPointer->setText(i18nc("DOM Storage action", "DOM Storage"));
     findCaseSensitiveActionPointer->setText(i18nc("Find Case Sensitive action", "Find Case Sensitive"));
+    hideFindTextActionPointer->setText(i18nc("Hide Find Text action", "Hide Find Text"));
 
     // Set the action icons.
     userAgentPrivacyBrowserActionPointer->setIcon(QIcon(":/icons/privacy-mode"));
-    userAgentWebEngineDefaultActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("user-group-properties")));
-    userAgentFirefoxLinuxActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("firefox-esr")));
-    userAgentChromiumLinuxActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("chromium")));
-    userAgentFirefoxWindowsActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("firefox-esr")));
-    userAgentChromeWindowsActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("chromium")));
-    userAgentEdgeWindowsActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("user-group-properties")));
-    userAgentSafariMacosActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("user-group-properties")));
-    userAgentCustomActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("user-group-properties")));
-    searchEngineMojeekActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("search")));
-    searchEngineMonoclesActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("search")));
-    searchEngineMetagerActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("search")));
-    searchEngineGoogleActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("im-google")));
-    searchEngineBingActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("search")));
-    searchEngineYahooActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("im-yahoo")));
-    searchEngineCustomActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("search")));
-    zoomFactorActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("zoom")));
-    domainSettingsActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("settings-configure")));
-    cookiesActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("preferences-web-browser-cookies")));
-    domStorageActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("code-class")));
-    findCaseSensitiveActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("format-text-lowercase")));
+    userAgentWebEngineDefaultActionPointer->setIcon(QIcon::fromTheme(QLatin1String("user-group-properties")));
+    userAgentFirefoxLinuxActionPointer->setIcon(QIcon::fromTheme(QLatin1String("firefox-esr")));
+    userAgentChromiumLinuxActionPointer->setIcon(QIcon::fromTheme(QLatin1String("chromium")));
+    userAgentFirefoxWindowsActionPointer->setIcon(QIcon::fromTheme(QLatin1String("firefox-esr")));
+    userAgentChromeWindowsActionPointer->setIcon(QIcon::fromTheme(QLatin1String("chromium")));
+    userAgentEdgeWindowsActionPointer->setIcon(QIcon::fromTheme(QLatin1String("user-group-properties")));
+    userAgentSafariMacosActionPointer->setIcon(QIcon::fromTheme(QLatin1String("user-group-properties")));
+    userAgentCustomActionPointer->setIcon(QIcon::fromTheme(QLatin1String("user-group-properties")));
+    searchEngineMojeekActionPointer->setIcon(QIcon::fromTheme(QLatin1String("search")));
+    searchEngineMonoclesActionPointer->setIcon(QIcon::fromTheme(QLatin1String("search")));
+    searchEngineMetagerActionPointer->setIcon(QIcon::fromTheme(QLatin1String("search")));
+    searchEngineGoogleActionPointer->setIcon(QIcon::fromTheme(QLatin1String("im-google")));
+    searchEngineBingActionPointer->setIcon(QIcon::fromTheme(QLatin1String("search")));
+    searchEngineYahooActionPointer->setIcon(QIcon::fromTheme(QLatin1String("im-yahoo")));
+    searchEngineCustomActionPointer->setIcon(QIcon::fromTheme(QLatin1String("search")));
+    zoomFactorActionPointer->setIcon(QIcon::fromTheme(QLatin1String("zoom")));
+    domainSettingsActionPointer->setIcon(QIcon::fromTheme(QLatin1String("settings-configure")));
+    cookiesActionPointer->setIcon(QIcon::fromTheme(QLatin1String("preferences-web-browser-cookies")));
+    domStorageActionPointer->setIcon(QIcon::fromTheme(QLatin1String("code-class")));
+    findCaseSensitiveActionPointer->setIcon(QIcon::fromTheme(QLatin1String("format-text-lowercase")));
+    hideFindTextActionPointer->setIcon(QIcon::fromTheme(QLatin1String("window-close-symbolic")));
 
     // Update the on-the-fly menus.
     connect(tabWidgetPointer, SIGNAL(updateUserAgentActions(QString, bool)), this, SLOT(updateUserAgentActions(QString, bool)));
@@ -221,8 +224,9 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow()
 
     // Connect the find text actions.
     connect(findCaseSensitiveActionPointer, SIGNAL(triggered()), this, SLOT(toggleFindCaseSensitive()));
+    connect(hideFindTextActionPointer, SIGNAL(triggered()), this, SLOT(hideFindTextActions()));
 
-    // Setup the GUI based on the browser_window_ui.rc file.
+    // Setup the GUI based on the browserwindowui.rc file.
     setupGUI(StandardWindowOption::Default, ("browserwindowui.rc"));
 
     // Get lists of the actions' associated widgets.
@@ -242,8 +246,8 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow()
     searchEngineMenuActionPointer = searchEngineMenuPointer->menuAction();
 
     // Get handles for the toolbars.
-    navigationToolBarPointer = toolBar(QStringLiteral("navigation_toolbar"));
-    urlToolBarPointer = toolBar(QStringLiteral("url_toolbar"));
+    navigationToolBarPointer = toolBar(QLatin1String("navigation_toolbar"));
+    urlToolBarPointer = toolBar(QLatin1String("url_toolbar"));
 
     // Create the line edits.
     urlLineEditPointer = new KLineEdit();
@@ -266,7 +270,7 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow()
     findTextLineEditPointer->setMinimumWidth(200);
     findTextLineEditPointer->setMaximumWidth(350);
 
-    // Set the placehold text.
+    // Set the place holder text.
     urlLineEditPointer->setPlaceholderText(i18nc("The URL line edit placeholder text", "URL or Search Terms"));
     findTextLineEditPointer->setPlaceholderText(i18nc("The find line edit placeholder text", "Find Text"));
 
@@ -283,12 +287,15 @@ BrowserWindow::BrowserWindow(bool firstWindow) : KXmlGuiWindow()
     findTextLabelPointer = new QLabel();
 
     // Set the default label text.
-    findTextLabelPointer->setText(QStringLiteral("  ") + i18nc("Default find results.", "0/0") + QStringLiteral("  "));
+    findTextLabelPointer->setText(QLatin1String("  ") + i18nc("Default find results.", "0/0") + QLatin1String("  "));
 
     // Insert the widgets into the toolbars.
     urlToolBarPointer->insertWidget(javaScriptActionPointer, urlLineEditPointer);
-    urlToolBarPointer->insertWidget(findNextActionPointer, findTextLineEditPointer);
-    urlToolBarPointer->insertWidget(findNextActionPointer, findTextLabelPointer);
+    findTextLineEditActionPointer = urlToolBarPointer->insertWidget(findNextActionPointer, findTextLineEditPointer);
+    findTextLabelActionPointer = urlToolBarPointer->insertWidget(findNextActionPointer, findTextLabelPointer);
+
+    // Initially hide the find text actions.
+    hideFindTextActions();
 
     // Load a new URL from the URL line edit.
     connect(urlLineEditPointer, SIGNAL(returnKeyPressed(const QString)), this, SLOT(loadUrlFromLineEdit(const QString)));
@@ -421,7 +428,7 @@ void BrowserWindow::clearUrlLineEditFocus() const
 
 void BrowserWindow::escape() const
 {
-    // Process the excape according to the status of the browser.
+    // Process the escape according to the status of the browser.
     if (fullScreenActionPointer->isChecked())  // Full screen browsing is enabled.
     {
         // Exit full screen browsing.
@@ -463,15 +470,6 @@ void BrowserWindow::findPrevious() const
         tabWidgetPointer->findPrevious(findString);
 }
 
-void BrowserWindow::focusFindLineEdit() const
-{
-    // Set the focus on the find line edit.
-    findTextLineEditPointer->setFocus();
-
-    // Select all the text in the find line edit.
-    findTextLineEditPointer->selectAll();
-}
-
 void BrowserWindow::forward() const
 {
     // Remove the focus from the URL line edit.
@@ -534,6 +532,17 @@ void BrowserWindow::getZoomFactorFromUser()
     }
 }
 
+void BrowserWindow::hideFindTextActions() const
+{
+    // Hide the find text actions.
+    findTextLineEditActionPointer->setVisible(false);
+    findTextLabelActionPointer->setVisible(false);
+    findNextActionPointer->setVisible(false);
+    findPreviousActionPointer->setVisible(false);
+    findCaseSensitiveActionPointer->setVisible(false);
+    hideFindTextActionPointer->setVisible(false);
+}
+
 void BrowserWindow::home() const
 {
     // Remove the focus from the URL line edit.
@@ -618,6 +627,23 @@ void BrowserWindow::showDomainSettingsDialog() const
     connect(domainSettingsDialogPointer, SIGNAL(domainSettingsUpdated()), tabWidgetPointer, SLOT(applyDomainSettingsAndReload()));
 }
 
+void BrowserWindow::showFindTextActions() const
+{
+    // Show the find text actions.
+    findTextLineEditActionPointer->setVisible(true);
+    findTextLabelActionPointer->setVisible(true);
+    findNextActionPointer->setVisible(true);
+    findPreviousActionPointer->setVisible(true);
+    findCaseSensitiveActionPointer->setVisible(true);
+    hideFindTextActionPointer->setVisible(true);
+
+    // Set the focus on the find line edit.
+    findTextLineEditPointer->setFocus();
+
+    // Select all the text in the find line edit.
+    findTextLineEditPointer->selectAll();
+}
+
 void BrowserWindow::showProgressBar(const int &progress) const
 {
     // Set the progress bar value.
index 4c043d2e8f4717b13e4dba0193ba8e7225d3064c..1c22d1df2e28edd7b0694b3ef74fe384e9e07bea 100644 (file)
@@ -57,16 +57,17 @@ private Q_SLOTS:
     void fileNew() const;
     void findNext() const;
     void findPrevious() const;
-    void focusFindLineEdit() const;
     void forward() const;
     void fullScreenRequested(const bool toggleOn);
     void getZoomFactorFromUser();
+    void hideFindTextActions() const;
     void home() const;
     void loadUrlFromLineEdit(const QString &url) const;
     void refresh() const;
     void showCookiesDialog();
     void showDownloadLocationBrowseDialog() const;
     void showDomainSettingsDialog() const;
+    void showFindTextActions() const;
     void showProgressBar(const int &progress) const;
     void showSettingsDialog();
     void toggleDomStorage() const;
@@ -100,9 +101,14 @@ private:
     QAction *domStorageActionPointer;
     QComboBox *downloadLocationComboBoxPointer;
     QAction *findCaseSensitiveActionPointer;
+    QAction *findNextActionPointer;
+    QAction *findPreviousActionPointer;
+    QAction *findTextLabelActionPointer;
     QLabel *findTextLabelPointer;
+    QAction *findTextLineEditActionPointer;
     KLineEdit *findTextLineEditPointer;
     KToggleFullScreenAction *fullScreenActionPointer;
+    QAction *hideFindTextActionPointer;
     QAction *javaScriptActionPointer;
     bool javaScriptEnabled;
     QAction *localStorageActionPointer;