]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/commitdiff
Restore the current URL text when switching tabs. https://redmine.stoutner.com/issue...
authorSoren Stoutner <soren@stoutner.com>
Tue, 22 Oct 2024 17:51:05 +0000 (10:51 -0700)
committerSoren Stoutner <soren@stoutner.com>
Tue, 22 Oct 2024 17:51:05 +0000 (10:51 -0700)
doc/index.docbook
src/helpers/FilterListHelper.h
src/widgets/PrivacyWebEngineView.h
src/widgets/TabWidget.cpp
src/widgets/TabWidget.h
src/windows/BrowserWindow.cpp
src/windows/BrowserWindow.h

index f40ecc3746a4b3f938fe9db88b9fb1efb58dbb5d..95c12aa509c793a32fb1f64586f39adda643210f 100644 (file)
                         </listitem>
                     </varlistentry>
 
+                    <!-- Restore URL text. -->
+                    <varlistentry id="restore-url-text">
+                        <term>
+                            <command>
+                                &Ctrl;+&Shift;+<keycap>R</keycap>
+                            </command>
+                        </term>
+
+                        <listitem>
+                            <para>
+                                Restore the URL text (if it has been edited) to the URL that is currently displayed in the tab.
+                            </para>
+                        </listitem>
+                    </varlistentry>
+
                     <!-- Escape. -->
                     <varlistentry id="escape">
                         <term>
index d6b96adc4558d9c85eb1a19827df6dcdcdc662f0..df7477ddd4a7275952b630894628000630f1b254 100644 (file)
@@ -14,7 +14,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with Privacy Browser PC.  If not, see <http://www.gnu.org/licenses/>.
+ * along with Privacy Browser PC.  If not, see <https://www.gnu.org/licenses/>.
  */
 
 #ifndef FILTER_LIST_HELPER_H
index 60121cd75c803dabad4da018ca0d5bac5dd95663..18f87f445888b60d3fc162b76c8269dc8613f8f7 100644 (file)
@@ -53,6 +53,7 @@ public:
     // The public variables.
     QVector<int> blockedRequestsVector = {0, 0, 0, 0, 0, 0};
     std::list<QNetworkCookie> *cookieListPointer = new std::list<QNetworkCookie>;
+    QString currentUrlText = QLatin1String("");
     double defaultZoomFactor = 1.00;
     QString domainSettingsName = QLatin1String("");
     bool easyListEnabled = true;
index c7de2207b00b40a977c0c236c4d53fe083b72218..173296b767d9a18be463e407fc2d7c283fc9c876 100644 (file)
@@ -14,7 +14,7 @@
  * GNU General Public License for more details.
  *
  * You should have received a copy of the GNU General Public License
- * along with Privacy Browser PC.  If not, see <http://www.gnu.org/licenses/>.
+ * along with Privacy Browser PC.  If not, see <https://www.gnu.org/licenses/>.
  */
 
 // Application headers.
@@ -1141,6 +1141,12 @@ void TabWidget::stop() const
     currentPrivacyWebEngineViewPointer->stop();
 }
 
+void TabWidget::storeCurrentUrlText(const QString &urlText) const
+{
+    // Store the current URL text in the privacy WebEngine view.
+    currentPrivacyWebEngineViewPointer->currentUrlText = urlText;
+}
+
 void TabWidget::toggleDeveloperTools(const bool enabled) const
 {
     // Get a handle for the current developer tools WebEngine.
@@ -1307,6 +1313,9 @@ void TabWidget::updateUiFromWebEngineView(const PrivacyWebEngineView *privacyWeb
 
 void TabWidget::updateUiWithTabSettings()
 {
+    // Clear the URL line edit focus.
+    emit clearUrlLineEditFocus();
+
     // Update the current WebEngine pointers.
     currentPrivacyWebEngineViewPointer = qTabWidgetPointer->currentWidget()->findChild<PrivacyWebEngineView *>();
     currentWebEngineSettingsPointer = currentPrivacyWebEngineViewPointer->settings();
@@ -1315,9 +1324,6 @@ void TabWidget::updateUiWithTabSettings()
     currentWebEngineHistoryPointer = currentWebEnginePagePointer->history();
     currentWebEngineCookieStorePointer = currentWebEngineProfilePointer->cookieStore();
 
-    // Clear the URL line edit focus.
-    emit clearUrlLineEditFocus();
-
     // Get a handle for the development tools WebEngine view.
     DevToolsWebEngineView *devToolsWebEngineViewPointer = qTabWidgetPointer->currentWidget()->findChild<DevToolsWebEngineView *>();
 
@@ -1342,7 +1348,7 @@ void TabWidget::updateUiWithTabSettings()
     // Update the URL.
     emit updateWindowTitle(currentPrivacyWebEngineViewPointer->title());
     emit updateDomainSettingsIndicator(currentPrivacyWebEngineViewPointer->domainSettingsName != QLatin1String(""));
-    emit updateUrlLineEdit(currentPrivacyWebEngineViewPointer->url());
+    emit updateUrlLineEdit(currentPrivacyWebEngineViewPointer->currentUrlText);
 
     // Update the find text.
     emit updateFindText(currentPrivacyWebEngineViewPointer->findString, currentPrivacyWebEngineViewPointer->findCaseSensitive);
index b4453336f8e669fb48d29967a3071e311ed40d30..8963df3e8e5af486800838ef2775adc8b6b990d8 100644 (file)
@@ -130,6 +130,7 @@ public Q_SLOTS:
     void reloadAndBypassCache() const;
     void saveArchive();
     void stop() const;
+    void storeCurrentUrlText(const QString &urlText) const;
     void toggleEasyList() const;
     void toggleEasyPrivacy() const;
     void toggleFanboysAnnoyanceList() const;
index c101c8e9a27f271d78ea9dda6d675579bfda586f..d948104c5cd5593e5a4f740e4f77725249f4bd8b 100644 (file)
@@ -501,6 +501,7 @@ BrowserWindow::BrowserWindow(bool firstWindow, QString *initialUrlStringPointer)
     bookmarkedActionPointer = urlLineEditPointer->addAction(QIcon::fromTheme(QLatin1String("non-starred-symbolic")), QLineEdit::LeadingPosition);
     QAction *addOrEditDomainSettingsActionPointer = urlLineEditPointer->addAction(QIcon::fromTheme(QLatin1String("settings-configure"), QIcon::fromTheme(QLatin1String("preferences-desktop"))),
                                                                                   QLineEdit::TrailingPosition);
+    restoreUrlTextActionPointer = urlLineEditPointer->addAction(QIcon::fromTheme(QLatin1String("edit-undo")), QLineEdit::TrailingPosition);
 
     // Set the bookmarked action pointer to be checkable.
     bookmarkedActionPointer->setCheckable(true);
@@ -508,6 +509,7 @@ BrowserWindow::BrowserWindow(bool firstWindow, QString *initialUrlStringPointer)
     // Connect the URL line edit actions.
     connect(bookmarkedActionPointer, SIGNAL(triggered()), this, SLOT(toggleBookmark()));
     connect(addOrEditDomainSettingsActionPointer, SIGNAL(triggered()), this, SLOT(addOrEditDomainSettings()));
+    connect(restoreUrlTextActionPointer, SIGNAL(triggered()), this, SLOT(restoreUrlText()));
 
     // Create a find text label pointer.
     findTextLabelPointer = new QLabel();
@@ -544,6 +546,9 @@ BrowserWindow::BrowserWindow(bool firstWindow, QString *initialUrlStringPointer)
     // Update the window title.
     connect(tabWidgetPointer, SIGNAL(updateWindowTitle(const QString)), this, SLOT(updateWindowTitle(const QString)));
 
+    // Store the URL line edit when it changes.
+    connect(urlLineEditPointer, SIGNAL(textChanged(const QString &)), this, SLOT(processUrlTextChanges(const QString &)));
+
     // Get a handle for the status bar.
     QStatusBar *statusBarPointer = statusBar();
 
@@ -603,10 +608,12 @@ BrowserWindow::BrowserWindow(bool firstWindow, QString *initialUrlStringPointer)
 
     // Create keyboard shortcuts.
     QShortcut *f11ShortcutPointer = new QShortcut(QKeySequence(i18nc("The toggle full screen shortcut.", "F11")), this);
+    QShortcut *ctrlShiftRShortcut = new QShortcut(QKeySequence(i18nc("The restore URL text key sequence.", "Ctrl+Shift+R")), this);
     QShortcut *escapeShortcutPointer = new QShortcut(QKeySequence::Cancel, this);
 
     // Connect the keyboard shortcuts.
     connect(f11ShortcutPointer, SIGNAL(activated()), fullScreenActionPointer, SLOT(trigger()));
+    connect(ctrlShiftRShortcut, SIGNAL(activated()), restoreUrlTextActionPointer, SLOT(trigger()));
     connect(escapeShortcutPointer, SIGNAL(activated()), this, SLOT(escape()));
 
     // Get a handle for the Bookmarks menu.
@@ -1406,6 +1413,15 @@ void BrowserWindow::populateBookmarksToolBarSubfolders(const double folderId, QM
     }
 }
 
+void BrowserWindow::processUrlTextChanges(const QString &newUrlText) const
+{
+    // Update the visibility of the restore URL text action pointer.
+    restoreUrlTextActionPointer->setVisible(newUrlText != tabWidgetPointer->getCurrentTabUrl());
+
+    // Store the new URL text in the WebEngine View.
+    tabWidgetPointer->storeCurrentUrlText(newUrlText);
+}
+
 void BrowserWindow::refresh() const
 {
     // Remove the focus from the URL line edit.
@@ -1424,6 +1440,12 @@ void BrowserWindow::reloadAndBypassCache() const
     tabWidgetPointer->refresh();
 }
 
+void BrowserWindow::restoreUrlText() const
+{
+    // Restore the URL text to the current URL.
+    urlLineEditPointer->setText(tabWidgetPointer->getCurrentTabUrl());
+}
+
 void BrowserWindow::showBookmarkContextMenu(const QPoint &point)
 {
     // Get the bookmark action.
index 7564567d52b533e5c3b5080187982058d7f87cbb..a41226c6e8fc555e19261819396223a14d80687c 100644 (file)
@@ -76,8 +76,10 @@ private Q_SLOTS:
     void openWithChromium() const;
     void openWithFirefox() const;
     void populateBookmarksInAllWindows() const;
+    void processUrlTextChanges(const QString &newUrlText) const;
     void refresh() const;
     void reloadAndBypassCache() const;
+    void restoreUrlText() const;
     void showBookmarkContextMenu(const QPoint &point);
     void showCookiesDialog();
     void showDomainSettingsDialog();
@@ -160,6 +162,7 @@ private:
     QProgressBar *progressBarPointer;
     QAction *refreshActionPointer;
     QAction *requestsActionPointer;
+    QAction *restoreUrlTextActionPointer;
     QAction *searchEngineMenuActionPointer;
     QAction *searchEngineMojeekActionPointer;
     QAction *searchEngineMonoclesActionPointer;