X-Git-Url: https://gitweb.stoutner.com/?p=PrivacyBrowserPC.git;a=blobdiff_plain;f=src%2Fmainwindow.cpp;h=1f7f34643832d83db1d14774441c8f95394c6e27;hp=9cde452405cdd43ee1a71c2e8843caa66fae56ed;hb=f3047a42fa756bb36d4840f40ab7acf83e751b48;hpb=153c5c0d60eaf3185cb4419032fb0fdaeb78907c diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp index 9cde452..1f7f346 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); @@ -38,47 +38,45 @@ MainWindow::MainWindow() : KXmlGuiWindow() // Get a handle for the action collectoin. KActionCollection *actionCollectionPointer = this->actionCollection(); - // Create a switch colorsaction pointer. - QAction *switchColorsActionPointer; - - // 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); - + // 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; - 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(); + // 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()); + + // 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(); + } }