From: Soren Stoutner Date: Thu, 3 Feb 2022 23:09:34 +0000 (-0700) Subject: Enable setting as the default browser. X-Git-Tag: v0.1~64 X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserPC.git;a=commitdiff_plain;h=a65c9f31cc84f245da08642cefefe7a17fa941ce Enable setting as the default browser. --- diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index c36a84b..425f0e7 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -46,15 +46,18 @@ ki18n_wrap_ui(privacy-browser # Link the following libraries. target_link_libraries(privacy-browser - KF5::ConfigWidgets + Qt5::Core + Qt5::Gui + Qt5::Widgets + Qt5::WebEngineWidgets KF5::Completion + KF5::ConfigWidgets KF5::CoreAddons KF5::Crash KF5::DBusAddons + KF5::DocTools KF5::I18n KF5::XmlGui - Qt5::Widgets - Qt5::WebEngineWidgets ) # Install Privacy Browser using the default KDE arguments. diff --git a/src/com.stoutner.privacybrowser.desktop b/src/com.stoutner.privacybrowser.desktop index a0e17f9..a7ca9d6 100644 --- a/src/com.stoutner.privacybrowser.desktop +++ b/src/com.stoutner.privacybrowser.desktop @@ -32,13 +32,14 @@ Categories=Network;WebBrowser; # Set the icon. Icon=privacy-browser.svg -# Set the executable. -Exec=privacy-browser +# Set the executable with the optional URL argument. +Exec=privacy-browser %u -# TODO. Check if this is needed. +# Specify the WM class, which groups windows of the same application together. StartupWMClass=privacy-browser # TODO. Set the document path. X-DocPath=privacybrowser/index.html -# TODO. Add MIME types. +# Enumerate the supported MIME types. +MimeType=text/html;text/xml;application/xhtml+xml;application/xml;x-scheme-handler/http;x-scheme-handler/https; diff --git a/src/mainview.cpp b/src/mainview.cpp index 3ebee4c..416014b 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -22,14 +22,7 @@ #include "mainview.h" #include "mouseeventfilter.h" #include "settings.h" - -// KDE Framework headers. -#include - -// Qt headers. -#include -#include -#include +#include "ui_mainview.h" MainView::MainView(QWidget *parent) : QWidget(parent) { @@ -90,8 +83,20 @@ MainView::MainView(QWidget *parent) : QWidget(parent) // Set the focus on the WebEngine view. webEngineViewPointer->setFocus(); - // Load the homepage. - goHome(); + // Get the arguments. + QStringList argumentsStringList = qApp->arguments(); + + // Check to see if the arguments lists contains a URL. + if (argumentsStringList.size() > 1) + { + // Load the URL from the arguments list. + webEngineViewPointer->setUrl(QUrl::fromUserInput(argumentsStringList.at(1))); + } + else + { + // Load the homepage. + goHome(); + } } void MainView::applyApplicationSettings() @@ -164,7 +169,7 @@ void MainView::updateInterface() if (!urlLineEditPointer->hasFocus()) { // Update the URL line edit. - urlLineEditPointer->setUrl(webEngineViewPointer->url().toString()); + urlLineEditPointer->setText(webEngineViewPointer->url().toString()); } // Update the status of the forward and back buttons. diff --git a/src/mainview.h b/src/mainview.h index ee82d79..018594e 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -20,8 +20,14 @@ #ifndef MAINVIEW_H #define MAINVIEW_H -// Application headers. -#include "ui_mainview.h" +// Qt framework headers. +#include +#include +#include +#include + +// KDE Framework headers. +#include class MainView : public QWidget { diff --git a/src/mainview.ui b/src/mainview.ui index d00087f..c7afeb8 100644 --- a/src/mainview.ui +++ b/src/mainview.ui @@ -131,10 +131,6 @@ - - - - 24