+++ /dev/null
-/*
- * Copyright © 2022 Soren Stoutner <soren@stoutner.com>.
- *
- * This file is part of Privacy Browser PC <https://www.stoutner.com/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 <http://www.gnu.org/licenses/>.
- */
-
-// Application headers.
-#include "browserwindow.h"
-#include "settings.h"
-#include "ui_settingsprivacy.h"
-#include "ui_settingsgeneral.h"
-
-// KDE Frameworks headers.
-#include <KActionCollection>
-#include <KConfigDialog>
-
-// Qt framework headers.
-#include <QStatusBar>
-
-BrowserWindow::BrowserWindow() : KXmlGuiWindow()
-{
- // Instantiate the main view pointer.
- mainViewPointer = new MainView(this);
-
- // Set the main view as the central widget.
- setCentralWidget(mainViewPointer);
-
- // Get a handle for the action collectoin.
- KActionCollection *actionCollectionPointer = this->actionCollection();
-
- // Add the standard actions.
- KStandardAction::openNew(this, SLOT(fileNew()), actionCollectionPointer);
- KStandardAction::quit(qApp, SLOT(closeAllWindows()), actionCollectionPointer);
- KStandardAction::preferences(this, SLOT(settingsConfigure()), actionCollectionPointer);
-
- // Update the status bar with the URL when a link is hovered.
- connect(mainViewPointer, SIGNAL(linkHovered(QString)), this, SLOT(updateStatusBar(QString)));
-
- // Setup the GUI based on the privacybrowserui.rc file.
- setupGUI();
-}
-
-void BrowserWindow::fileNew()
-{
- // Display a new instance of Privacy Browser.
- (new BrowserWindow)->show();
-}
-
-void BrowserWindow::settingsConfigure()
-{
- // Check to make sure the dialog box isn't already displayed.
- if (!KConfigDialog::exists(QStringLiteral("settings")))
- {
- // Create the settings widgets.
- QWidget *privacySettingsWidgetPointer = new QWidget;
- QWidget *generalSettingsWidgetPointer = new QWidget;
-
- // Instantiate the settings UI.
- Ui::PrivacySettings privacySettingsUi;
- Ui::GeneralSettings generalSettingsUi;
-
- // Setup the UI to display the settings widgets.
- privacySettingsUi.setupUi(privacySettingsWidgetPointer);
- generalSettingsUi.setupUi(generalSettingsWidgetPointer);
-
- // Instantiate a settings config dialog from the settings.kcfg file.
- KConfigDialog *configDialogPointer = new KConfigDialog(this, QStringLiteral("settings"), Settings::self());
-
- // Add the settings widgets as config dialog pages.
- configDialogPointer->addPage(privacySettingsWidgetPointer, i18nc("@title:tab", "Privacy"), QStringLiteral("privacy-browser"));
- configDialogPointer->addPage(generalSettingsWidgetPointer, i18nc("@title:tab", "General"), QStringLiteral("breeze-settings"));
-
- // Delete the config dialog when it is closed.
- configDialogPointer->setAttribute(Qt::WA_DeleteOnClose);
-
- // Make it so.
- configDialogPointer->show();
-
- // Apply the settings when they are updated.
- connect(configDialogPointer, SIGNAL(settingsChanged(QString)), mainViewPointer, SLOT(applyApplicationSettings()));
- connect(configDialogPointer, SIGNAL(settingsChanged(QString)), mainViewPointer, SLOT(applyDomainSettings()));
- }
-}
-
-void BrowserWindow::updateStatusBar(const QString &statusBarMessage)
-{
- // Display the status bar message.
- statusBar()->showMessage(statusBarMessage);
-}