]> gitweb.stoutner.com Git - PrivacyBrowserPC.git/blobdiff - src/windows/DomainSettingsWindow.cpp
Begin implementing Domain Settings using KXmlGuiWindow part 2.
[PrivacyBrowserPC.git] / src / windows / DomainSettingsWindow.cpp
diff --git a/src/windows/DomainSettingsWindow.cpp b/src/windows/DomainSettingsWindow.cpp
new file mode 100644 (file)
index 0000000..af4b3e7
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright © 2022 Soren Stoutner <soren@stoutner.com>.
+ *
+ * This file is part of Privacy Browser PC <https://www.stoutner.com/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 <http://www.gnu.org/licenses/>.
+ */
+
+// Application headers.
+#include "DomainSettingsWindow.h"
+#include "views/DomainSettingsView.h"
+
+// KDE Frameworks headers.
+#include <KActionCollection>
+#include <KLocalizedString>
+
+DomainSettingsWindow::DomainSettingsWindow() : KXmlGuiWindow()
+{
+    // Instantiate the domain settings view pointer.
+    DomainSettingsView *domainSettingsViewPointer = new DomainSettingsView(this);
+
+    // Set the domain settings view as the central widget.
+    setCentralWidget(domainSettingsViewPointer);
+
+    // Set the object name.
+    this->setObjectName(QStringLiteral("domain_settings"));
+
+    // Set the window title.
+    setCaption(i18nc("The Domain Settings window title", "Domain Settings"));
+
+    // Get a handle for the action collection.
+    KActionCollection *actionCollectionPointer = this->actionCollection();
+
+    // Add the custom actions.
+    QAction *addDomainActionPointer = actionCollectionPointer->addAction(QStringLiteral("add_domain"));
+    QAction *deleteDomainActionPointer = actionCollectionPointer->addAction(QStringLiteral("delete_domain"));
+    QAction *okActionPointer = actionCollectionPointer->addAction(QStringLiteral("ok"));
+    QAction *applyActionPointer = actionCollectionPointer->addAction(QStringLiteral("apply"));
+    QAction *cancelActionPointer = actionCollectionPointer->addAction(QStringLiteral("cancel"));
+
+    // Set the action text.
+    addDomainActionPointer->setText(i18nc("Add domain toolbar button", "Add Domain"));
+    deleteDomainActionPointer->setText(i18nc("Delete domain toolbar button", "Delete Domain"));
+    okActionPointer->setText(i18nc("OK toolbar button", "OK"));
+    applyActionPointer->setText(i18nc("Apply toolbar button", "Apply"));
+    cancelActionPointer->setText(i18nc("Cancel toolbar button", "Cancel"));
+
+    // Set the action icons.
+    addDomainActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("document-new")));
+    deleteDomainActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("delete")));
+    okActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("dialog-ok")));
+    applyActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("dialog-ok-apply")));
+    cancelActionPointer->setIcon(QIcon::fromTheme(QStringLiteral("dialog-cancel")));
+
+    // Connect the button signals.
+    connect(addDomainActionPointer, SIGNAL(triggered()), domainSettingsViewPointer, SLOT(addDomain()));
+    connect(deleteDomainActionPointer, SIGNAL(triggered()), domainSettingsViewPointer, SLOT(deleteDomain()));
+
+    // Setup the GUI without a status bar based on the domain_settings_ui.rc file.
+    setupGUI(StandardWindowOption::ToolBar | StandardWindowOption::Keys | StandardWindowOption::Save | StandardWindowOption::Create, ("domain_settings_ui.rc"));
+}