]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blob - src/windows/DomainSettingsWindow.cpp
af4b3e7a42e6a99a5d4d83e7cf7f87570d41d3e3
[PrivacyBrowserPC.git] / src / windows / DomainSettingsWindow.cpp
1 /*
2  * Copyright © 2022 Soren Stoutner <soren@stoutner.com>.
3  *
4  * This file is part of Privacy Browser PC <https://www.stoutner.com/privacy-browser-pc>.
5  *
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.
10  *
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.
15  *
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/>.
18  */
19
20 // Application headers.
21 #include "DomainSettingsWindow.h"
22 #include "views/DomainSettingsView.h"
23
24 // KDE Frameworks headers.
25 #include <KActionCollection>
26 #include <KLocalizedString>
27
28 DomainSettingsWindow::DomainSettingsWindow() : KXmlGuiWindow()
29 {
30     // Instantiate the domain settings view pointer.
31     DomainSettingsView *domainSettingsViewPointer = new DomainSettingsView(this);
32
33     // Set the domain settings view as the central widget.
34     setCentralWidget(domainSettingsViewPointer);
35
36     // Set the object name.
37     this->setObjectName(QStringLiteral("domain_settings"));
38
39     // Set the window title.
40     setCaption(i18nc("The Domain Settings window title", "Domain Settings"));
41
42     // Get a handle for the action collection.
43     KActionCollection *actionCollectionPointer = this->actionCollection();
44
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"));
51
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"));
58
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")));
65
66     // Connect the button signals.
67     connect(addDomainActionPointer, SIGNAL(triggered()), domainSettingsViewPointer, SLOT(addDomain()));
68     connect(deleteDomainActionPointer, SIGNAL(triggered()), domainSettingsViewPointer, SLOT(deleteDomain()));
69
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"));
72 }