]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blobdiff - src/mainwindow.cpp
Make Privacy Browser installable.
[PrivacyBrowserPC.git] / src / mainwindow.cpp
index d0c4e1b0062c0d3634e8de66cb17558c415f41d9..9cde452405cdd43ee1a71c2e8843caa66fae56ed 100644 (file)
@@ -18,8 +18,8 @@
  */
 
 // Application headers.
+#include "mainview.h"
 #include "mainwindow.h"
-#include "privacybrowserpcview.h"
 #include "privacybrowserdebug.h"
 #include "settings.h"
 
 #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();
 }
 
@@ -70,9 +76,9 @@ void MainWindow::settingsConfigure()
 
     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();
 }