*/
// Application headers.
+#include "mainview.h"
#include "mainwindow.h"
-#include "privacybrowserpcview.h"
-#include "privacybrowserdebug.h"
#include "settings.h"
+#include "ui_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.
+ MainView *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();
-}
+ // Add the standard actions.
+ KStandardAction::openNew(this, SLOT(fileNew()), actionCollectionPointer);
+ KStandardAction::quit(qApp, SLOT(closeAllWindows()), actionCollectionPointer);
+ KStandardAction::preferences(this, SLOT(settingsConfigure()), actionCollectionPointer);
-MainWindow::~MainWindow()
-{
+ // Setup the GUI based on the privacybrowserui.rc file.
+ setupGUI();
}
void MainWindow::fileNew()
{
- qCDebug(PRIVACYBROWSER) << "PrivacyBrowserPCWindow::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;
- KConfigDialog *dialog = new KConfigDialog(this, QStringLiteral("settings"), Settings::self());
- QWidget *generalSettingsPage = new QWidget;
- m_settings.setupUi(generalSettingsPage);
- dialog->addPage(generalSettingsPage, i18nc("@title:tab", "General"), QStringLiteral("package_setting"));
- connect(dialog, &KConfigDialog::settingsChanged, m_privacybrowserpcView, &PrivacyBrowserPCView::handleSettingsChanged);
- dialog->setAttribute(Qt::WA_DeleteOnClose);
- dialog->show();
+ // 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());
+
+ // Add the general settings widget page.
+ configDialogPointer->addPage(generalSettingsWidgetPointer, i18nc("@title:tab", "General"), QStringLiteral("breeze-settings"));
+
+ // Delete the config dialog when it is closed.
+ configDialogPointer->setAttribute(Qt::WA_DeleteOnClose);
+
+ // Make it so.
+ configDialogPointer->show();
+ }
}