From 153c5c0d60eaf3185cb4419032fb0fdaeb78907c Mon Sep 17 00:00:00 2001 From: Soren Stoutner Date: Sat, 22 Jan 2022 15:01:34 -0700 Subject: [PATCH] Make Privacy Browser installable. --- po/privacybrowser.pot | 20 +++---- src/CMakeLists.txt | 44 ++++++++------ src/com.stoutner.privacybrowser.appdata.xml | 59 +++++++++++++++++++ src/com.stoutner.privacybrowser.desktop | 44 ++++++++++++++ ...rowser.svg => sc-apps-privacy_browser.svg} | 0 src/main.cpp | 8 +-- ...{privacybrowserpcview.cpp => mainview.cpp} | 13 ++-- src/{privacybrowserpcview.h => mainview.h} | 16 ++--- src/{privacybrowserpcview.ui => mainview.ui} | 4 +- src/mainwindow.cpp | 44 ++++++++------ src/mainwindow.h | 37 +++--------- src/org.example.privacybrowserpc.appdata.xml | 29 --------- src/org.example.privacybrowserpc.desktop | 10 ---- ...vacybrowserpcui.rc => privacybrowserui.rc} | 2 +- src/resources.qrc | 2 +- 15 files changed, 195 insertions(+), 137 deletions(-) create mode 100644 src/com.stoutner.privacybrowser.appdata.xml create mode 100644 src/com.stoutner.privacybrowser.desktop rename src/icons/{privacy_browser.svg => sc-apps-privacy_browser.svg} (100%) rename src/{privacybrowserpcview.cpp => mainview.cpp} (75%) rename src/{privacybrowserpcview.h => mainview.h} (69%) rename src/{privacybrowserpcview.ui => mainview.ui} (98%) delete mode 100644 src/org.example.privacybrowserpc.appdata.xml delete mode 100644 src/org.example.privacybrowserpc.desktop rename src/{privacybrowserpcui.rc => privacybrowserui.rc} (95%) diff --git a/po/privacybrowser.pot b/po/privacybrowser.pot index 18f6b42..3ab6a9b 100644 --- a/po/privacybrowser.pot +++ b/po/privacybrowser.pot @@ -21,7 +21,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2022-01-20 17:18-0700\n" +"POT-Creation-Date: 2022-01-22 14:47-0700\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -30,18 +30,13 @@ msgstr "" "Content-Type: text/plain; charset=UTF-8\n" "Content-Transfer-Encoding: 8bit\n" -#: src/privacybrowserpcview.cpp:44 -#, kde-format -msgid "This project is %1 days old" -msgstr "" - -#: src/mainwindow.cpp:38 +#: src/mainwindow.cpp:46 #, kde-format msgctxt "@action" msgid "Switch Colors" msgstr "" -#: src/mainwindow.cpp:74 +#: src/mainwindow.cpp:80 #, kde-format msgctxt "@title:tab" msgid "General" @@ -72,6 +67,11 @@ msgstr "" msgid "A web browser that respects your privacy." msgstr "" +#: src/mainview.cpp:44 +#, kde-format +msgid "This project is %1 days old" +msgstr "" + #: rc.cpp:3 #, kde-format msgid "Background color:" @@ -154,12 +154,12 @@ msgstr "" #: rc.cpp:45 #, kde-format -msgid "hello, world" +msgid "Main Toolbar" msgstr "" #: rc.cpp:48 #, kde-format -msgid "Main Toolbar" +msgid "hello, world" msgstr "" #: rc.cpp:49 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e251e06..513e8e6 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -17,43 +17,53 @@ # Create the executable and add the resources. -add_executable(privacybrowser resources.qrc) +add_executable(privacy-browser resources.qrc) # List the sources to include in the executable. -target_sources(privacybrowser PRIVATE +target_sources(privacy-browser PRIVATE main.cpp mainwindow.cpp - privacybrowserpcview.cpp + mainview.cpp ) -# Add the Qt logging category. -ecm_qt_declare_logging_category(privacybrowser +# Add the Qt logging category. This will create the `privacybrowserdebug.h` header file. +ecm_qt_declare_logging_category(privacy-browser HEADER privacybrowserdebug.h IDENTIFIER PRIVACYBROWSER CATEGORY_NAME "privacybrowser" ) # Include the KConfig controller file. -kconfig_add_kcfg_files(privacybrowser settings.kcfgc) +kconfig_add_kcfg_files(privacy-browser settings.kcfgc) # Use KDE Frameworks to handle internationalization of the following UI files. -ki18n_wrap_ui(privacybrowser - privacybrowserpcview.ui +ki18n_wrap_ui(privacy-browser + mainview.ui settings.ui ) - -target_link_libraries(privacybrowser +# Link the following libraries. +target_link_libraries(privacy-browser + KF5::ConfigWidgets KF5::CoreAddons + KF5::Crash + KF5::DBusAddons KF5::I18n KF5::XmlGui - KF5::ConfigWidgets - KF5::DBusAddons - KF5::Crash Qt5::Widgets ) -install(TARGETS privacybrowser ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) -install(PROGRAMS com.stoutner.privacybrowser DESTINATION ${KDE_INSTALL_APPDIR}) -install(FILES com.stounter.privacybrowser.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR}) -install(FILES privacybrowserpcui.rc DESTINATION ${KDE_INSTALL_KXMLGUI5DIR}/privacybrowser) # TODO +# Install Privacy Browser using the default KDE arguments. +install(TARGETS privacy-browser ${KDE_INSTALL_TARGETS_DEFAULT_ARGS}) + +# Install Privacy Browser according to the instructions in the desktop file, specifying the permissions. +install(PROGRAMS com.stoutner.privacybrowser.desktop DESTINATION ${KDE_INSTALL_APPDIR} PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ) + +# Install Privacy Browser's metadata file. +install(FILES com.stoutner.privacybrowser.appdata.xml DESTINATION ${KDE_INSTALL_METAINFODIR}) + +# Install Privacy Browser's RC (Runtime Configuration) file. +install(FILES privacybrowserui.rc DESTINATION ${KDE_INSTALL_KXMLGUI5DIR}/privacybrowser) + +# Install Privacy Browser's icon. +ecm_install_icons(ICONS icons/sc-apps-privacy_browser.svg DESTINATION ${KDE_INSTALL_ICONDIR}) diff --git a/src/com.stoutner.privacybrowser.appdata.xml b/src/com.stoutner.privacybrowser.appdata.xml new file mode 100644 index 0000000..49704a9 --- /dev/null +++ b/src/com.stoutner.privacybrowser.appdata.xml @@ -0,0 +1,59 @@ + + + + + + + com.stoutner.privacybrowser + + GFDL-1.3 + + Privacy Browser + + A web browser that respects your privacy. + + + Network + WebBrowser + + + https://www.stoutner.com/privacy-browser-pc/ + https://redmine.stoutner.com/projects/privacy-browser-pc/issues + https://www.stoutner.com/donations/ + https://redmine.stoutner.com/projects/privacy-browser-pc/boards + + com.stoutner.privacybrowser.desktop + + + + + + + + privacy-browser + + + GPL-3.0-or-later + + Soren Stoutner + + + + + https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html#tag-screenshots + + + + soren@stoutner.com + diff --git a/src/com.stoutner.privacybrowser.desktop b/src/com.stoutner.privacybrowser.desktop new file mode 100644 index 0000000..bdb64ed --- /dev/null +++ b/src/com.stoutner.privacybrowser.desktop @@ -0,0 +1,44 @@ +# Copyright © 2022 Soren Stoutner . +# +# This file is part of Privacy Browser PC . +# +# Privacy Browser PC is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# Privacy Browser PC is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# 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 . + +# The specification for the .desktop file can be found at . +[Desktop Entry] +# Set the type. +Type=Application + +# Set the name. +Name=Privacy Browser + +# Set the generic name, which is displayed next to the name in the menu. +GenericName=Web Browser + +# Set the categories. These are used to organize the application in the menu. +Categories=Network;WebBrowser; + +# Set the icon. +Icon=privacy_browser.svg + +# Set the executable. +Exec=privacy-browser + +# TODO. Check if this is needed. +StartupWMClass=privacy-browser + +# TODO. Set the document path. +X-DocPath=privacybrowser/index.html + +# TODO. Add MIME types. diff --git a/src/icons/privacy_browser.svg b/src/icons/sc-apps-privacy_browser.svg similarity index 100% rename from src/icons/privacy_browser.svg rename to src/icons/sc-apps-privacy_browser.svg diff --git a/src/main.cpp b/src/main.cpp index 5605cdf..3416364 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -40,10 +40,10 @@ int main(int argc, char *argv[]) // Initialize KCrash. KCrash::initialize(); - // Instantiate about data. - KAboutData aboutData(QStringLiteral("privacybrowser"), i18n("Privacy Browser"), QStringLiteral("0.1")); + // Instantiate about data, setting the component name, the display name, and the version. + KAboutData aboutData(QStringLiteral("privacy-browser"), i18n("Privacy Browser"), QStringLiteral("0.1")); - // Add the author information. + // Add the author name, job description, email address, and website. aboutData.addAuthor(i18n("Soren Stoutner"),i18n("Principal developer"), QStringLiteral("soren@stoutner.com"), QStringLiteral("https://www.stoutner.com/")); // Populate additional about data info. @@ -59,7 +59,7 @@ int main(int argc, char *argv[]) KAboutData::setApplicationData(aboutData); // Set the window icon. - application.setWindowIcon(QIcon::fromTheme(QStringLiteral("privacybrowser"), QIcon(":/icons/privacy_browser.svg"))); + application.setWindowIcon(QIcon::fromTheme(QStringLiteral("privacy-browser"), QIcon(":/icons/sc-apps-privacy_browser.svg"))); // Create a command line parser. QCommandLineParser commandLineParser; diff --git a/src/privacybrowserpcview.cpp b/src/mainview.cpp similarity index 75% rename from src/privacybrowserpcview.cpp rename to src/mainview.cpp index 8369f99..c437c2c 100644 --- a/src/privacybrowserpcview.cpp +++ b/src/mainview.cpp @@ -5,24 +5,24 @@ */ // application headers -#include "privacybrowserpcview.h" +#include "mainview.h" #include "settings.h" #include "privacybrowserdebug.h" -PrivacyBrowserPCView::PrivacyBrowserPCView(QWidget *parent) +MainView::MainView(QWidget *parent) : QWidget(parent) { m_ui.setupUi(this); handleSettingsChanged(); } -PrivacyBrowserPCView::~PrivacyBrowserPCView() +MainView::~MainView() { } -void PrivacyBrowserPCView::switchColors() +void MainView::switchColors() { // switch the foreground/background colors of the label QColor color = Settings::colorBackground(); @@ -32,9 +32,9 @@ void PrivacyBrowserPCView::switchColors() handleSettingsChanged(); } -void PrivacyBrowserPCView::handleSettingsChanged() +void MainView::handleSettingsChanged() { - qCDebug(PRIVACYBROWSER) << "PrivacyBrowserPCView::handleSettingsChanged()"; + qCDebug(PRIVACYBROWSER) << "MainView::handleSettingsChanged()"; QPalette palette = m_ui.templateLabel->palette(); palette.setColor(QPalette::Window, Settings::colorBackground()); palette.setColor(QPalette::WindowText, Settings::colorForeground()); @@ -43,4 +43,3 @@ void PrivacyBrowserPCView::handleSettingsChanged() // i18n : internationalization m_ui.templateLabel->setText(i18n("This project is %1 days old", Settings::ageInDays())); } - diff --git a/src/privacybrowserpcview.h b/src/mainview.h similarity index 69% rename from src/privacybrowserpcview.h rename to src/mainview.h index f6dd7ba..6b9e6ca 100644 --- a/src/privacybrowserpcview.h +++ b/src/mainview.h @@ -4,10 +4,10 @@ SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL */ -#ifndef PRIVACYBROWSERPCVIEW_H -#define PRIVACYBROWSERPCVIEW_H +#ifndef MAINVIEW_H +#define MAINVIEW_H -#include "ui_privacybrowserpcview.h" +#include "ui_mainview.h" /** @@ -18,19 +18,19 @@ * @author %{AUTHOR} <%{EMAIL}> * @version %{VERSION} */ -class PrivacyBrowserPCView : public QWidget +class MainView : public QWidget { Q_OBJECT public: /** * Default Constructor */ - explicit PrivacyBrowserPCView(QWidget *parent); + explicit MainView(QWidget *parent); /** * Default Destructor */ - ~PrivacyBrowserPCView() override; + ~MainView() override; public Q_SLOTS: void switchColors(); @@ -39,7 +39,7 @@ public Q_SLOTS: private: // this is the name of the root widget inside our Ui file // you can rename it in designer and then change it here - Ui::PrivacyBrowserPCView m_ui; + Ui::MainView m_ui; }; -#endif // PRIVACYBROWSERPCVIEW_H +#endif diff --git a/src/privacybrowserpcview.ui b/src/mainview.ui similarity index 98% rename from src/privacybrowserpcview.ui rename to src/mainview.ui index f20cd07..2f42279 100644 --- a/src/privacybrowserpcview.ui +++ b/src/mainview.ui @@ -1,7 +1,7 @@ - PrivacyBrowserPCView - + MainView + 0 diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index d0c4e1b..9cde452 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -18,8 +18,8 @@ */ // Application headers. +#include "mainview.h" #include "mainwindow.h" -#include "privacybrowserpcview.h" #include "privacybrowserdebug.h" #include "settings.h" @@ -27,32 +27,38 @@ #include #include - MainWindow::MainWindow() : KXmlGuiWindow() { - m_privacybrowserpcView = new PrivacyBrowserPCView(this); - setCentralWidget(m_privacybrowserpcView); + // Instantiate the main view pointer. + mainViewPointer = new MainView(this); - KActionCollection* actionCollection = this->actionCollection(); - m_switchAction = actionCollection->addAction(QStringLiteral("switch_action")); - m_switchAction->setText(i18nc("@action", "Switch Colors")); - m_switchAction->setIcon(QIcon::fromTheme(QStringLiteral("fill-color"))); - connect(m_switchAction, &QAction::triggered, m_privacybrowserpcView, &PrivacyBrowserPCView::switchColors); + // Set the main view as the central widget. + setCentralWidget(mainViewPointer); - KStandardAction::openNew(this, SLOT(fileNew()), actionCollection); - KStandardAction::quit(qApp, SLOT(closeAllWindows()), actionCollection); - KStandardAction::preferences(this, SLOT(settingsConfigure()), actionCollection); + // Get a handle for the action collectoin. + KActionCollection *actionCollectionPointer = this->actionCollection(); - setupGUI(); -} + // Create a switch colorsaction pointer. + QAction *switchColorsActionPointer; -MainWindow::~MainWindow() -{ + // Populate the switch colors action pointer. + switchColorsActionPointer = actionCollectionPointer->addAction(QStringLiteral("switch_action")); + switchColorsActionPointer->setText(i18nc("@action", "Switch Colors")); + switchColorsActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("fill-color"))); + + // Connect the signals to the slots. + connect(switchColorsActionPointer, &QAction::triggered, mainViewPointer, &MainView::switchColors); + + KStandardAction::openNew(this, SLOT(fileNew()), actionCollectionPointer); + KStandardAction::quit(qApp, SLOT(closeAllWindows()), actionCollectionPointer); + KStandardAction::preferences(this, SLOT(settingsConfigure()), actionCollectionPointer); + + setupGUI(); } void MainWindow::fileNew() { - qCDebug(PRIVACYBROWSER) << "PrivacyBrowserPCWindow::fileNew()"; + qCDebug(PRIVACYBROWSER) << "MainWindow::fileNew()"; (new MainWindow)->show(); } @@ -70,9 +76,9 @@ void MainWindow::settingsConfigure() KConfigDialog *dialog = new KConfigDialog(this, QStringLiteral("settings"), Settings::self()); QWidget *generalSettingsPage = new QWidget; - m_settings.setupUi(generalSettingsPage); + settingsWidget.setupUi(generalSettingsPage); dialog->addPage(generalSettingsPage, i18nc("@title:tab", "General"), QStringLiteral("package_setting")); - connect(dialog, &KConfigDialog::settingsChanged, m_privacybrowserpcView, &PrivacyBrowserPCView::handleSettingsChanged); + connect(dialog, &KConfigDialog::settingsChanged, mainViewPointer, &MainView::handleSettingsChanged); dialog->setAttribute(Qt::WA_DeleteOnClose); dialog->show(); } diff --git a/src/mainwindow.h b/src/mainwindow.h index f108c0d..3e48bd4 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -21,24 +21,15 @@ #define MAINWINDOW_H // Application headers. -#include "ui_settings.h" // TODO. Can probably be removed. Does not appear to exist. -#include "PrivacyBrowserPCSettings.h" // TODO. Can probably be removed. Doe snot appear to exist. +#include "settings.h" +#include "ui_settings.h" // KDE Frameworks headers. #include -// TODO. What is this doing here? -class PrivacyBrowserPCView; +class MainView; -/** TODO. Remove. - * This class serves as the main window for privacybrowserpc. It handles the - * menus, toolbars and status bars. - * - * @short Main window class - * @author %{AUTHOR} <%{EMAIL}> - * @version %{VERSION} - */ -class MainWindow : public KXmlGuiWindow // TODO. Checkout documentation. +class MainWindow : public KXmlGuiWindow { // Include the Q_OBJECT macro. Q_OBJECT @@ -47,26 +38,14 @@ public: // The default constructor. MainWindow(); - - // The default destructor. TODO, this could probably be removed. - ~MainWindow() override; - private Q_SLOTS: - /** - * Create a new window - */ + // Define the private slots. void fileNew(); - - /** - * Open the settings dialog - */ void settingsConfigure(); private: - // this is the name of the root widget inside our Ui file - // you can rename it in designer and then change it here - Ui::Settings m_settings; - QAction *m_switchAction; - PrivacyBrowserPCView *m_privacybrowserpcView; + // Define the private variables. + Ui::Settings settingsWidget; + MainView *mainViewPointer; }; #endif diff --git a/src/org.example.privacybrowserpc.appdata.xml b/src/org.example.privacybrowserpc.appdata.xml deleted file mode 100644 index e2974dd..0000000 --- a/src/org.example.privacybrowserpc.appdata.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - org.example.privacybrowserpc.desktop - CC0-1.0 - https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html#tag-metadata_license - PrivacyBrowserPC - https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html#tag-summary - -

https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html#tag-description

-
- https://www.example.org - https://bugs.example.org - https://www.example.org/community/donations - - - https://www.freedesktop.org/software/appstream/docs/chap-Metadata.html#tag-screenshots - - - - privacybrowserpc - - KDE - - - - - - -
diff --git a/src/org.example.privacybrowserpc.desktop b/src/org.example.privacybrowserpc.desktop deleted file mode 100644 index c640c80..0000000 --- a/src/org.example.privacybrowserpc.desktop +++ /dev/null @@ -1,10 +0,0 @@ -[Desktop Entry] -Type=Application - -Name=PrivacyBrowserPC -GenericName=A Simple Application written with KDE Frameworks -Icon=privacybrowserpc - -Exec=privacybrowserpc -StartupWMClass=privacybrowserpc -X-DocPath=privacybrowserpc/index.html diff --git a/src/privacybrowserpcui.rc b/src/privacybrowserui.rc similarity index 95% rename from src/privacybrowserpcui.rc rename to src/privacybrowserui.rc index f14edf0..977ea54 100644 --- a/src/privacybrowserpcui.rc +++ b/src/privacybrowserui.rc @@ -1,5 +1,5 @@ - - icons/privacy_browser.svg + icons/sc-apps-privacy_browser.svg licenses/GPLv3+.txt -- 2.45.2