2 SPDX-FileCopyrightText: %{CURRENT_YEAR} %{AUTHOR} <%{EMAIL}>
4 SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
8 #include "privacybrowserpcwindow.h"
10 #include "privacybrowserpcview.h"
11 #include "privacybrowserpcdebug.h"
14 #include <KActionCollection>
15 #include <KConfigDialog>
18 PrivacyBrowserPCWindow::PrivacyBrowserPCWindow()
21 m_privacybrowserpcView = new PrivacyBrowserPCView(this);
22 setCentralWidget(m_privacybrowserpcView);
24 KActionCollection* actionCollection = this->actionCollection();
25 m_switchAction = actionCollection->addAction(QStringLiteral("switch_action"));
26 m_switchAction->setText(i18nc("@action", "Switch Colors"));
27 m_switchAction->setIcon(QIcon::fromTheme(QStringLiteral("fill-color")));
28 connect(m_switchAction, &QAction::triggered, m_privacybrowserpcView, &PrivacyBrowserPCView::switchColors);
30 KStandardAction::openNew(this, SLOT(fileNew()), actionCollection);
31 KStandardAction::quit(qApp, SLOT(closeAllWindows()), actionCollection);
32 KStandardAction::preferences(this, SLOT(settingsConfigure()), actionCollection);
37 PrivacyBrowserPCWindow::~PrivacyBrowserPCWindow()
41 void PrivacyBrowserPCWindow::fileNew()
43 qCDebug(PRIVACYBROWSERPC) << "PrivacyBrowserPCWindow::fileNew()";
44 (new PrivacyBrowserPCWindow)->show();
47 void PrivacyBrowserPCWindow::settingsConfigure()
49 qCDebug(PRIVACYBROWSERPC) << "PrivacyBrowserPCWindow::settingsConfigure()";
50 // The preference dialog is derived from prefs_base.ui
52 // compare the names of the widgets in the .ui file
53 // to the names of the variables in the .kcfg file
54 //avoid to have 2 dialogs shown
55 if (KConfigDialog::showDialog(QStringLiteral("settings"))) {
59 KConfigDialog *dialog = new KConfigDialog(this, QStringLiteral("settings"), PrivacyBrowserPCSettings::self());
60 QWidget *generalSettingsPage = new QWidget;
61 m_settings.setupUi(generalSettingsPage);
62 dialog->addPage(generalSettingsPage, i18nc("@title:tab", "General"), QStringLiteral("package_setting"));
63 connect(dialog, &KConfigDialog::settingsChanged, m_privacybrowserpcView, &PrivacyBrowserPCView::handleSettingsChanged);
64 dialog->setAttribute(Qt::WA_DeleteOnClose);