X-Git-Url: https://gitweb.stoutner.com/?a=blobdiff_plain;f=src%2Fmainwindow.cpp;fp=src%2Fmainwindow.cpp;h=739fca9603b3e11e6bc78f0a44cda526303a61b9;hb=597b6f74d41343f57e288694ec499e2303022f7e;hp=0000000000000000000000000000000000000000;hpb=6b2e1320fae530d918e617bbf2eab7b34e454498;p=PrivacyBrowserPC.git diff --git a/src/mainwindow.cpp b/src/mainwindow.cpp new file mode 100644 index 0000000..739fca9 --- /dev/null +++ b/src/mainwindow.cpp @@ -0,0 +1,77 @@ +/* + * Copyright © 2022 Soren Stoutner . + * + * This file is part of Privacy Browser PC . + * + * Privacy Browser PC is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Privacy Browser PC is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Privacy Browser PC. If not, see . + */ + +// Application headers. +#include "mainwindow.h" +#include "privacybrowserpcview.h" +#include "privacybrowserpcdebug.h" + +// KDE Frameworks headers. +#include +#include + + +MainWindow::MainWindow() : KXmlGuiWindow() +{ + m_privacybrowserpcView = new PrivacyBrowserPCView(this); + setCentralWidget(m_privacybrowserpcView); + + 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); + + KStandardAction::openNew(this, SLOT(fileNew()), actionCollection); + KStandardAction::quit(qApp, SLOT(closeAllWindows()), actionCollection); + KStandardAction::preferences(this, SLOT(settingsConfigure()), actionCollection); + + setupGUI(); +} + +MainWindow::~MainWindow() +{ +} + +void MainWindow::fileNew() +{ + qCDebug(PRIVACYBROWSER) << "PrivacyBrowserPCWindow::fileNew()"; + (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; + } + + KConfigDialog *dialog = new KConfigDialog(this, QStringLiteral("settings"), PrivacyBrowserPCSettings::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(); +}