From: Soren Stoutner Date: Thu, 27 Jan 2022 22:19:24 +0000 (-0700) Subject: Add a web engine view. X-Git-Tag: v0.1~73 X-Git-Url: https://gitweb.stoutner.com/?a=commitdiff_plain;h=255215b082091aaadd5ef24cfc0880cd81e42272;p=PrivacyBrowserPC.git Add a web engine view. --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 29c01f6..b32fd18 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -43,7 +43,12 @@ include(ECMQtDeclareLoggingCategory) include(FeatureSummary) # Load the Qt components. -find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS Core Gui Widgets) +find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED COMPONENTS + Core + Gui + WebEngineWidgets + Widgets +) # Load the KDE Frameworks components. find_package(KF5 ${KDE_FRAMEWORKS_MIN_VERSION} REQUIRED COMPONENTS diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 513e8e6..811cb80 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -26,9 +26,9 @@ target_sources(privacy-browser PRIVATE mainview.cpp ) -# Add the Qt logging category. This will create the `privacybrowserdebug.h` header file. +# Add the Qt logging category. This will create the `debug.h` header file. ecm_qt_declare_logging_category(privacy-browser - HEADER privacybrowserdebug.h + HEADER debug.h IDENTIFIER PRIVACYBROWSER CATEGORY_NAME "privacybrowser" ) @@ -51,6 +51,7 @@ target_link_libraries(privacy-browser KF5::I18n KF5::XmlGui Qt5::Widgets + Qt5::WebEngineWidgets ) # Install Privacy Browser using the default KDE arguments. @@ -66,4 +67,4 @@ install(FILES com.stoutner.privacybrowser.appdata.xml DESTINATION ${KDE_INSTALL_ 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}) +ecm_install_icons(ICONS icons/sc-apps-privacy-browser.svg DESTINATION ${KDE_INSTALL_ICONDIR}) diff --git a/src/icons/sc-apps-privacy_browser.svg b/src/icons/sc-apps-privacy_browser.svg deleted file mode 100644 index 428d507..0000000 --- a/src/icons/sc-apps-privacy_browser.svg +++ /dev/null @@ -1,47 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/src/main.cpp b/src/main.cpp index 3416364..6bf5e74 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -23,9 +23,11 @@ // KDE Frameworks headers. #include #include +#include #include // Qt headers. +#include #include #include @@ -41,7 +43,7 @@ int main(int argc, char *argv[]) KCrash::initialize(); // Instantiate about data, setting the component name, the display name, and the version. - KAboutData aboutData(QStringLiteral("privacy-browser"), i18n("Privacy Browser"), QStringLiteral("0.1")); + KAboutData aboutData(QStringLiteral("privacybrowser"), i18n("Privacy Browser"), QStringLiteral("0.1")); // 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/")); @@ -59,7 +61,7 @@ int main(int argc, char *argv[]) KAboutData::setApplicationData(aboutData); // Set the window icon. - application.setWindowIcon(QIcon::fromTheme(QStringLiteral("privacy-browser"), QIcon(":/icons/sc-apps-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/mainview.cpp b/src/mainview.cpp index c437c2c..844f930 100644 --- a/src/mainview.cpp +++ b/src/mainview.cpp @@ -1,45 +1,37 @@ /* - SPDX-FileCopyrightText: %{CURRENT_YEAR} %{AUTHOR} <%{EMAIL}> - - SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL -*/ - -// application headers + * 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 . + */ + +// Application headers #include "mainview.h" - #include "settings.h" -#include "privacybrowserdebug.h" - - -MainView::MainView(QWidget *parent) - : QWidget(parent) -{ - m_ui.setupUi(this); - handleSettingsChanged(); -} -MainView::~MainView() -{ -} +// Qt framework headers. +#include -void MainView::switchColors() +MainView::MainView(QWidget *parent) : QWidget(parent) { - // switch the foreground/background colors of the label - QColor color = Settings::colorBackground(); - Settings::setColorBackground(Settings::colorForeground()); - Settings::setColorForeground(color); + // Setup the UI. + mainViewUi.setupUi(this); - handleSettingsChanged(); -} - -void MainView::handleSettingsChanged() -{ - qCDebug(PRIVACYBROWSER) << "MainView::handleSettingsChanged()"; - QPalette palette = m_ui.templateLabel->palette(); - palette.setColor(QPalette::Window, Settings::colorBackground()); - palette.setColor(QPalette::WindowText, Settings::colorForeground()); - m_ui.templateLabel->setPalette(palette); + // Get a handle for the web engine view. + QWebEngineView *webEngineViewPointer = mainViewUi.webEngineView; - // i18n : internationalization - m_ui.templateLabel->setText(i18n("This project is %1 days old", Settings::ageInDays())); + // Load a website. + webEngineViewPointer->setUrl(QUrl(QStringLiteral("https://www.stoutner.com/"))); } diff --git a/src/mainview.h b/src/mainview.h index 6b9e6ca..8129eca 100644 --- a/src/mainview.h +++ b/src/mainview.h @@ -1,45 +1,39 @@ /* - SPDX-FileCopyrightText: %{CURRENT_YEAR} %{AUTHOR} <%{EMAIL}> - - SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL -*/ + * 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 . + */ #ifndef MAINVIEW_H #define MAINVIEW_H +// Application headers. #include "ui_mainview.h" - -/** - * 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 MainView : public QWidget { + // Include the Q_OBJECT macro. Q_OBJECT + public: - /** - * Default Constructor - */ + // The default contructor. explicit MainView(QWidget *parent); - /** - * Default Destructor - */ - ~MainView() override; - -public Q_SLOTS: - void switchColors(); - void handleSettingsChanged(); - 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::MainView m_ui; + // Declare the private variables. + Ui::MainView mainViewUi; }; - #endif diff --git a/src/mainview.ui b/src/mainview.ui index 2f42279..41b9b00 100644 --- a/src/mainview.ui +++ b/src/mainview.ui @@ -1,203 +1,62 @@ + + + - MainView - - - - 0 - 0 - 315 - 233 - - - - true - - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - - - 255 - 255 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - - - 255 - 255 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - - - 119 - 119 - 119 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - 0 - 0 - 0 - - - - - - - - - Sans Serif - 12 - - - - true - - - hello, world - - - true - - - Qt::AlignCenter - - - false - + MainView + + + + + + 0 + 0 + 315 + 233 + + + + + + 0 + + + + 0 + + + + 0 + + + + 0 + + + + + + + - - - - - + + + + diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 9cde452..3564a8e 100644 --- a/src/mainwindow.cpp +++ b/src/mainwindow.cpp @@ -20,8 +20,8 @@ // Application headers. #include "mainview.h" #include "mainwindow.h" -#include "privacybrowserdebug.h" #include "settings.h" +#include "ui_settings.h" // KDE Frameworks headers. #include @@ -30,7 +30,7 @@ MainWindow::MainWindow() : KXmlGuiWindow() { // Instantiate the main view pointer. - mainViewPointer = new MainView(this); + MainView *mainViewPointer = new MainView(this); // Set the main view as the central widget. setCentralWidget(mainViewPointer); @@ -49,36 +49,45 @@ MainWindow::MainWindow() : KXmlGuiWindow() // Connect the signals to the slots. connect(switchColorsActionPointer, &QAction::triggered, mainViewPointer, &MainView::switchColors); + // Add the standard actions. KStandardAction::openNew(this, SLOT(fileNew()), actionCollectionPointer); KStandardAction::quit(qApp, SLOT(closeAllWindows()), actionCollectionPointer); KStandardAction::preferences(this, SLOT(settingsConfigure()), actionCollectionPointer); + // Setup the GUI based on the privacybrowserui.rc file. setupGUI(); } void MainWindow::fileNew() { - qCDebug(PRIVACYBROWSER) << "MainWindow::fileNew()"; + // Display a new instance of Privacy Browser. (new MainWindow)->show(); } void MainWindow::settingsConfigure() { - qCDebug(PRIVACYBROWSER) << "MainWindow::settingsConfigure()"; - // The preference dialog is derived from prefs_base.ui - // - // compare the names of the widgets in the .ui file - // to the names of the variables in the .kcfg file - //avoid to have 2 dialogs shown - if (KConfigDialog::showDialog(QStringLiteral("settings"))) { - return; - } + // Check to make sure the dialog box isn't already displayed. + if (!KConfigDialog::exists(QStringLiteral("settings"))) + { + // Create a general settings page. + QWidget *generalSettingsWidgetPointer = new QWidget; + + // Instantiate the settings UI. + Ui::Settings settingsUi; + + // Setup the UI to display the general settings widget. + settingsUi.setupUi(generalSettingsWidgetPointer); + + // Instantiate a settings config dialog from the settings.kcfg file. + KConfigDialog *configDialogPointer = new KConfigDialog(this, QStringLiteral("settings"), Settings::self()); - KConfigDialog *dialog = new KConfigDialog(this, QStringLiteral("settings"), Settings::self()); - QWidget *generalSettingsPage = new QWidget; - settingsWidget.setupUi(generalSettingsPage); - dialog->addPage(generalSettingsPage, i18nc("@title:tab", "General"), QStringLiteral("package_setting")); - connect(dialog, &KConfigDialog::settingsChanged, mainViewPointer, &MainView::handleSettingsChanged); - dialog->setAttribute(Qt::WA_DeleteOnClose); - dialog->show(); + // Add the general settings widget page. + configDialogPointer->addPage(generalSettingsWidgetPointer, i18nc("@title:tab", "General"), QStringLiteral("package_setting")); + + // Delete the config dialog when it is closed. + configDialogPointer->setAttribute(Qt::WA_DeleteOnClose); + + // Make it so. + configDialogPointer->show(); + } } diff --git a/src/mainwindow.h b/src/mainwindow.h index 3e48bd4..588ac9e 100644 --- a/src/mainwindow.h +++ b/src/mainwindow.h @@ -20,15 +20,9 @@ #ifndef MAINWINDOW_H #define MAINWINDOW_H -// Application headers. -#include "settings.h" -#include "ui_settings.h" - // KDE Frameworks headers. #include -class MainView; - class MainWindow : public KXmlGuiWindow { // Include the Q_OBJECT macro. @@ -42,10 +36,5 @@ private Q_SLOTS: // Define the private slots. void fileNew(); void settingsConfigure(); - -private: - // Define the private variables. - Ui::Settings settingsWidget; - MainView *mainViewPointer; }; #endif diff --git a/src/privacybrowserui.rc b/src/privacybrowserui.rc index 977ea54..cedd0c6 100644 --- a/src/privacybrowserui.rc +++ b/src/privacybrowserui.rc @@ -1,20 +1,43 @@ - - - - - - - - - Main Toolbar - - - - + + + + + + + + + + + + + Main Toolbar + + + + + + + diff --git a/src/resources.qrc b/src/resources.qrc index f836ed9..5ac9f4c 100644 --- a/src/resources.qrc +++ b/src/resources.qrc @@ -19,7 +19,7 @@ - icons/sc-apps-privacy_browser.svg + icons/sc-apps-privacy-browser.svg licenses/GPLv3+.txt diff --git a/src/settings.kcfg b/src/settings.kcfg index 492e0e9..9a85eda 100644 --- a/src/settings.kcfg +++ b/src/settings.kcfg @@ -1,21 +1,44 @@ - - - - - - black - - - - yellow - - - - 2 - - + + + + + + + + + + + black + + + + + yellow + + + + + 2 + + diff --git a/src/settings.kcfgc b/src/settings.kcfgc index 4f3b929..4cd2746 100644 --- a/src/settings.kcfgc +++ b/src/settings.kcfgc @@ -25,5 +25,5 @@ ClassName=Settings # Make the generated class a singleton. TODO, the default is false. This may not be needed. Singleton=true -# Create code for mutating (making changes to) the listed variables. TODO, the default is false. These may not be needed. +# Allow mutating (making changes to) the listed variables. Mutators=colorBackground,colorForeground diff --git a/src/settings.ui b/src/settings.ui index e7759ac..fdfe8f2 100644 --- a/src/settings.ui +++ b/src/settings.ui @@ -1,94 +1,132 @@ + + + - Settings - - - - 0 - 0 - 374 - 200 - - - - - - - Background color: - + Settings + + + + + 0 + 0 + 374 + 200 + + + + + + + + Background color: + + + + + + + + Choose a new background color + + + + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> + p, li { white-space: pre-wrap; } + </style></head><body style=" font-family:'DejaVu Serif'; font-size:9pt; font-weight:400; font-style:normal;"> + <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Change the <span style=" font-weight:600;">background</span> color by clicking here and choose the new <span style=" color:#ff0000;">color</span> in the <span style=" font-style:italic;">color dialog</span>.</p></body></html> + + + + + + + + + + + + Foreground color: + + + + + + + + Choose a new foreground color + + + + <html><head><meta name="qrichtext" content="1" /><style type="text/css"> + p, li { white-space: pre-wrap; } + </style></head><body style=" font-family:'DejaVu Serif'; font-size:9pt; font-weight:400; font-style:normal;"> + <p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Change the <span style=" font-weight:600;">foreground</span> color by clicking here and choose the new <span style=" color:#ff0000;">color</span> in the <span style=" font-style:italic;">color dialog</span>.</p></body></html> + + + + + + + + + + + + Project age: + + + + + + + + Set the project age (in days) + + + + Change the project age (in days) by choosing a new number of days. + + + + 1 + + + + 2 + + + + - - - - - Choose a new background color - - - <html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'DejaVu Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Change the <span style=" font-weight:600;">background</span> color by clicking here and choose the new <span style=" color:#ff0000;">color</span> in the <span style=" font-style:italic;">color dialog</span>.</p></body></html> - - - - - - - - - - Foreground color: - - - - - - - Choose a new foreground color - - - <html><head><meta name="qrichtext" content="1" /><style type="text/css"> -p, li { white-space: pre-wrap; } -</style></head><body style=" font-family:'DejaVu Serif'; font-size:9pt; font-weight:400; font-style:normal;"> -<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Change the <span style=" font-weight:600;">foreground</span> color by clicking here and choose the new <span style=" color:#ff0000;">color</span> in the <span style=" font-style:italic;">color dialog</span>.</p></body></html> - - - - - - - - - - Project age: - - - - - - - Set the project age (in days) - - - Change the project age (in days) by choosing a new number of days. - - - 1 - - - 2 - - - - - - - - KColorButton - QPushButton -
kcolorbutton.h
-
-
- - + + + + KColorButton + + QPushButton + +
kcolorbutton.h
+
+
+ + + +