]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blobdiff - src/mainwindow.cpp
Make Privacy Browser installable.
[PrivacyBrowserPC.git] / src / mainwindow.cpp
index 739fca9603b3e11e6bc78f0a44cda526303a61b9..9cde452405cdd43ee1a71c2e8843caa66fae56ed 100644 (file)
  */
 
 // Application headers.
+#include "mainview.h"
 #include "mainwindow.h"
-#include "privacybrowserpcview.h"
-#include "privacybrowserpcdebug.h"
+#include "privacybrowserdebug.h"
+#include "settings.h"
 
 // KDE Frameworks headers.
 #include <KActionCollection>
 #include <KConfigDialog>
 
-
 MainWindow::MainWindow() : KXmlGuiWindow()
 {
-    m_privacybrowserpcView = new PrivacyBrowserPCView(this);
-    setCentralWidget(m_privacybrowserpcView);
+    // Instantiate the main view pointer.
+    mainViewPointer = new MainView(this);
 
-    KActionCollection* actionCollection = this->actionCollection();
-    m_switchAction = actionCollection->addAction(QStringLiteral("switch_action"));
-    m_switchAction->setText(i18nc("@action", "Switch Colors"));
-    m_switchAction->setIcon(QIcon::fromTheme(QStringLiteral("fill-color")));
-    connect(m_switchAction, &QAction::triggered, m_privacybrowserpcView, &PrivacyBrowserPCView::switchColors);
+    // Set the main view as the central widget.
+    setCentralWidget(mainViewPointer);
 
-    KStandardAction::openNew(this, SLOT(fileNew()), actionCollection);
-    KStandardAction::quit(qApp, SLOT(closeAllWindows()), actionCollection);
-    KStandardAction::preferences(this, SLOT(settingsConfigure()), actionCollection);
+    // Get a handle for the action collectoin.
+    KActionCollection *actionCollectionPointer = this->actionCollection();
 
-    setupGUI();
-}
+    // Create a switch colorsaction pointer.
+    QAction *switchColorsActionPointer;
 
-MainWindow::~MainWindow()
-{
+    // 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);
+
+    KStandardAction::openNew(this, SLOT(fileNew()), actionCollectionPointer);
+    KStandardAction::quit(qApp, SLOT(closeAllWindows()), actionCollectionPointer);
+    KStandardAction::preferences(this, SLOT(settingsConfigure()), actionCollectionPointer);
+
+    setupGUI();
 }
 
 void MainWindow::fileNew()
 {
-    qCDebug(PRIVACYBROWSER) << "PrivacyBrowserPCWindow::fileNew()";
+    qCDebug(PRIVACYBROWSER) << "MainWindow::fileNew()";
     (new MainWindow)->show();
 }
 
@@ -67,11 +74,11 @@ void MainWindow::settingsConfigure()
         return;
     }
 
-    KConfigDialog *dialog = new KConfigDialog(this, QStringLiteral("settings"), PrivacyBrowserPCSettings::self());
+    KConfigDialog *dialog = new KConfigDialog(this, QStringLiteral("settings"), Settings::self());
     QWidget *generalSettingsPage = new QWidget;
-    m_settings.setupUi(generalSettingsPage);
+    settingsWidget.setupUi(generalSettingsPage);
     dialog->addPage(generalSettingsPage, i18nc("@title:tab", "General"), QStringLiteral("package_setting"));
-    connect(dialog, &KConfigDialog::settingsChanged, m_privacybrowserpcView, &PrivacyBrowserPCView::handleSettingsChanged);
+    connect(dialog, &KConfigDialog::settingsChanged, mainViewPointer, &MainView::handleSettingsChanged);
     dialog->setAttribute(Qt::WA_DeleteOnClose);
     dialog->show();
 }