]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blobdiff - src/mainwindow.cpp
Add the URL line edit.
[PrivacyBrowserPC.git] / src / mainwindow.cpp
index 9cde452405cdd43ee1a71c2e8843caa66fae56ed..1f7f34643832d83db1d14774441c8f95394c6e27 100644 (file)
@@ -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 <KActionCollection>
@@ -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();
+    }
 }