2 * Copyright © 2022 Soren Stoutner <soren@stoutner.com>.
4 * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
6 * Privacy Browser PC is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * Privacy Browser PC is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with Privacy Browser PC. If not, see <http://www.gnu.org/licenses/>.
20 // Application headers.
21 #include "DomainSettingsWindow.h"
22 #include "views/DomainSettingsView.h"
24 // KDE Frameworks headers.
25 #include <KActionCollection>
26 #include <KLocalizedString>
28 DomainSettingsWindow::DomainSettingsWindow() : KXmlGuiWindow()
30 // Instantiate the domain settings view pointer.
31 DomainSettingsView *domainSettingsViewPointer = new DomainSettingsView(this);
33 // Set the domain settings view as the central widget.
34 setCentralWidget(domainSettingsViewPointer);
36 // Set the object name.
37 this->setObjectName(QStringLiteral("domain_settings"));
39 // Set the window title.
40 setCaption(i18nc("The Domain Settings window title", "Domain Settings"));
42 // Get a handle for the action collection.
43 KActionCollection *actionCollectionPointer = this->actionCollection();
45 // Add the custom actions.
46 QAction *addDomainActionPointer = actionCollectionPointer->addAction(QStringLiteral("add_domain"));
47 QAction *deleteDomainActionPointer = actionCollectionPointer->addAction(QStringLiteral("delete_domain"));
48 QAction *okActionPointer = actionCollectionPointer->addAction(QStringLiteral("ok"));
49 QAction *applyActionPointer = actionCollectionPointer->addAction(QStringLiteral("apply"));
50 QAction *cancelActionPointer = actionCollectionPointer->addAction(QStringLiteral("cancel"));
52 // Set the action text.
53 addDomainActionPointer->setText(i18nc("Add domain toolbar button", "Add Domain"));
54 deleteDomainActionPointer->setText(i18nc("Delete domain toolbar button", "Delete Domain"));
55 okActionPointer->setText(i18nc("OK toolbar button", "OK"));
56 applyActionPointer->setText(i18nc("Apply toolbar button", "Apply"));
57 cancelActionPointer->setText(i18nc("Cancel toolbar button", "Cancel"));
59 // Set the action icons.
60 addDomainActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("document-new")));
61 deleteDomainActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("delete")));
62 okActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("dialog-ok")));
63 applyActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("dialog-ok-apply")));
64 cancelActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("dialog-cancel")));
66 // Connect the button signals.
67 connect(addDomainActionPointer, SIGNAL(triggered()), domainSettingsViewPointer, SLOT(addDomain()));
68 connect(deleteDomainActionPointer, SIGNAL(triggered()), domainSettingsViewPointer, SLOT(deleteDomain()));
70 // Setup the GUI without a status bar based on the domain_settings_ui.rc file.
71 setupGUI(StandardWindowOption::ToolBar | StandardWindowOption::Keys | StandardWindowOption::Save | StandardWindowOption::Create, ("domain_settings_ui.rc"));