#include "helpers/FilterListHelper.h"
// List the global variables, proceeded by `extern`.
+extern bool globalChromiumInstalled;
extern FilterListHelper *globalFilterListHelperPointer;
+extern bool globalFirefoxInstalled;
#endif
// Set the window title.
setWindowTitle(i18nc("The requests dialog window title", "Requests"));
- // Set the window modality.
- setWindowModality(Qt::WindowModality::ApplicationModal);
-
// Instantiate the requests dialog UI.
Ui::RequestsDialog requestsDialogUi;
QStringList enabledSpellCheckLanguagesList = Settings::spellCheckLanguages();
// Add each dictionary to the spell check list widget.
- foreach(QString dictionaryString, dictionariesStringList)
+ foreach (QString dictionaryString, dictionariesStringList)
{
// Create a new list widget item pointer.
QListWidgetItem *listWidgetItemPointer = new QListWidgetItem();
#include <QFile>
// Declare the global variables.
+bool globalChromiumInstalled;
FilterListHelper *globalFilterListHelperPointer;
+bool globalFirefoxInstalled;
int main(int argc, char *argv[])
{
CookiesDatabase::addDatabase();
DomainsDatabase::addDatabase();
- // Populate the filter lists.
+ // Populate the global filter list helper.
globalFilterListHelperPointer = new FilterListHelper;
+ // Check if other browsers are installed and store the result in the global variables
+ globalChromiumInstalled = (system("chromium --version > /dev/null 2> /dev/null") == 0);
+ globalFirefoxInstalled = (system("firefox -v > /dev/null 2> /dev/null") == 0);
+
// Create the main window.
BrowserWindow *browserWindowPointer = new BrowserWindow();
<class>RequestsDialog</class>
<widget class="QWidget">
+ <property name="windowModality">
+ <enum>Qt::ApplicationModal</enum>
+ </property>
+
<property name="geometry">
<rect>
<x>0</x>
*/
// Application headers.
+#include "GlobalVariables.h"
#include "PrivacyWebEngineView.h"
#include "PrivacyWebEnginePage.h"
#include "Settings.h"
// Handle HTTP authentication requests.
connect(privacyWebEnginePagePointer, SIGNAL(authenticationRequired(const QUrl&, QAuthenticator*)), this, SLOT(handleAuthenticationRequest(const QUrl&, QAuthenticator*)));
+
+ // Store the link URL whenever a link is hovered.
+ connect(privacyWebEnginePagePointer, SIGNAL(linkHovered(const QString)), this, SLOT(saveHoveredLink(const QString)));
}
void PrivacyWebEngineView::addCookieToList(const QNetworkCookie &cookie) const
// Add the open link in new background tab action if the context menu already contains the open link in new window action.
if (contextMenuActionsList.contains(webEnginePagePointer->action(QWebEnginePage::OpenLinkInNewWindow)))
{
- // Move the open in new tab action to the top of the list.
+ // Move the open in new tab action above the back action.
contextMenu->insertAction(webEnginePagePointer->action(QWebEnginePage::Back), webEnginePagePointer->action(QWebEnginePage::OpenLinkInNewTab));
- // Add the open link in background tab action below the open in new tab action.
+ // Add the open link in background tab action above the back action.
contextMenu->insertAction(webEnginePagePointer->action(QWebEnginePage::Back), webEnginePagePointer->action(QWebEnginePage::OpenLinkInNewBackgroundTab));
- // Move the open in new window action below the open in background tab action.
+ // Move the open in new window action above the back action.
contextMenu->insertAction(webEnginePagePointer->action(QWebEnginePage::Back), webEnginePagePointer->action(QWebEnginePage::OpenLinkInNewWindow));
- // Add a separator below the open in new window action.
+ // Add a separator above the back action.
contextMenu->insertSeparator(webEnginePagePointer->action(QWebEnginePage::Back));
+
+ if (globalFirefoxInstalled || globalChromiumInstalled)
+ {
+ // Add the open with Firefox action if Firefox is installed.
+ if (globalFirefoxInstalled)
+ {
+ // Create an open with Firefox action.
+ QAction *openWithFirefoxActionPointer = new QAction(QIcon::fromTheme(QLatin1String("firefox-esr")), i18nc("Open with Firefox context menu action", "Open with Firefox"), contextMenu);
+
+ // Add the open with Firefox action above the back action.
+ contextMenu->insertAction(webEnginePagePointer->action(QWebEnginePage::Back), openWithFirefoxActionPointer);
+
+ // Connect the action.
+ connect(openWithFirefoxActionPointer, SIGNAL(triggered()), this, SLOT(openWithFirefox()));
+ }
+
+ // Add the open with Chromium action if Chromium is installed.
+ if (globalChromiumInstalled)
+ {
+ // Create an open with Chromium action.
+ QAction *openWithChromiumActionPointer = new QAction(QIcon::fromTheme(QLatin1String("chromium")), i18nc("Open with Chromium context menu action", "Open with Chromium"), contextMenu);
+
+ // Add the open with Chromium action above the back action.
+ contextMenu->insertAction(webEnginePagePointer->action(QWebEnginePage::Back), openWithChromiumActionPointer);
+
+ // Connect the action.
+ connect(openWithChromiumActionPointer, SIGNAL(triggered()), this, SLOT(openWithChromium()));
+ }
+
+
+ // Add a separator above the back action.
+ contextMenu->insertSeparator(webEnginePagePointer->action(QWebEnginePage::Back));
+ }
}
// Display the menu using the location in the context menu event.
}
}
+void PrivacyWebEngineView::openWithChromium() const
+{
+ // Open the current URL in Chromium
+ QProcess::startDetached("chromium", QStringList(hoveredLinkString));
+}
+
+void PrivacyWebEngineView::openWithFirefox() const
+{
+ // Open the current URL in Firefox.
+ QProcess::startDetached("firefox-esr", QStringList(hoveredLinkString));
+}
+
void PrivacyWebEngineView::removeCookieFromList(const QNetworkCookie &cookie) const
{
//qDebug() << "Remove cookie: " << cookie.toRawForm();
emit numberOfCookiesChanged(cookieListPointer->size());
}
+void PrivacyWebEngineView::saveHoveredLink(const QString &hoveredLink)
+{
+ // Save the hovered link.
+ hoveredLinkString = hoveredLink;
+}
+
void PrivacyWebEngineView::storeRequest(RequestStruct *requestStructPointer)
{
// Store the request struct in the list.
void clearRequestsList();
void displayHttpPingDialog(const QString &httpPingUrl) const;
void handleAuthenticationRequest(const QUrl &requestUrl, QAuthenticator *authenticatorPointer);
+ void openWithChromium() const;
+ void openWithFirefox() const;
+ void saveHoveredLink(const QString &hoveredLink);
void storeRequest(RequestStruct *requestStructPointer);
private:
// The private variables.
+ QString hoveredLinkString;
KLineEdit *passwordLineEditPointer;
KLineEdit *usernameLineEditPointer;
QWebEngineProfile *webEngineProfilePointer;
// Application headers.
#include "BrowserWindow.h"
+#include "GlobalVariables.h"
#include "Settings.h"
#include "databases/BookmarksDatabase.h"
#include "databases/DomainsDatabase.h"
actionCollectionPointer->setDefaultShortcut(domainSettingsActionPointer, ctrlShiftDKeySequence);
actionCollectionPointer->setDefaultShortcut(cookiesActionPointer, ctrlSemicolonKeySequence);
- // Execute the actions.
+ // Connect the actions.
connect(newTabActionPointer, SIGNAL(triggered()), tabWidgetPointer, SLOT(addTab()));
connect(newWindowActionPointer, SIGNAL(triggered()), this, SLOT(newWindow()));
connect(saveArchiveActionPointer, SIGNAL(triggered()), tabWidgetPointer, SLOT(saveArchive()));
// 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);
+ openWithFirefoxActionPointer->setVisible(globalFirefoxInstalled);
+ openWithChromiumActionPointer->setVisible(globalChromiumInstalled);
// Get lists of the actions' associated widgets.
QList<QWidget*> userAgentAssociatedWidgetsPointerList = userAgentPrivacyBrowserActionPointer->associatedWidgets();