]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/commitdiff
Implement opening web pages in other browsers. https://redmine.stoutner.com/issues...
authorSoren Stoutner <soren@stoutner.com>
Thu, 29 Aug 2024 19:33:06 +0000 (12:33 -0700)
committerSoren Stoutner <soren@stoutner.com>
Thu, 29 Aug 2024 19:33:06 +0000 (12:33 -0700)
doc/index.docbook
src/ui.rcs/browserwindowui.rc
src/windows/BrowserWindow.cpp
src/windows/BrowserWindow.h

index 7282b3956adf001f764756bbb3b562b0cb7b40a3..3a9905e8de34301a7e19ae2fb0b1929d57060d6a 100644 (file)
     <chapter id="changelog">
         <title>Changelog</title>
 
-        <!-- Verstion 0.6.1. -->
+        <!-- Version 0.6.1. -->
         <sect1 id="version_0.6.1">
             <title><ulink url="https://www.stoutner.com/privacy-browser-pc-0-6-1/">0.6.1</ulink> -
-                21 August 2024</title>
+                <ulink url="https://gitweb.stoutner.com/?p=PrivacyBrowserPC.git;a=commitdiff;h=8c481c85245b67c1d1d69bc20196be910179bcda;ds=sidebyside">21 August 2024</ulink></title>
 
             <itemizedlist>
                 <listitem><para>Fix the domain settings dialog <ulink url="https://redmine.stoutner.com/issues/1219">not fitting</ulink> on small screens.</para></listitem>
index 0deed074f45e26c59a3960de4fff2d8aa9e680ad..d0c931e3bba1bba174e28027ce206c9d0af031a1 100644 (file)
@@ -36,6 +36,9 @@
             <Action name="new_window" append="new_merge" />
 
             <Action name="save_archive" append="save_merge" />
+
+            <Action name="open_with_firefox" />
+            <Action name="open_with_chromium" />
         </Menu>
 
         <!-- View. -->
index 9177b265f73868a29dfaacd8da051fa2a8db99c6..6dded8a6024c150e1b1eb2ddf649240d1b30814c 100644 (file)
@@ -95,6 +95,8 @@ BrowserWindow::BrowserWindow(bool firstWindow, QString *initialUrlStringPointer)
     QAction *newTabActionPointer = actionCollectionPointer->addAction(QLatin1String("new_tab"));
     QAction *newWindowActionPointer = actionCollectionPointer->addAction(QLatin1String("new_window"));
     QAction *saveArchiveActionPointer = actionCollectionPointer->addAction(QLatin1String("save_archive"));
+    QAction *openWithFirefoxActionPointer = actionCollectionPointer->addAction(QLatin1String("open_with_firefox"));
+    QAction *openWithChromiumActionPointer = actionCollectionPointer->addAction(QLatin1String("open_with_chromium"));
     zoomDefaultActionPointer = actionCollectionPointer->addAction(QLatin1String("zoom_default"));
     QAction *reloadAndBypassCacheActionPointer = actionCollectionPointer->addAction(QLatin1String("reload_and_bypass_cache"));
     stopActionPointer = actionCollectionPointer->addAction(QLatin1String("stop"));
@@ -194,6 +196,8 @@ BrowserWindow::BrowserWindow(bool firstWindow, QString *initialUrlStringPointer)
     newTabActionPointer->setText(i18nc("New tab action", "New Tab"));
     newWindowActionPointer->setText(i18nc("New window action", "New Window"));
     saveArchiveActionPointer->setText(i18nc("Save archive action", "Save Archive"));
+    openWithFirefoxActionPointer->setText(i18nc("Open with Firefox action", "Open With Firefox"));
+    openWithChromiumActionPointer->setText(i18nc("Open with Chromium action", "Open With Chromium"));
     zoomDefaultActionPointer->setText(i18nc("Zoom default action", "Zoom Default"));
     reloadAndBypassCacheActionPointer->setText(i18nc("Reload and bypass cache action", "Reload and Bypass Cache"));
     stopActionPointer->setText(i18nc("Stop action", "Stop"));
@@ -239,6 +243,8 @@ BrowserWindow::BrowserWindow(bool firstWindow, QString *initialUrlStringPointer)
     newTabActionPointer->setIcon(QIcon::fromTheme(QLatin1String("tab-new")));
     newWindowActionPointer->setIcon(QIcon::fromTheme(QLatin1String("window-new")));
     saveArchiveActionPointer->setIcon(QIcon::fromTheme(QLatin1String("document-save")));
+    openWithFirefoxActionPointer->setIcon(QIcon::fromTheme(QLatin1String("firefox-esr")));
+    openWithChromiumActionPointer->setIcon(QIcon::fromTheme(QLatin1String("chromium")));
     zoomDefaultActionPointer->setIcon(QIcon::fromTheme(QLatin1String("zoom-fit-best")));
     reloadAndBypassCacheActionPointer->setIcon(QIcon::fromTheme(QLatin1String("view-refresh")));
     stopActionPointer->setIcon(QIcon::fromTheme(QLatin1String("process-stop")));
@@ -284,6 +290,8 @@ BrowserWindow::BrowserWindow(bool firstWindow, QString *initialUrlStringPointer)
     QKeySequence ctrlTKeySequence = QKeySequence(i18nc("The open new tab key sequence.", "Ctrl+T"));
     QKeySequence ctrlNKeySequence = QKeySequence(i18nc("The open new window key sequence.", "Ctrl+N"));
     QKeySequence ctrlAKeySequence = QKeySequence(i18nc("The save archive key sequence.", "Ctrl+A"));
+    QKeySequence altFKeySequence = QKeySequence(i18nc("The open with Firefox key sequence.", "Alt+F"));
+    QKeySequence altCKeySequence = QKeySequence(i18nc("The open with Chromium key sequence.", "Alt+C"));
     QKeySequence ctrl0KeySequence = QKeySequence(i18nc("The zoom default key sequence.", "Ctrl+0"));
     QKeySequence ctrlF5KeySequence = QKeySequence(i18nc("The reload and bypass cache key sequence.", "Ctrl+F5"));
     QKeySequence ctrlShiftXKeySequence = QKeySequence(i18nc("The stop key sequence.", "Ctrl+Shift+X"));
@@ -323,6 +331,8 @@ BrowserWindow::BrowserWindow(bool firstWindow, QString *initialUrlStringPointer)
     actionCollectionPointer->setDefaultShortcut(newTabActionPointer, ctrlTKeySequence);
     actionCollectionPointer->setDefaultShortcut(newWindowActionPointer, ctrlNKeySequence);
     actionCollectionPointer->setDefaultShortcut(saveArchiveActionPointer, ctrlAKeySequence);
+    actionCollectionPointer->setDefaultShortcut(openWithFirefoxActionPointer, altFKeySequence);
+    actionCollectionPointer->setDefaultShortcut(openWithChromiumActionPointer, altCKeySequence);
     actionCollectionPointer->setDefaultShortcut(zoomDefaultActionPointer, ctrl0KeySequence);
     actionCollectionPointer->setDefaultShortcut(reloadAndBypassCacheActionPointer, ctrlF5KeySequence);
     actionCollectionPointer->setDefaultShortcut(stopActionPointer, ctrlShiftXKeySequence);
@@ -362,6 +372,8 @@ BrowserWindow::BrowserWindow(bool firstWindow, QString *initialUrlStringPointer)
     connect(newTabActionPointer, SIGNAL(triggered()), tabWidgetPointer, SLOT(addTab()));
     connect(newWindowActionPointer, SIGNAL(triggered()), this, SLOT(newWindow()));
     connect(saveArchiveActionPointer, SIGNAL(triggered()), tabWidgetPointer, SLOT(saveArchive()));
+    connect(openWithFirefoxActionPointer, SIGNAL(triggered()), this, SLOT(openWithFirefox()));
+    connect(openWithChromiumActionPointer, SIGNAL(triggered()), this, SLOT(openWithChromium()));
     connect(zoomDefaultActionPointer, SIGNAL(triggered()), this, SLOT(zoomDefault()));
     connect(reloadAndBypassCacheActionPointer, SIGNAL(triggered()), this, SLOT(reloadAndBypassCache()));
     connect(stopActionPointer, SIGNAL(triggered()), tabWidgetPointer, SLOT(stop()));
@@ -428,6 +440,14 @@ BrowserWindow::BrowserWindow(bool firstWindow, QString *initialUrlStringPointer)
     // Setup the GUI based on the browserwindowui.rc file.
     setupGUI(StandardWindowOption::Default, ("browserwindowui.rc"));
 
+    // Check if other browsers are installed.
+    int firefoxExitCodeInt = system("firefox -v > /dev/null 2> /dev/null");
+    int chromiumExitCodeInt = system("chromium --version > /dev/null 2> /dev/null");
+
+    // Set the open with other browser actions visibility.
+    openWithFirefoxActionPointer->setVisible(firefoxExitCodeInt == 0);
+    openWithChromiumActionPointer->setVisible(chromiumExitCodeInt == 0);
+
     // Get lists of the actions' associated widgets.
     QList<QWidget*> userAgentAssociatedWidgetsPointerList = userAgentPrivacyBrowserActionPointer->associatedWidgets();
     QList<QWidget*> searchEngineAssociatedWidgetsPointerList = searchEngineMojeekActionPointer->associatedWidgets();
@@ -1134,6 +1154,18 @@ void BrowserWindow::newWindow() const
     browserWindowPointer->show();
 }
 
+void BrowserWindow::openWithChromium() const
+{
+    // Open the current URL in Chromium
+    QProcess::startDetached("chromium", QStringList(urlLineEditPointer->text()));
+}
+
+void BrowserWindow::openWithFirefox() const
+{
+    // Open the current URL in Firefox.
+    QProcess::startDetached("firefox-esr", QStringList(urlLineEditPointer->text()));
+}
+
 void BrowserWindow::populateBookmarksInAllWindows() const
 {
     // Get a list of all the registered service names.
index 8ee94b811f5fd8c7d33053a6230f4bd59e338e4d..7564567d52b533e5c3b5080187982058d7f87cbb 100644 (file)
@@ -73,6 +73,8 @@ private Q_SLOTS:
     void incrementZoom();
     void loadUrlFromLineEdit(const QString &url) const;
     void newWindow() const;
+    void openWithChromium() const;
+    void openWithFirefox() const;
     void populateBookmarksInAllWindows() const;
     void refresh() const;
     void reloadAndBypassCache() const;