2 * Copyright © 2022 Soren Stoutner <soren@stoutner.com>.
4 * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
6 * Privacy Browser PC is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * Privacy Browser PC is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Privacy Browser PC. If not, see <http://www.gnu.org/licenses/>.
20 // Application headers.
21 #include "browserwindow.h"
24 #include "ui_settings.h"
26 // KDE Frameworks headers.
27 #include <KActionCollection>
28 #include <KConfigDialog>
30 // Qt framework headers.
33 BrowserWindow::BrowserWindow() : KXmlGuiWindow()
35 // Instantiate the main view pointer.
36 MainView *mainViewPointer = new MainView(this);
38 // Set the main view as the central widget.
39 setCentralWidget(mainViewPointer);
41 // Get a handle for the action collectoin.
42 KActionCollection *actionCollectionPointer = this->actionCollection();
44 // Add the standard actions.
45 KStandardAction::openNew(this, SLOT(fileNew()), actionCollectionPointer);
46 KStandardAction::quit(qApp, SLOT(closeAllWindows()), actionCollectionPointer);
47 KStandardAction::preferences(this, SLOT(settingsConfigure()), actionCollectionPointer);
49 // Update the status bar with the URL when a link is hovered.
50 connect(mainViewPointer, SIGNAL(linkHovered(QString)), this, SLOT(updateStatusBar(QString)));
52 // Setup the GUI based on the privacybrowserui.rc file.
56 void BrowserWindow::fileNew()
58 // Display a new instance of Privacy Browser.
59 (new BrowserWindow)->show();
62 void BrowserWindow::settingsConfigure()
64 // Check to make sure the dialog box isn't already displayed.
65 if (!KConfigDialog::exists(QStringLiteral("settings")))
67 // Create a general settings page.
68 QWidget *generalSettingsWidgetPointer = new QWidget;
70 // Instantiate the settings UI.
71 Ui::Settings settingsUi;
73 // Setup the UI to display the general settings widget.
74 settingsUi.setupUi(generalSettingsWidgetPointer);
76 // Instantiate a settings config dialog from the settings.kcfg file.
77 KConfigDialog *configDialogPointer = new KConfigDialog(this, QStringLiteral("settings"), Settings::self());
79 // Add the general settings widget page.
80 configDialogPointer->addPage(generalSettingsWidgetPointer, i18nc("@title:tab", "General"), QStringLiteral("breeze-settings"));
82 // Delete the config dialog when it is closed.
83 configDialogPointer->setAttribute(Qt::WA_DeleteOnClose);
86 configDialogPointer->show();
90 void BrowserWindow::updateStatusBar(const QString &statusBarMessage)
92 // Display the status bar message.
93 statusBar()->showMessage(statusBarMessage);