X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserPC.git;a=blobdiff_plain;f=src%2Fmainwindow.cpp;h=3564a8e7a71d32e638d4a6a0683de73552fa4473;hp=9cde452405cdd43ee1a71c2e8843caa66fae56ed;hb=255215b082091aaadd5ef24cfc0880cd81e42272;hpb=153c5c0d60eaf3185cb4419032fb0fdaeb78907c 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(); + } }