aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/dialog
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/ui/dialog/GeneralDialog.cpp88
-rw-r--r--src/ui/dialog/GeneralDialog.h66
-rwxr-xr-xsrc/ui/dialog/QuitDialog.cpp4
-rwxr-xr-xsrc/ui/dialog/QuitDialog.h3
-rw-r--r--src/ui/dialog/SignersPicker.cpp (renamed from src/ui/widgets/SignersPicker.cpp)23
-rw-r--r--src/ui/dialog/SignersPicker.h (renamed from src/ui/widgets/SignersPicker.h)17
-rw-r--r--src/ui/dialog/Wizard.h6
-rw-r--r--src/ui/dialog/details/SignatureDetailsDialog.cpp (renamed from src/ui/details/SignatureDetailsDialog.cpp)0
-rw-r--r--src/ui/dialog/details/SignatureDetailsDialog.h (renamed from src/ui/details/SignatureDetailsDialog.h)1
-rw-r--r--src/ui/dialog/details/VerifyDetailsDialog.cpp (renamed from src/ui/details/VerifyDetailsDialog.cpp)0
-rw-r--r--src/ui/dialog/details/VerifyDetailsDialog.h (renamed from src/ui/details/VerifyDetailsDialog.h)0
-rw-r--r--src/ui/dialog/help/AboutDialog.cpp (renamed from src/ui/help/AboutDialog.cpp)28
-rw-r--r--src/ui/dialog/help/AboutDialog.h (renamed from src/ui/help/AboutDialog.h)3
-rw-r--r--src/ui/dialog/help/GnupgTab.cpp66
-rw-r--r--src/ui/dialog/help/GnupgTab.h53
-rw-r--r--src/ui/dialog/import_export/ExportKeyPackageDialog.cpp (renamed from src/ui/import_export/ExportKeyPackageDialog.cpp)6
-rw-r--r--src/ui/dialog/import_export/ExportKeyPackageDialog.h (renamed from src/ui/import_export/ExportKeyPackageDialog.h)3
-rw-r--r--src/ui/dialog/import_export/KeyImportDetailDialog.cpp (renamed from src/ui/import_export/KeyImportDetailDialog.cpp)6
-rw-r--r--src/ui/dialog/import_export/KeyImportDetailDialog.h (renamed from src/ui/import_export/KeyImportDetailDialog.h)3
-rw-r--r--src/ui/dialog/import_export/KeyServerImportDialog.cpp (renamed from src/ui/import_export/KeyServerImportDialog.cpp)270
-rw-r--r--src/ui/dialog/import_export/KeyServerImportDialog.h (renamed from src/ui/import_export/KeyServerImportDialog.h)45
-rw-r--r--src/ui/dialog/import_export/KeyUploadDialog.cpp (renamed from src/ui/import_export/KeyUploadDialog.cpp)8
-rw-r--r--src/ui/dialog/import_export/KeyUploadDialog.h (renamed from src/ui/import_export/KeyUploadDialog.h)3
-rw-r--r--src/ui/dialog/key_generate/KeygenDialog.cpp (renamed from src/ui/key_generate/KeygenDialog.cpp)5
-rw-r--r--src/ui/dialog/key_generate/KeygenDialog.h (renamed from src/ui/key_generate/KeygenDialog.h)3
-rw-r--r--src/ui/dialog/key_generate/SubkeyGenerateDialog.cpp (renamed from src/ui/key_generate/SubkeyGenerateDialog.cpp)5
-rw-r--r--src/ui/dialog/key_generate/SubkeyGenerateDialog.h (renamed from src/ui/key_generate/SubkeyGenerateDialog.h)3
-rw-r--r--src/ui/dialog/keypair_details/KeyDetailsDialog.cpp (renamed from src/ui/keypair_details/KeyDetailsDialog.cpp)12
-rw-r--r--src/ui/dialog/keypair_details/KeyDetailsDialog.h (renamed from src/ui/keypair_details/KeyDetailsDialog.h)3
-rw-r--r--src/ui/dialog/keypair_details/KeyNewUIDDialog.cpp (renamed from src/ui/keypair_details/KeyNewUIDDialog.cpp)14
-rw-r--r--src/ui/dialog/keypair_details/KeyNewUIDDialog.h (renamed from src/ui/keypair_details/KeyNewUIDDialog.h)3
-rw-r--r--src/ui/dialog/keypair_details/KeyPairDetailTab.cpp (renamed from src/ui/keypair_details/KeyPairDetailTab.cpp)2
-rw-r--r--src/ui/dialog/keypair_details/KeyPairDetailTab.h (renamed from src/ui/keypair_details/KeyPairDetailTab.h)24
-rw-r--r--src/ui/dialog/keypair_details/KeyPairOperaTab.cpp (renamed from src/ui/keypair_details/KeyPairOperaTab.cpp)4
-rw-r--r--src/ui/dialog/keypair_details/KeyPairOperaTab.h (renamed from src/ui/keypair_details/KeyPairOperaTab.h)0
-rw-r--r--src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp (renamed from src/ui/keypair_details/KeyPairSubkeyTab.cpp)2
-rw-r--r--src/ui/dialog/keypair_details/KeyPairSubkeyTab.h (renamed from src/ui/keypair_details/KeyPairSubkeyTab.h)2
-rw-r--r--src/ui/dialog/keypair_details/KeyPairUIDTab.cpp (renamed from src/ui/keypair_details/KeyPairUIDTab.cpp)2
-rw-r--r--src/ui/dialog/keypair_details/KeyPairUIDTab.h (renamed from src/ui/keypair_details/KeyPairUIDTab.h)0
-rw-r--r--src/ui/dialog/keypair_details/KeySetExpireDateDialog.cpp (renamed from src/ui/keypair_details/KeySetExpireDateDialog.cpp)6
-rw-r--r--src/ui/dialog/keypair_details/KeySetExpireDateDialog.h (renamed from src/ui/keypair_details/KeySetExpireDateDialog.h)3
-rw-r--r--src/ui/dialog/keypair_details/KeyUIDSignDialog.cpp (renamed from src/ui/keypair_details/KeyUIDSignDialog.cpp)6
-rw-r--r--src/ui/dialog/keypair_details/KeyUIDSignDialog.h (renamed from src/ui/keypair_details/KeyUIDSignDialog.h)3
-rw-r--r--src/ui/dialog/settings/SettingsAdvanced.cpp (renamed from src/ui/settings/SettingsAdvanced.cpp)0
-rw-r--r--src/ui/dialog/settings/SettingsAdvanced.h (renamed from src/ui/settings/SettingsAdvanced.h)0
-rw-r--r--src/ui/dialog/settings/SettingsAppearance.cpp (renamed from src/ui/settings/SettingsAppearance.cpp)26
-rw-r--r--src/ui/dialog/settings/SettingsAppearance.h (renamed from src/ui/settings/SettingsAppearance.h)0
-rw-r--r--src/ui/dialog/settings/SettingsDialog.cpp (renamed from src/ui/settings/SettingsDialog.cpp)13
-rw-r--r--[-rwxr-xr-x]src/ui/dialog/settings/SettingsDialog.h (renamed from src/ui/settings/SettingsDialog.h)5
-rw-r--r--src/ui/dialog/settings/SettingsGeneral.cpp (renamed from src/ui/settings/SettingsGeneral.cpp)0
-rw-r--r--src/ui/dialog/settings/SettingsGeneral.h (renamed from src/ui/settings/SettingsGeneral.h)0
-rw-r--r--src/ui/dialog/settings/SettingsKeyServer.cpp (renamed from src/ui/settings/SettingsKeyServer.cpp)35
-rw-r--r--src/ui/dialog/settings/SettingsKeyServer.h (renamed from src/ui/settings/SettingsKeyServer.h)0
-rw-r--r--src/ui/dialog/settings/SettingsNetwork.cpp (renamed from src/ui/settings/SettingsNetwork.cpp)0
-rw-r--r--src/ui/dialog/settings/SettingsNetwork.h (renamed from src/ui/settings/SettingsNetwork.h)0
55 files changed, 584 insertions, 299 deletions
diff --git a/src/ui/dialog/GeneralDialog.cpp b/src/ui/dialog/GeneralDialog.cpp
new file mode 100644
index 00000000..d07c2497
--- /dev/null
+++ b/src/ui/dialog/GeneralDialog.cpp
@@ -0,0 +1,88 @@
+/*
+ * Copyright (c) 2022. Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend 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.
+ *
+ * GpgFrontend 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 GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#include "GeneralDialog.h"
+
+#include "ui/struct/SettingsObject.h"
+
+GpgFrontend::UI::GeneralDialog::GeneralDialog(std::string name, QWidget *parent)
+ : name_(std::move(name)), QDialog(parent) {
+ slot_restore_settings();
+ connect(this, &QDialog::finished, this, &GeneralDialog::slot_save_settings);
+}
+
+GpgFrontend::UI::GeneralDialog::~GeneralDialog() = default;
+
+void GpgFrontend::UI::GeneralDialog::slot_restore_settings() noexcept {
+ try {
+ LOG(INFO) << name_ << _("Called");
+
+ SettingsObject general_windows_state(name_ + "_dialog_state");
+
+ bool window_save = general_windows_state.Check("window_save", true);
+
+ // Restore window size & location
+ if (window_save) {
+ int x = general_windows_state.Check("window_pos").Check("x", 100),
+ y = general_windows_state.Check("window_pos").Check("y", 100);
+
+ this->move({x, y});
+ pos_ = {x, y};
+
+ int width =
+ general_windows_state.Check("window_size").Check("width", 400),
+ height =
+ general_windows_state.Check("window_size").Check("height", 247);
+
+ this->resize({width, height});
+ size_ = {width, height};
+
+ }
+
+ } catch (...) {
+ LOG(ERROR) << name_ << "error";
+ }
+}
+
+void GpgFrontend::UI::GeneralDialog::slot_save_settings() noexcept {
+ try {
+ LOG(INFO) << name_ << _("Called");
+
+ SettingsObject general_windows_state(name_ + "_dialog_state");
+
+ // window position and size
+ general_windows_state["window_pos"]["x"] = pos().x();
+ general_windows_state["window_pos"]["y"] = pos().y();
+
+ general_windows_state["window_size"]["width"] = size_.width();
+ general_windows_state["window_size"]["height"] = size_.height();
+ general_windows_state["window_save"] = true;
+
+ } catch (...) {
+ LOG(ERROR) << name_ << "error";
+ }
+}
diff --git a/src/ui/dialog/GeneralDialog.h b/src/ui/dialog/GeneralDialog.h
new file mode 100644
index 00000000..ca480c8b
--- /dev/null
+++ b/src/ui/dialog/GeneralDialog.h
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2022. Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend 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.
+ *
+ * GpgFrontend 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 GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+#ifndef GPGFRONTEND_GENERALDIALOG_H
+#define GPGFRONTEND_GENERALDIALOG_H
+
+#include "ui/GpgFrontendUI.h"
+
+namespace GpgFrontend::UI {
+
+class GeneralDialog : public QDialog {
+ public:
+ /**
+ *
+ * @param name
+ */
+ explicit GeneralDialog(std::string name, QWidget* parent = nullptr);
+
+ /**
+ *
+ */
+ ~GeneralDialog() override;
+
+ private slots:
+ /**
+ *
+ */
+ void slot_restore_settings() noexcept;
+
+ /**
+ *
+ */
+ void slot_save_settings() noexcept;
+
+ private:
+ std::string name_; ///<
+ QPoint pos_; ///<
+ QSize size_; ///<
+};
+} // namespace GpgFrontend::UI
+
+#endif // GPGFRONTEND_GENERALDIALOG_H
diff --git a/src/ui/dialog/QuitDialog.cpp b/src/ui/dialog/QuitDialog.cpp
index da0be488..87b1c1e1 100755
--- a/src/ui/dialog/QuitDialog.cpp
+++ b/src/ui/dialog/QuitDialog.cpp
@@ -33,7 +33,7 @@
namespace GpgFrontend::UI {
QuitDialog::QuitDialog(QWidget* parent, const QHash<int, QString>& unsavedDocs)
- : QDialog(parent) {
+ : GeneralDialog("quit_dialog", parent) {
setWindowTitle(_("Unsaved Files"));
setModal(true);
discarded_ = false;
@@ -111,7 +111,7 @@ QuitDialog::QuitDialog(QWidget* parent, const QHash<int, QString>& unsavedDocs)
connect(buttonBox, &QDialogButtonBox::accepted, this, &QuitDialog::accept);
connect(buttonBox, &QDialogButtonBox::rejected, this, &QuitDialog::reject);
QPushButton* btnNoKey = buttonBox->button(QDialogButtonBox::Discard);
- connect(btnNoKey, &QPushButton::clicked, this,&QuitDialog::slot_my_discard);
+ connect(btnNoKey, &QPushButton::clicked, this, &QuitDialog::slot_my_discard);
/*
* Set the layout
diff --git a/src/ui/dialog/QuitDialog.h b/src/ui/dialog/QuitDialog.h
index 2d09790b..2fd9e382 100755
--- a/src/ui/dialog/QuitDialog.h
+++ b/src/ui/dialog/QuitDialog.h
@@ -30,6 +30,7 @@
#define __QUITDIALOG_H__
#include "ui/GpgFrontendUI.h"
+#include "ui/dialog/GeneralDialog.h"
namespace GpgFrontend::UI {
@@ -37,7 +38,7 @@ namespace GpgFrontend::UI {
* @brief
*
*/
-class QuitDialog : public QDialog {
+class QuitDialog : public GeneralDialog {
Q_OBJECT
public:
diff --git a/src/ui/widgets/SignersPicker.cpp b/src/ui/dialog/SignersPicker.cpp
index 75f6b2ba..a670e514 100644
--- a/src/ui/widgets/SignersPicker.cpp
+++ b/src/ui/dialog/SignersPicker.cpp
@@ -1,7 +1,7 @@
-/**
- * Copyright (C) 2021 Saturneric
+/*
+ * Copyright (c) 2022. Saturneric
*
- * This file is part of GpgFrontend.
+ * This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,18 +23,24 @@
* Saturneric<[email protected]> starting on May 12, 2021.
*
* SPDX-License-Identifier: GPL-3.0-or-later
- *
*/
-#include "ui/widgets/SignersPicker.h"
+#include "SignersPicker.h"
#include "ui/widgets/KeyList.h"
namespace GpgFrontend::UI {
-SignersPicker::SignersPicker(QWidget* parent) : QDialog(parent) {
+SignersPicker::SignersPicker(QWidget* parent)
+ : GeneralDialog(typeid(SignersPicker).name(), parent) {
auto confirm_button = new QPushButton(_("Confirm"));
- connect(confirm_button, &QPushButton::clicked, this, &SignersPicker::accept);
+ auto cancel_button = new QPushButton(_("Cancel"));
+
+ connect(confirm_button, &QPushButton::clicked, [=]() {
+ this->accepted_ = true;
+ });
+ connect(confirm_button, &QPushButton::clicked, this, &QDialog::accept);
+ connect(cancel_button, &QPushButton::clicked, this, &QDialog::reject);
/*Setup KeyList*/
key_list_ = new KeyList(false, this);
@@ -55,6 +61,7 @@ SignersPicker::SignersPicker(QWidget* parent) : QDialog(parent) {
"\n" +
_("If no key is selected, the default key will be used for signing.")));
vbox2->addWidget(confirm_button);
+ vbox2->addWidget(cancel_button);
vbox2->addStretch(0);
setLayout(vbox2);
@@ -71,4 +78,6 @@ GpgFrontend::KeyIdArgsListPtr SignersPicker::GetCheckedSigners() {
return key_list_->GetPrivateChecked();
}
+bool SignersPicker::GetStatus() const { return this->accepted_; }
+
} // namespace GpgFrontend::UI
diff --git a/src/ui/widgets/SignersPicker.h b/src/ui/dialog/SignersPicker.h
index 30f872f8..5533f9d8 100644
--- a/src/ui/widgets/SignersPicker.h
+++ b/src/ui/dialog/SignersPicker.h
@@ -1,7 +1,7 @@
-/**
- * Copyright (C) 2021 Saturneric
+/*
+ * Copyright (c) 2022. Saturneric
*
- * This file is part of GpgFrontend.
+ * This file is part of GpgFrontend.
*
* GpgFrontend is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -23,13 +23,13 @@
* Saturneric<[email protected]> starting on May 12, 2021.
*
* SPDX-License-Identifier: GPL-3.0-or-later
- *
*/
#ifndef GPGFRONTEND_ZH_CN_TS_SIGNERSPIRCKER_H
#define GPGFRONTEND_ZH_CN_TS_SIGNERSPIRCKER_H
#include "GpgFrontendUI.h"
+#include "ui/dialog//GeneralDialog.h"
namespace GpgFrontend::UI {
@@ -39,7 +39,7 @@ class KeyList;
* @brief
*
*/
-class SignersPicker : public QDialog {
+class SignersPicker : public GeneralDialog {
Q_OBJECT
public:
@@ -57,8 +57,15 @@ class SignersPicker : public QDialog {
*/
GpgFrontend::KeyIdArgsListPtr GetCheckedSigners();
+ /**
+ *
+ * @return
+ */
+ [[nodiscard]] bool GetStatus() const;
+
private:
KeyList* key_list_; ///<
+ bool accepted_ = false;
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/dialog/Wizard.h b/src/ui/dialog/Wizard.h
index eb093550..879dc5d9 100644
--- a/src/ui/dialog/Wizard.h
+++ b/src/ui/dialog/Wizard.h
@@ -30,10 +30,10 @@
#define WIZARD_H
#include "core/GpgConstants.h"
+#include "main_window/KeyMgmt.h"
#include "ui/GpgFrontendUI.h"
-#include "ui/KeyMgmt.h"
-#include "ui/key_generate/KeygenDialog.h"
-#include "ui/settings/SettingsDialog.h"
+#include "ui/dialog/key_generate/KeygenDialog.h"
+#include "ui/dialog/settings/SettingsDialog.h"
namespace GpgFrontend::UI {
diff --git a/src/ui/details/SignatureDetailsDialog.cpp b/src/ui/dialog/details/SignatureDetailsDialog.cpp
index a3ad03b3..a3ad03b3 100644
--- a/src/ui/details/SignatureDetailsDialog.cpp
+++ b/src/ui/dialog/details/SignatureDetailsDialog.cpp
diff --git a/src/ui/details/SignatureDetailsDialog.h b/src/ui/dialog/details/SignatureDetailsDialog.h
index 847b320b..7b01d054 100644
--- a/src/ui/details/SignatureDetailsDialog.h
+++ b/src/ui/dialog/details/SignatureDetailsDialog.h
@@ -28,6 +28,7 @@
#ifndef GPGFRONTEND_SIGNATUREDETAILSDIALOG_H
#define GPGFRONTEND_SIGNATUREDETAILSDIALOG_H
+
#include "ui/GpgFrontendUI.h"
class SignatureDetailsDialog : public QDialog {
diff --git a/src/ui/details/VerifyDetailsDialog.cpp b/src/ui/dialog/details/VerifyDetailsDialog.cpp
index d2af4ee1..d2af4ee1 100644
--- a/src/ui/details/VerifyDetailsDialog.cpp
+++ b/src/ui/dialog/details/VerifyDetailsDialog.cpp
diff --git a/src/ui/details/VerifyDetailsDialog.h b/src/ui/dialog/details/VerifyDetailsDialog.h
index 97e2cc2d..97e2cc2d 100644
--- a/src/ui/details/VerifyDetailsDialog.h
+++ b/src/ui/dialog/details/VerifyDetailsDialog.h
diff --git a/src/ui/help/AboutDialog.cpp b/src/ui/dialog/help/AboutDialog.cpp
index e8fbeb1b..6b6e4356 100644
--- a/src/ui/help/AboutDialog.cpp
+++ b/src/ui/dialog/help/AboutDialog.cpp
@@ -26,39 +26,43 @@
*
*/
-#include "ui/help/AboutDialog.h"
+#include "AboutDialog.h"
#include "GpgFrontendBuildInfo.h"
#include "core/function/GlobalSettingStation.h"
#include "core/thread/TaskRunnerGetter.h"
+#include "ui/dialog/help/GnupgTab.h"
#include "ui/thread/VersionCheckTask.h"
namespace GpgFrontend::UI {
-AboutDialog::AboutDialog(int defaultIndex, QWidget* parent) : QDialog(parent) {
+AboutDialog::AboutDialog(int defaultIndex, QWidget* parent)
+ : GeneralDialog(typeid(AboutDialog).name(), parent) {
this->setWindowTitle(QString(_("About")) + " " + qApp->applicationName());
- auto* tabWidget = new QTabWidget;
- auto* infoTab = new InfoTab();
- auto* translatorsTab = new TranslatorsTab();
+ auto* tab_widget = new QTabWidget;
+ auto* info_tab = new InfoTab();
+ auto* gnupg_tab = new GnupgTab();
+ auto* translators_tab = new TranslatorsTab();
update_tab_ = new UpdateTab();
- tabWidget->addTab(infoTab, _("About Software"));
- tabWidget->addTab(translatorsTab, _("Translators"));
- tabWidget->addTab(update_tab_, _("Update"));
+ tab_widget->addTab(info_tab, _("About GpgFrontend"));
+ tab_widget->addTab(gnupg_tab, _("GnuPG"));
+ tab_widget->addTab(translators_tab, _("Translators"));
+ tab_widget->addTab(update_tab_, _("Update"));
- connect(tabWidget, &QTabWidget::currentChanged, this,
+ connect(tab_widget, &QTabWidget::currentChanged, this,
[&](int index) { LOG(INFO) << "Current Index" << index; });
- if (defaultIndex < tabWidget->count() && defaultIndex >= 0) {
- tabWidget->setCurrentIndex(defaultIndex);
+ if (defaultIndex < tab_widget->count() && defaultIndex >= 0) {
+ tab_widget->setCurrentIndex(defaultIndex);
}
auto* buttonBox = new QDialogButtonBox(QDialogButtonBox::Ok);
connect(buttonBox, &QDialogButtonBox::accepted, this, &AboutDialog::close);
auto* mainLayout = new QVBoxLayout;
- mainLayout->addWidget(tabWidget);
+ mainLayout->addWidget(tab_widget);
mainLayout->addWidget(buttonBox);
setLayout(mainLayout);
diff --git a/src/ui/help/AboutDialog.h b/src/ui/dialog/help/AboutDialog.h
index 40d93f3e..09a63734 100644
--- a/src/ui/help/AboutDialog.h
+++ b/src/ui/dialog/help/AboutDialog.h
@@ -31,6 +31,7 @@
#include "core/GpgContext.h"
#include "ui/GpgFrontendUI.h"
+#include "ui/dialog/GeneralDialog.h"
#include "ui/struct/SoftwareVersion.h"
namespace GpgFrontend::UI {
@@ -116,7 +117,7 @@ class UpdateTab : public QWidget {
* @brief Class for handling the about dialog
*
*/
-class AboutDialog : public QDialog {
+class AboutDialog : public GeneralDialog {
Q_OBJECT
public:
diff --git a/src/ui/dialog/help/GnupgTab.cpp b/src/ui/dialog/help/GnupgTab.cpp
new file mode 100644
index 00000000..48787987
--- /dev/null
+++ b/src/ui/dialog/help/GnupgTab.cpp
@@ -0,0 +1,66 @@
+/*
+ * Copyright (c) 2022. Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend 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.
+ *
+ * GpgFrontend 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 GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+//
+// Created by eric on 2022/7/23.
+//
+
+#include "GnupgTab.h"
+
+GpgFrontend::UI::GnupgTab::GnupgTab(QWidget* parent) : QWidget(parent) {
+ GpgContext& ctx = GpgContext::GetInstance();
+ auto info = ctx.GetInfo();
+
+ auto* pixmap = new QPixmap(":gnupg.png");
+ auto* text = new QString(
+ "<center><h2>" + QString(_("GnuPG")) + "</h2></center>" + "<center><b>" +
+ QString(_("GnuPG Version")) + ": " +
+ QString::fromStdString(info.GnupgVersion) + "</b></center>" +
+ "<center><b>" + +"</b></center>" + "<center>" +
+ QString(_("GpgME Version")) + ": " +
+ QString::fromStdString(info.GpgMEVersion) + "</center><br /><hr />" +
+ "<h3>" + QString(_("PATHs")) + "</h3>" + QString(_("GpgConf")) + ": " +
+ QString::fromStdString(info.GpgConfPath) + "<br />" +
+ QString(_("GnuPG")) + ": " + QString::fromStdString(info.AppPath) +
+ "<br />" + QString(_("CMS")) + ": " +
+ QString::fromStdString(info.CMSPath) + "<br />");
+
+ auto* layout = new QGridLayout();
+ auto* pixmapLabel = new QLabel();
+ pixmapLabel->setPixmap(*pixmap);
+ layout->addWidget(pixmapLabel, 0, 0, 1, -1, Qt::AlignCenter);
+ auto* aboutLabel = new QLabel();
+ aboutLabel->setText(*text);
+ aboutLabel->setWordWrap(true);
+ aboutLabel->setOpenExternalLinks(true);
+ layout->addWidget(aboutLabel, 1, 0, 1, -1);
+ layout->addItem(
+ new QSpacerItem(20, 10, QSizePolicy::Minimum, QSizePolicy::Fixed), 2, 1,
+ 1, 1);
+
+ setLayout(layout);
+}
diff --git a/src/ui/dialog/help/GnupgTab.h b/src/ui/dialog/help/GnupgTab.h
new file mode 100644
index 00000000..4fc7ff22
--- /dev/null
+++ b/src/ui/dialog/help/GnupgTab.h
@@ -0,0 +1,53 @@
+/*
+ * Copyright (c) 2022. Saturneric
+ *
+ * This file is part of GpgFrontend.
+ *
+ * GpgFrontend 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.
+ *
+ * GpgFrontend 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 GpgFrontend. If not, see <https://www.gnu.org/licenses/>.
+ *
+ * The initial version of the source code is inherited from
+ * the gpg4usb project, which is under GPL-3.0-or-later.
+ *
+ * All the source code of GpgFrontend was modified and released by
+ * Saturneric<[email protected]> starting on May 12, 2021.
+ *
+ * SPDX-License-Identifier: GPL-3.0-or-later
+ */
+
+//
+// Created by eric on 2022/7/23.
+//
+
+#ifndef GPGFRONTEND_GNUPGTAB_H
+#define GPGFRONTEND_GNUPGTAB_H
+
+#include "core/GpgContext.h"
+#include "ui/GpgFrontendUI.h"
+
+namespace GpgFrontend::UI{
+class GnupgTab: public QWidget {
+ Q_OBJECT
+ public:
+ /**
+ * @brief Construct a new Info Tab object
+ *
+ * @param parent
+ */
+ explicit GnupgTab(QWidget* parent = nullptr);
+};
+}
+
+
+
+#endif // GPGFRONTEND_GNUPGTAB_H
diff --git a/src/ui/import_export/ExportKeyPackageDialog.cpp b/src/ui/dialog/import_export/ExportKeyPackageDialog.cpp
index d6f303f6..312cd946 100644
--- a/src/ui/import_export/ExportKeyPackageDialog.cpp
+++ b/src/ui/dialog/import_export/ExportKeyPackageDialog.cpp
@@ -30,13 +30,13 @@
#include <boost/format.hpp>
-#include "core/function/gpg/GpgKeyGetter.h"
#include "core/function/KeyPackageOperator.h"
+#include "core/function/gpg/GpgKeyGetter.h"
#include "ui_ExportKeyPackageDialog.h"
GpgFrontend::UI::ExportKeyPackageDialog::ExportKeyPackageDialog(
KeyIdArgsListPtr key_ids, QWidget* parent)
- : QDialog(parent),
+ : GeneralDialog(typeid(ExportKeyPackageDialog).name(), parent),
ui_(std::make_shared<Ui_exportKeyPackageDialog>()),
key_ids_(std::move(key_ids)) {
ui_->setupUi(this);
@@ -141,5 +141,5 @@ GpgFrontend::UI::ExportKeyPackageDialog::ExportKeyPackageDialog(
_("Exclude keys that do not have a private key"));
setAttribute(Qt::WA_DeleteOnClose);
- setWindowTitle(_("exportKeyPackageDialog"));
+ setWindowTitle(_("Export As Key Package"));
}
diff --git a/src/ui/import_export/ExportKeyPackageDialog.h b/src/ui/dialog/import_export/ExportKeyPackageDialog.h
index ecf13b1d..c5f9a2b1 100644
--- a/src/ui/import_export/ExportKeyPackageDialog.h
+++ b/src/ui/dialog/import_export/ExportKeyPackageDialog.h
@@ -30,6 +30,7 @@
#define GPGFRONTEND_EXPORTKEYPACKAGEDIALOG_H
#include "GpgFrontendUI.h"
+#include "ui/dialog/GeneralDialog.h"
class Ui_exportKeyPackageDialog;
@@ -39,7 +40,7 @@ namespace GpgFrontend::UI {
* @brief
*
*/
-class ExportKeyPackageDialog : public QDialog {
+class ExportKeyPackageDialog : public GeneralDialog {
Q_OBJECT
public:
diff --git a/src/ui/import_export/KeyImportDetailDialog.cpp b/src/ui/dialog/import_export/KeyImportDetailDialog.cpp
index 766d2d81..31183a34 100644
--- a/src/ui/import_export/KeyImportDetailDialog.cpp
+++ b/src/ui/dialog/import_export/KeyImportDetailDialog.cpp
@@ -33,7 +33,8 @@
namespace GpgFrontend::UI {
KeyImportDetailDialog::KeyImportDetailDialog(GpgImportInformation result,
bool automatic, QWidget* parent)
- : QDialog(parent), m_result_(std::move(result)) {
+ : GeneralDialog(typeid(KeyImportDetailDialog).name(), parent),
+ m_result_(std::move(result)) {
// If no key for import found, just show a message
if (m_result_.considered == 0) {
if (automatic)
@@ -197,6 +198,7 @@ QString KeyImportDetailDialog::get_status_string(int keyStatus) {
void KeyImportDetailDialog::create_button_box() {
button_box_ = new QDialogButtonBox(QDialogButtonBox::Ok);
- connect(button_box_, &QDialogButtonBox::accepted, this, &KeyImportDetailDialog::close);
+ connect(button_box_, &QDialogButtonBox::accepted, this,
+ &KeyImportDetailDialog::close);
}
} // namespace GpgFrontend::UI
diff --git a/src/ui/import_export/KeyImportDetailDialog.h b/src/ui/dialog/import_export/KeyImportDetailDialog.h
index a648f205..06f44e94 100644
--- a/src/ui/import_export/KeyImportDetailDialog.h
+++ b/src/ui/dialog/import_export/KeyImportDetailDialog.h
@@ -32,6 +32,7 @@
#include "core/GpgContext.h"
#include "core/function/gpg/GpgKeyImportExporter.h"
#include "ui/GpgFrontendUI.h"
+#include "ui/dialog/GeneralDialog.h"
namespace GpgFrontend::UI {
@@ -39,7 +40,7 @@ namespace GpgFrontend::UI {
* @brief
*
*/
-class KeyImportDetailDialog : public QDialog {
+class KeyImportDetailDialog : public GeneralDialog {
Q_OBJECT
public:
diff --git a/src/ui/import_export/KeyServerImportDialog.cpp b/src/ui/dialog/import_export/KeyServerImportDialog.cpp
index e359238c..6430a22e 100644
--- a/src/ui/import_export/KeyServerImportDialog.cpp
+++ b/src/ui/dialog/import_export/KeyServerImportDialog.cpp
@@ -28,17 +28,21 @@
#include "KeyServerImportDialog.h"
+#include <string>
#include <utility>
#include "core/function/GlobalSettingStation.h"
#include "core/function/gpg/GpgKeyImportExporter.h"
+#include "thread/KeyServerImportTask.h"
#include "ui/SignalStation.h"
#include "ui/struct/SettingsObject.h"
+#include "ui/thread/KeyServerSearchTask.h"
namespace GpgFrontend::UI {
KeyServerImportDialog::KeyServerImportDialog(bool automatic, QWidget* parent)
- : QDialog(parent), m_automatic_(automatic) {
+ : GeneralDialog("key_server_import_dialog", parent),
+ m_automatic_(automatic) {
// Layout for messagebox
auto* message_layout = new QHBoxLayout();
@@ -115,36 +119,6 @@ KeyServerImportDialog::KeyServerImportDialog(bool automatic, QWidget* parent)
if (automatic) {
this->setFixedSize(240, 42);
- } else {
- auto pos = QPoint(150, 150);
- LOG(INFO) << "parent" << parent;
- if (parent) pos += parent->pos();
- LOG(INFO) << "pos default" << pos.x() << pos.y();
- auto size = QSize(800, 500);
-
- try {
- SettingsObject key_server_import_state("key_server_import_state");
- bool window_save = key_server_import_state.Check("window_save", true);
-
- // Restore window size & location
- if (window_save) {
- int x = key_server_import_state.Check("window_pos").Check("x", pos.x()),
- y = key_server_import_state.Check("window_pos").Check("y", pos.y());
-
- pos = QPoint(x, y);
- int width = key_server_import_state.Check("window_size")
- .Check("width", size.width()),
- height = key_server_import_state.Check("window_size")
- .Check("height", size.height());
-
- size = QSize(width, height);
- }
- } catch (...) {
- LOG(WARNING) << "cannot read pos or size from settings object";
- }
-
- this->resize(size);
- this->move(pos);
}
this->setModal(true);
@@ -152,10 +126,31 @@ KeyServerImportDialog::KeyServerImportDialog(bool automatic, QWidget* parent)
connect(this, &KeyServerImportDialog::SignalKeyImported,
SignalStation::GetInstance(),
&SignalStation::SignalKeyDatabaseRefresh);
+}
+
+KeyServerImportDialog::KeyServerImportDialog(QWidget* parent)
+ : GeneralDialog("key_server_import_dialog", parent), m_automatic_(true) {
+ setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
+
+ // Network Waiting
+ waiting_bar_ = new QProgressBar();
+ waiting_bar_->setVisible(false);
+ waiting_bar_->setRange(0, 0);
+ waiting_bar_->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
+ waiting_bar_->setTextVisible(false);
+
+ // Layout for messagebox
+ auto* layout = new QHBoxLayout();
+ layout->setContentsMargins(0, 0, 0, 0);
+ layout->setSpacing(0);
+ layout->addWidget(waiting_bar_);
- // save window pos and size to configure file
- connect(this, &KeyServerImportDialog::finished, this,
- &KeyServerImportDialog::slot_save_window_state);
+ key_server_combo_box_ = create_comboBox();
+
+ this->setLayout(layout);
+ this->setWindowTitle(_("Update Keys from Keyserver"));
+ this->setFixedSize(240, 42);
+ this->setModal(true);
}
QComboBox* KeyServerImportDialog::create_comboBox() {
@@ -174,6 +169,9 @@ QComboBox* KeyServerImportDialog::create_comboBox() {
}
int default_key_server_index = key_server_json.Check("default_server", 0);
+ if (default_key_server_index >= key_server_list.size()) {
+ throw std::runtime_error("default_server index out of range");
+ }
std::string default_key_server =
key_server_list[default_key_server_index].get<std::string>();
@@ -227,45 +225,44 @@ void KeyServerImportDialog::slot_search() {
return;
}
- QUrl url_from_remote = key_server_combo_box_->currentText() +
- "/pks/lookup?search=" + search_line_edit_->text() +
- "&op=index&options=mr";
- network_access_manager_ = new QNetworkAccessManager(this);
- QNetworkReply* reply =
- network_access_manager_->get(QNetworkRequest(url_from_remote));
+ auto* task = new KeyServerSearchTask(
+ key_server_combo_box_->currentText().toStdString(),
+ search_line_edit_->text().toStdString());
- connect(reply, &QNetworkReply::finished, this,
+ connect(task, &KeyServerSearchTask::SignalKeyServerSearchResult, this,
&KeyServerImportDialog::slot_search_finished);
+ connect(task, &KeyServerSearchTask::SignalKeyServerSearchResult, this, [=]() {
+ this->search_button_->setDisabled(false);
+ this->key_server_combo_box_->setDisabled(false);
+ this->search_line_edit_->setReadOnly(false);
+ this->import_button_->setDisabled(false);
+ set_loading(false);
+ });
+
set_loading(true);
this->search_button_->setDisabled(true);
this->key_server_combo_box_->setDisabled(true);
this->search_line_edit_->setReadOnly(true);
this->import_button_->setDisabled(true);
- while (reply->isRunning()) {
- QApplication::processEvents();
- }
-
- this->search_button_->setDisabled(false);
- this->key_server_combo_box_->setDisabled(false);
- this->search_line_edit_->setReadOnly(false);
- this->import_button_->setDisabled(false);
- set_loading(false);
+ Thread::TaskRunnerGetter::GetInstance()
+ .GetTaskRunner(Thread::TaskRunnerGetter::kTaskRunnerType_Network)
+ ->PostTask(task);
}
-void KeyServerImportDialog::slot_search_finished() {
- LOG(INFO) << "Called";
-
- auto* reply = qobject_cast<QNetworkReply*>(sender());
+void KeyServerImportDialog::slot_search_finished(
+ QNetworkReply::NetworkError error, QByteArray buffer) {
+ LOG(INFO) << "Called" << error << buffer.size();
+ LOG(INFO) << buffer.toStdString();
keys_table_->clearContents();
keys_table_->setRowCount(0);
- QString first_line = QString(reply->readLine(1024));
- auto error = reply->error();
+ auto stream = QTextStream(buffer);
+
if (error != QNetworkReply::NoError) {
- LOG(INFO) << "Error From Reply" << reply->errorString().toStdString();
+ LOG(INFO) << "Error From Reply" << error;
switch (error) {
case QNetworkReply::ContentNotFoundError:
@@ -283,8 +280,9 @@ void KeyServerImportDialog::slot_search_finished() {
return;
}
- if (first_line.contains("Error")) {
- QString text = QString(reply->readLine(1024));
+ if (stream.readLine().contains("Error")) {
+ auto text = stream.readLine(1024);
+
if (text.contains("Too many responses")) {
set_message(
"<h4>" + QString(_("Too many responses from keyserver!")) + "</h4>",
@@ -324,11 +322,14 @@ void KeyServerImportDialog::slot_search_finished() {
} else {
int row = 0;
bool strikeout = false;
- while (reply->canReadLine()) {
- auto line_buff = reply->readLine().trimmed();
- QString decoded =
- QString::fromUtf8(line_buff.constData(), line_buff.size());
- QStringList line = decoded.split(":");
+
+ // read lines until end of steam
+ while (!stream.atEnd()) {
+ QStringList line =
+ QString::fromUtf8(QByteArray::fromPercentEncoding(
+ stream.readLine().trimmed().toUtf8()))
+ .split(":");
+
// TODO: have a look at two following pub lines
if (line[0] == "pub") {
strikeout = false;
@@ -354,7 +355,9 @@ void KeyServerImportDialog::slot_search_finished() {
}
}
- QStringList line2 = QString(reply->readLine()).split(":");
+ QStringList line2 = QString(QByteArray::fromPercentEncoding(
+ stream.readLine().trimmed().toUtf8()))
+ .split(":");
auto* uid = new QTableWidgetItem();
if (line2.size() > 1) {
@@ -400,32 +403,45 @@ void KeyServerImportDialog::slot_search_finished() {
keys_table_->resizeColumnsToContents();
import_button_->setDisabled(keys_table_->size().isEmpty());
}
- reply->deleteLater();
}
void KeyServerImportDialog::slot_import() {
- LOG(INFO) << _("Current Row") << keys_table_->currentRow();
- if (keys_table_->currentRow() > -1) {
- QString keyid = keys_table_->item(keys_table_->currentRow(), 2)->text();
- SlotImport(QStringList(keyid), key_server_combo_box_->currentText());
+ std::vector<std::string> key_ids;
+ const int row_count = keys_table_->rowCount();
+ for (int i = 0; i < row_count; ++i) {
+ if (keys_table_->item(i, 2)->isSelected()) {
+ QString keyid = keys_table_->item(i, 2)->text();
+ key_ids.push_back(keyid.toStdString());
+ }
}
+ if (!key_ids.empty())
+ SlotImport(key_ids, key_server_combo_box_->currentText().toStdString());
}
void KeyServerImportDialog::SlotImport(const KeyIdArgsListPtr& keys) {
+ // keyserver host url
std::string target_keyserver;
+
if (key_server_combo_box_ != nullptr) {
target_keyserver = key_server_combo_box_->currentText().toStdString();
}
if (target_keyserver.empty()) {
try {
- auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
+ SettingsObject key_server_json("key_server");
+ const auto key_server_list =
+ key_server_json.Check("server_list", nlohmann::json::array());
- target_keyserver = settings.lookup("keyserver.default_server").c_str();
+ int default_key_server_index = key_server_json.Check("default_server", 0);
+ if (default_key_server_index >= key_server_list.size()) {
+ throw std::runtime_error("default_server index out of range");
+ }
+ std::string default_key_server =
+ key_server_list[default_key_server_index].get<std::string>();
- LOG(INFO) << _("Set target Key Server to default Key Server")
- << target_keyserver;
+ target_keyserver = default_key_server;
} catch (...) {
- LOG(ERROR) << _("Cannot read default_keyserver From Settings");
+ LOG(ERROR) << _("Setting Operation Error") << "server_list"
+ << "default_server";
QMessageBox::critical(
nullptr, _("Default Keyserver Not Found"),
_("Cannot read default keyserver from your settings, "
@@ -433,42 +449,31 @@ void KeyServerImportDialog::SlotImport(const KeyIdArgsListPtr& keys) {
return;
}
}
- auto key_ids = QStringList();
- for (const auto& key_id : *keys)
- key_ids.append(QString::fromStdString(key_id));
- SlotImport(key_ids, QUrl(target_keyserver.c_str()));
-}
-
-void KeyServerImportDialog::SlotImport(const QStringList& keyIds,
- const QUrl& keyserverUrl) {
- for (const auto& keyId : keyIds) {
- QUrl req_url(keyserverUrl.scheme() + "://" + keyserverUrl.host() +
- "/pks/lookup?op=get&search=0x" + keyId + "&options=mr");
-
- LOG(INFO) << "request url" << req_url.toString().toStdString();
- auto manager = new QNetworkAccessManager(this);
-
- QNetworkReply* reply = manager->get(QNetworkRequest(req_url));
- connect(reply, &QNetworkReply::finished, this,
- [&, keyId]() { this->slot_import_finished(keyId); });
- LOG(INFO) << "loading start";
- set_loading(true);
- while (reply->isRunning()) QApplication::processEvents();
- set_loading(false);
- LOG(INFO) << "loading done";
+ std::vector<std::string> key_ids;
+ for (const auto& key_id : *keys) {
+ key_ids.push_back(key_id);
}
+ SlotImport(key_ids, target_keyserver);
}
-void KeyServerImportDialog::slot_import_finished(const QString& keyid) {
- LOG(INFO) << _("Called");
+void KeyServerImportDialog::SlotImport(std::vector<std::string> key_ids,
+ std::string keyserver_url) {
+ auto* task = new KeyServerImportTask(keyserver_url, key_ids);
- auto* reply = qobject_cast<QNetworkReply*>(sender());
+ connect(task, &KeyServerImportTask::SignalKeyServerImportResult, this,
+ &KeyServerImportDialog::slot_import_finished);
- QByteArray key = reply->readAll();
+ Thread::TaskRunnerGetter::GetInstance()
+ .GetTaskRunner(Thread::TaskRunnerGetter::kTaskRunnerType_Network)
+ ->PostTask(task);
+}
+
+void KeyServerImportDialog::slot_import_finished(
+ QNetworkReply::NetworkError error, QByteArray buffer) {
+ LOG(INFO) << _("Called");
- auto error = reply->error();
if (error != QNetworkReply::NoError) {
- LOG(ERROR) << "Error From Reply" << reply->errorString().toStdString();
+ LOG(ERROR) << "Error From Reply" << buffer.toStdString();
if (!m_automatic_) {
switch (error) {
case QNetworkReply::ContentNotFoundError:
@@ -486,10 +491,8 @@ void KeyServerImportDialog::slot_import_finished(const QString& keyid) {
} else {
switch (error) {
case QNetworkReply::ContentNotFoundError:
- QMessageBox::critical(
- nullptr, _("Public key Not Found"),
- QString(_("Public key fingerprint %1 not found in the Keyserver"))
- .arg(keyid));
+ QMessageBox::critical(nullptr, _("Key Not Found"),
+ QString(_("key not found in the Keyserver")));
break;
case QNetworkReply::TimeoutError:
QMessageBox::critical(nullptr, _("Timeout"), "Connection timeout");
@@ -510,9 +513,8 @@ void KeyServerImportDialog::slot_import_finished(const QString& keyid) {
return;
}
- reply->deleteLater();
-
- this->import_keys(std::make_unique<ByteArray>(key.constData(), key.length()));
+ this->import_keys(
+ std::make_unique<ByteArray>(buffer.constData(), buffer.length()));
if (!m_automatic_) {
set_message(QString("<h4>") + _("Key Imported") + "</h4>", false);
@@ -522,14 +524,17 @@ void KeyServerImportDialog::slot_import_finished(const QString& keyid) {
void KeyServerImportDialog::import_keys(ByteArrayPtr in_data) {
GpgImportInformation result =
GpgKeyImportExporter::GetInstance().ImportKey(std::move(in_data));
+
+ // refresh the key database
emit SignalKeyImported();
+
QWidget* _parent = qobject_cast<QWidget*>(parent());
if (m_automatic_) {
auto dialog = new KeyImportDetailDialog(result, true, _parent);
dialog->show();
this->accept();
} else {
- auto dialog = new KeyImportDetailDialog(result, false, _parent);
+ auto dialog = new KeyImportDetailDialog(result, false, this);
dialog->exec();
}
}
@@ -542,45 +547,4 @@ void KeyServerImportDialog::set_loading(bool status) {
}
}
-KeyServerImportDialog::KeyServerImportDialog(QWidget* parent)
- : QDialog(parent), m_automatic_(true) {
- setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
-
- // Network Waiting
- waiting_bar_ = new QProgressBar();
- waiting_bar_->setVisible(false);
- waiting_bar_->setRange(0, 0);
- waiting_bar_->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
- waiting_bar_->setTextVisible(false);
-
- // Layout for messagebox
- auto* layout = new QHBoxLayout();
- layout->setContentsMargins(0, 0, 0, 0);
- layout->setSpacing(0);
- layout->addWidget(waiting_bar_);
-
- key_server_combo_box_ = create_comboBox();
-
- this->setLayout(layout);
- this->setWindowTitle(_("Update Keys from Keyserver"));
- this->setFixedSize(240, 42);
- this->setModal(true);
-}
-
-void KeyServerImportDialog::slot_save_window_state() {
- LOG(INFO) << _("Called");
-
- if (m_automatic_) return;
-
- SettingsObject key_server_import_state("key_server_import_state");
-
- // window position and size
- key_server_import_state["window_pos"]["x"] = pos().x();
- key_server_import_state["window_pos"]["y"] = pos().y();
-
- key_server_import_state["window_size"]["width"] = size().width();
- key_server_import_state["window_size"]["height"] = size().height();
- key_server_import_state["window_save"] = true;
-}
-
} // namespace GpgFrontend::UI
diff --git a/src/ui/import_export/KeyServerImportDialog.h b/src/ui/dialog/import_export/KeyServerImportDialog.h
index 37362859..fd912bdd 100644
--- a/src/ui/import_export/KeyServerImportDialog.h
+++ b/src/ui/dialog/import_export/KeyServerImportDialog.h
@@ -29,9 +29,12 @@
#ifndef __KEY_SERVER_IMPORT_DIALOG_H__
#define __KEY_SERVER_IMPORT_DIALOG_H__
+#include <string>
+
#include "KeyImportDetailDialog.h"
#include "core/GpgContext.h"
#include "ui/GpgFrontendUI.h"
+#include "ui/dialog/GeneralDialog.h"
#include "ui/widgets/KeyList.h"
namespace GpgFrontend::UI {
@@ -40,7 +43,7 @@ namespace GpgFrontend::UI {
* @brief
*
*/
-class KeyServerImportDialog : public QDialog {
+class KeyServerImportDialog : public GeneralDialog {
Q_OBJECT
public:
@@ -74,7 +77,8 @@ class KeyServerImportDialog : public QDialog {
* @param keyIds
* @param keyserverUrl
*/
- void SlotImport(const QStringList& keyIds, const QUrl& keyserverUrl);
+ void SlotImport(std::vector<std::string> key_ids_list,
+ std::string keyserver_url);
signals:
@@ -87,7 +91,7 @@ class KeyServerImportDialog : public QDialog {
private slots:
/**
- * @brief
+ * @brief import key(s) for the key table selection
*
*/
void slot_import();
@@ -96,14 +100,16 @@ class KeyServerImportDialog : public QDialog {
* @brief
*
*/
- void slot_search_finished();
+ void slot_search_finished(QNetworkReply::NetworkError reply,
+ QByteArray buffer);
/**
* @brief
*
* @param keyid
*/
- void slot_import_finished(const QString& keyid);
+ void slot_import_finished(QNetworkReply::NetworkError error,
+ QByteArray buffer);
/**
* @brief
@@ -111,12 +117,6 @@ class KeyServerImportDialog : public QDialog {
*/
void slot_search();
- /**
- * @brief
- *
- */
- void slot_save_window_state();
-
private:
/**
* @brief Create a keys table object
@@ -164,18 +164,17 @@ class KeyServerImportDialog : public QDialog {
bool m_automatic_ = false; ///<
- QLineEdit* search_line_edit_{}; ///<
- QComboBox* key_server_combo_box_{}; ///<
- QProgressBar* waiting_bar_; ///<
- QLabel* search_label_{}; ///<
- QLabel* key_server_label_{}; ///<
- QLabel* message_{}; ///<
- QLabel* icon_{}; ///<
- QPushButton* close_button_{}; ///<
- QPushButton* import_button_{}; ///<
- QPushButton* search_button_{}; ///<
- QTableWidget* keys_table_{}; ///<
- QNetworkAccessManager* network_access_manager_{}; ///<
+ QLineEdit* search_line_edit_{}; ///<
+ QComboBox* key_server_combo_box_{}; ///<
+ QProgressBar* waiting_bar_; ///<
+ QLabel* search_label_{}; ///<
+ QLabel* key_server_label_{}; ///<
+ QLabel* message_{}; ///<
+ QLabel* icon_{}; ///<
+ QPushButton* close_button_{}; ///<
+ QPushButton* import_button_{}; ///<
+ QPushButton* search_button_{}; ///<
+ QTableWidget* keys_table_{}; ///<
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/import_export/KeyUploadDialog.cpp b/src/ui/dialog/import_export/KeyUploadDialog.cpp
index a0436a8e..055f2e1f 100644
--- a/src/ui/import_export/KeyUploadDialog.cpp
+++ b/src/ui/dialog/import_export/KeyUploadDialog.cpp
@@ -30,15 +30,16 @@
#include <algorithm>
+#include "core/function/GlobalSettingStation.h"
#include "core/function/gpg/GpgKeyGetter.h"
#include "core/function/gpg/GpgKeyImportExporter.h"
-#include "core/function/GlobalSettingStation.h"
namespace GpgFrontend::UI {
KeyUploadDialog::KeyUploadDialog(const KeyIdArgsListPtr& keys_ids,
QWidget* parent)
- : QDialog(parent), m_keys_(GpgKeyGetter::GetInstance().GetKeys(keys_ids)) {
+ : GeneralDialog(typeid(KeyUploadDialog).name(), parent),
+ m_keys_(GpgKeyGetter::GetInstance().GetKeys(keys_ids)) {
auto* pb = new QProgressBar();
pb->setRange(0, 0);
pb->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
@@ -109,7 +110,8 @@ void KeyUploadDialog::slot_upload_key_to_server(
// Send Post Data
QNetworkReply* reply = qnam->post(request, postData);
- connect(reply, &QNetworkReply::finished, this, &KeyUploadDialog::slot_upload_finished);
+ connect(reply, &QNetworkReply::finished, this,
+ &KeyUploadDialog::slot_upload_finished);
// Keep Waiting
while (reply->isRunning()) {
diff --git a/src/ui/import_export/KeyUploadDialog.h b/src/ui/dialog/import_export/KeyUploadDialog.h
index 05cba083..d621f33a 100644
--- a/src/ui/import_export/KeyUploadDialog.h
+++ b/src/ui/dialog/import_export/KeyUploadDialog.h
@@ -31,6 +31,7 @@
#include "core/GpgContext.h"
#include "ui/GpgFrontendUI.h"
+#include "ui/dialog/GeneralDialog.h"
namespace GpgFrontend::UI {
@@ -38,7 +39,7 @@ namespace GpgFrontend::UI {
* @brief
*
*/
-class KeyUploadDialog : public QDialog {
+class KeyUploadDialog : public GeneralDialog {
Q_OBJECT
public:
/**
diff --git a/src/ui/key_generate/KeygenDialog.cpp b/src/ui/dialog/key_generate/KeygenDialog.cpp
index d5ca801d..42160ec9 100644
--- a/src/ui/key_generate/KeygenDialog.cpp
+++ b/src/ui/dialog/key_generate/KeygenDialog.cpp
@@ -26,7 +26,7 @@
*
*/
-#include "ui/key_generate/KeygenDialog.h"
+#include "KeygenDialog.h"
#include "core/function/GlobalSettingStation.h"
#include "core/function/gpg/GpgKeyOpera.h"
@@ -35,7 +35,8 @@
namespace GpgFrontend::UI {
-KeyGenDialog::KeyGenDialog(QWidget* parent) : QDialog(parent) {
+KeyGenDialog::KeyGenDialog(QWidget* parent)
+ : GeneralDialog(typeid(KeyGenDialog).name(), parent) {
button_box_ =
new QDialogButtonBox(QDialogButtonBox::Ok | QDialogButtonBox::Cancel);
diff --git a/src/ui/key_generate/KeygenDialog.h b/src/ui/dialog/key_generate/KeygenDialog.h
index 751ebdd8..baf10dbf 100644
--- a/src/ui/key_generate/KeygenDialog.h
+++ b/src/ui/dialog/key_generate/KeygenDialog.h
@@ -30,6 +30,7 @@
#include "core/GpgContext.h"
#include "core/GpgGenKeyInfo.h"
#include "ui/GpgFrontendUI.h"
+#include "ui/dialog/GeneralDialog.h"
namespace GpgFrontend::UI {
@@ -37,7 +38,7 @@ namespace GpgFrontend::UI {
* @brief
*
*/
-class KeyGenDialog : public QDialog {
+class KeyGenDialog : public GeneralDialog {
Q_OBJECT
public:
diff --git a/src/ui/key_generate/SubkeyGenerateDialog.cpp b/src/ui/dialog/key_generate/SubkeyGenerateDialog.cpp
index 2b9e076d..806c0e50 100644
--- a/src/ui/key_generate/SubkeyGenerateDialog.cpp
+++ b/src/ui/dialog/key_generate/SubkeyGenerateDialog.cpp
@@ -24,7 +24,7 @@
*
*/
-#include "ui/key_generate/SubkeyGenerateDialog.h"
+#include "SubkeyGenerateDialog.h"
#include "core/function/GlobalSettingStation.h"
#include "core/function/gpg/GpgKeyGetter.h"
@@ -35,7 +35,8 @@
namespace GpgFrontend::UI {
SubkeyGenerateDialog::SubkeyGenerateDialog(const KeyId& key_id, QWidget* parent)
- : QDialog(parent), key_(GpgKeyGetter::GetInstance().GetKey(key_id)) {
+ : GeneralDialog(typeid(SubkeyGenerateDialog).name(), parent),
+ key_(GpgKeyGetter::GetInstance().GetKey(key_id)) {
auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
// max expire date time
diff --git a/src/ui/key_generate/SubkeyGenerateDialog.h b/src/ui/dialog/key_generate/SubkeyGenerateDialog.h
index 4ab90ad4..1e6608b2 100644
--- a/src/ui/key_generate/SubkeyGenerateDialog.h
+++ b/src/ui/dialog/key_generate/SubkeyGenerateDialog.h
@@ -30,13 +30,14 @@
#include "core/GpgContext.h"
#include "core/GpgGenKeyInfo.h"
#include "ui/GpgFrontendUI.h"
+#include "ui/dialog/GeneralDialog.h"
namespace GpgFrontend::UI {
/**
* @brief
*
*/
-class SubkeyGenerateDialog : public QDialog {
+class SubkeyGenerateDialog : public GeneralDialog {
Q_OBJECT
public:
diff --git a/src/ui/keypair_details/KeyDetailsDialog.cpp b/src/ui/dialog/keypair_details/KeyDetailsDialog.cpp
index 3b3e8818..9c2f8003 100644
--- a/src/ui/keypair_details/KeyDetailsDialog.cpp
+++ b/src/ui/dialog/keypair_details/KeyDetailsDialog.cpp
@@ -26,16 +26,16 @@
*
*/
-#include "ui/keypair_details/KeyDetailsDialog.h"
+#include "KeyDetailsDialog.h"
-#include "ui/keypair_details/KeyPairDetailTab.h"
-#include "ui/keypair_details/KeyPairOperaTab.h"
-#include "ui/keypair_details/KeyPairSubkeyTab.h"
-#include "ui/keypair_details/KeyPairUIDTab.h"
+#include "KeyPairDetailTab.h"
+#include "KeyPairOperaTab.h"
+#include "KeyPairSubkeyTab.h"
+#include "KeyPairUIDTab.h"
namespace GpgFrontend::UI {
KeyDetailsDialog::KeyDetailsDialog(const GpgKey& key, QWidget* parent)
- : QDialog(parent) {
+ : GeneralDialog(typeid(KeyDetailsDialog).name(), parent) {
tab_widget_ = new QTabWidget();
tab_widget_->addTab(new KeyPairDetailTab(key.GetId(), tab_widget_),
_("KeyPair"));
diff --git a/src/ui/keypair_details/KeyDetailsDialog.h b/src/ui/dialog/keypair_details/KeyDetailsDialog.h
index e6f4472c..1ddcda00 100644
--- a/src/ui/keypair_details/KeyDetailsDialog.h
+++ b/src/ui/dialog/keypair_details/KeyDetailsDialog.h
@@ -31,10 +31,11 @@
#include "core/GpgContext.h"
#include "ui/GpgFrontendUI.h"
+#include "ui/dialog/GeneralDialog.h"
namespace GpgFrontend::UI {
-class KeyDetailsDialog : public QDialog {
+class KeyDetailsDialog : public GeneralDialog {
Q_OBJECT
public:
diff --git a/src/ui/keypair_details/KeyNewUIDDialog.cpp b/src/ui/dialog/keypair_details/KeyNewUIDDialog.cpp
index 9ff73f9e..18dd1967 100644
--- a/src/ui/keypair_details/KeyNewUIDDialog.cpp
+++ b/src/ui/dialog/keypair_details/KeyNewUIDDialog.cpp
@@ -24,7 +24,7 @@
*
*/
-#include "ui/keypair_details/KeyNewUIDDialog.h"
+#include "KeyNewUIDDialog.h"
#include "core/function/gpg/GpgKeyGetter.h"
#include "core/function/gpg/GpgUIDOperator.h"
@@ -32,7 +32,8 @@
namespace GpgFrontend::UI {
KeyNewUIDDialog::KeyNewUIDDialog(const KeyId& key_id, QWidget* parent)
- : QDialog(parent), m_key_(GpgKeyGetter::GetInstance().GetKey(key_id)) {
+ : GeneralDialog(typeid(KeyNewUIDDialog).name(), parent),
+ m_key_(GpgKeyGetter::GetInstance().GetKey(key_id)) {
name_ = new QLineEdit();
name_->setMinimumWidth(240);
email_ = new QLineEdit();
@@ -65,7 +66,8 @@ KeyNewUIDDialog::KeyNewUIDDialog(const KeyId& key_id, QWidget* parent)
this->setAttribute(Qt::WA_DeleteOnClose, true);
this->setModal(true);
- connect(this, &KeyNewUIDDialog::SignalUIDCreated, SignalStation::GetInstance(),
+ connect(this, &KeyNewUIDDialog::SignalUIDCreated,
+ SignalStation::GetInstance(),
&SignalStation::SignalKeyDatabaseRefresh);
}
@@ -84,9 +86,9 @@ void KeyNewUIDDialog::slot_create_new_uid() {
}
auto error_string = error_stream.str();
if (error_string.empty()) {
- if (GpgUIDOperator::GetInstance().AddUID(m_key_, name_->text().toStdString(),
- comment_->text().toStdString(),
- email_->text().toStdString())) {
+ if (GpgUIDOperator::GetInstance().AddUID(
+ m_key_, name_->text().toStdString(), comment_->text().toStdString(),
+ email_->text().toStdString())) {
emit finished(1);
emit SignalUIDCreated();
} else
diff --git a/src/ui/keypair_details/KeyNewUIDDialog.h b/src/ui/dialog/keypair_details/KeyNewUIDDialog.h
index 24f2c6b1..291b59c4 100644
--- a/src/ui/keypair_details/KeyNewUIDDialog.h
+++ b/src/ui/dialog/keypair_details/KeyNewUIDDialog.h
@@ -29,9 +29,10 @@
#include "core/GpgContext.h"
#include "ui/GpgFrontendUI.h"
+#include "ui/dialog/GeneralDialog.h"
namespace GpgFrontend::UI {
-class KeyNewUIDDialog : public QDialog {
+class KeyNewUIDDialog : public GeneralDialog {
Q_OBJECT
public:
diff --git a/src/ui/keypair_details/KeyPairDetailTab.cpp b/src/ui/dialog/keypair_details/KeyPairDetailTab.cpp
index 76f316e9..4a6e4b52 100644
--- a/src/ui/keypair_details/KeyPairDetailTab.cpp
+++ b/src/ui/dialog/keypair_details/KeyPairDetailTab.cpp
@@ -24,7 +24,7 @@
*
*/
-#include "ui/keypair_details/KeyPairDetailTab.h"
+#include "KeyPairDetailTab.h"
#include "core/function/gpg/GpgKeyGetter.h"
#include "core/function/gpg/GpgKeyImportExporter.h"
diff --git a/src/ui/keypair_details/KeyPairDetailTab.h b/src/ui/dialog/keypair_details/KeyPairDetailTab.h
index 9d0d6560..91ccdab8 100644
--- a/src/ui/keypair_details/KeyPairDetailTab.h
+++ b/src/ui/dialog/keypair_details/KeyPairDetailTab.h
@@ -29,9 +29,9 @@
#include "KeySetExpireDateDialog.h"
#include "core/GpgContext.h"
-#include "import_export/KeyServerImportDialog.h"
-#include "import_export/KeyUploadDialog.h"
#include "ui/GpgFrontendUI.h"
+#include "ui/dialog/import_export/KeyServerImportDialog.h"
+#include "ui/dialog/import_export/KeyUploadDialog.h"
namespace GpgFrontend::UI {
@@ -60,19 +60,19 @@ class KeyPairDetailTab : public QWidget {
private:
GpgKey key_; ///<
- QGroupBox* owner_box_; ///< Groupbox containing owner information
- QGroupBox* key_box_; ///< Groupbox containing key information
- QGroupBox* fingerprint_box_; ///< Groupbox containing fingerprint information
+ QGroupBox* owner_box_; ///< Groupbox containing owner information
+ QGroupBox* key_box_; ///< Groupbox containing key information
+ QGroupBox* fingerprint_box_; ///< Groupbox containing fingerprint information
QGroupBox* additional_uid_box_; ///< Groupbox containing information about
///< additional uids
- QLabel* name_var_label_; ///< Label containing the keys name
- QLabel* email_var_label_; ///< Label containing the keys email
- QLabel* comment_var_label_; ///< Label containing the keys comment
- QLabel* key_size_var_label_; ///< Label containing the keys key size
- QLabel* expire_var_label_; ///< Label containing the keys expiration date
- QLabel* created_var_label_; ///< Label containing the keys creation date
- QLabel* last_update_var_label_; ///<
+ QLabel* name_var_label_; ///< Label containing the keys name
+ QLabel* email_var_label_; ///< Label containing the keys email
+ QLabel* comment_var_label_; ///< Label containing the keys comment
+ QLabel* key_size_var_label_; ///< Label containing the keys key size
+ QLabel* expire_var_label_; ///< Label containing the keys expiration date
+ QLabel* created_var_label_; ///< Label containing the keys creation date
+ QLabel* last_update_var_label_; ///<
QLabel* algorithm_var_label_; ///< Label containing the keys algorithm
QLabel* key_id_var_label; ///< Label containing the keys keyid
QLabel* fingerprint_var_label_; ///< Label containing the keys fingerprint
diff --git a/src/ui/keypair_details/KeyPairOperaTab.cpp b/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp
index 4f7cd66f..77eba0bc 100644
--- a/src/ui/keypair_details/KeyPairOperaTab.cpp
+++ b/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp
@@ -26,12 +26,12 @@
#include "KeyPairOperaTab.h"
+#include "KeySetExpireDateDialog.h"
#include "core/function/gpg/GpgKeyImportExporter.h"
#include "core/function/gpg/GpgKeyOpera.h"
-#include "import_export/KeyUploadDialog.h"
#include "ui/SignalStation.h"
#include "ui/UserInterfaceUtils.h"
-#include "ui/keypair_details/KeySetExpireDateDialog.h"
+#include "ui/dialog/import_export/KeyUploadDialog.h"
namespace GpgFrontend::UI {
diff --git a/src/ui/keypair_details/KeyPairOperaTab.h b/src/ui/dialog/keypair_details/KeyPairOperaTab.h
index af6b1eee..af6b1eee 100644
--- a/src/ui/keypair_details/KeyPairOperaTab.h
+++ b/src/ui/dialog/keypair_details/KeyPairOperaTab.h
diff --git a/src/ui/keypair_details/KeyPairSubkeyTab.cpp b/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp
index 46de550c..fe1d0798 100644
--- a/src/ui/keypair_details/KeyPairSubkeyTab.cpp
+++ b/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp
@@ -26,7 +26,7 @@
*
*/
-#include "ui/keypair_details/KeyPairSubkeyTab.h"
+#include "KeyPairSubkeyTab.h"
#include "core/function/gpg/GpgKeyGetter.h"
#include "ui/SignalStation.h"
diff --git a/src/ui/keypair_details/KeyPairSubkeyTab.h b/src/ui/dialog/keypair_details/KeyPairSubkeyTab.h
index a64d143c..a93ebca5 100644
--- a/src/ui/keypair_details/KeyPairSubkeyTab.h
+++ b/src/ui/dialog/keypair_details/KeyPairSubkeyTab.h
@@ -32,7 +32,7 @@
#include "KeySetExpireDateDialog.h"
#include "core/GpgContext.h"
#include "ui/GpgFrontendUI.h"
-#include "ui/key_generate/SubkeyGenerateDialog.h"
+#include "ui/dialog/key_generate/SubkeyGenerateDialog.h"
namespace GpgFrontend::UI {
diff --git a/src/ui/keypair_details/KeyPairUIDTab.cpp b/src/ui/dialog/keypair_details/KeyPairUIDTab.cpp
index 4cc835a8..b923dbec 100644
--- a/src/ui/keypair_details/KeyPairUIDTab.cpp
+++ b/src/ui/dialog/keypair_details/KeyPairUIDTab.cpp
@@ -24,7 +24,7 @@
*
*/
-#include "ui/keypair_details/KeyPairUIDTab.h"
+#include "KeyPairUIDTab.h"
#include "core/function/gpg/GpgKeyGetter.h"
#include "core/function/gpg/GpgKeyManager.h"
diff --git a/src/ui/keypair_details/KeyPairUIDTab.h b/src/ui/dialog/keypair_details/KeyPairUIDTab.h
index fae8f9f2..fae8f9f2 100644
--- a/src/ui/keypair_details/KeyPairUIDTab.h
+++ b/src/ui/dialog/keypair_details/KeyPairUIDTab.h
diff --git a/src/ui/keypair_details/KeySetExpireDateDialog.cpp b/src/ui/dialog/keypair_details/KeySetExpireDateDialog.cpp
index f2ccc240..2c10b895 100644
--- a/src/ui/keypair_details/KeySetExpireDateDialog.cpp
+++ b/src/ui/dialog/keypair_details/KeySetExpireDateDialog.cpp
@@ -26,7 +26,7 @@
*
*/
-#include "ui/keypair_details/KeySetExpireDateDialog.h"
+#include "KeySetExpireDateDialog.h"
#include <utility>
@@ -40,7 +40,7 @@ namespace GpgFrontend::UI {
KeySetExpireDateDialog::KeySetExpireDateDialog(const KeyId& key_id,
QWidget* parent)
- : QDialog(parent),
+ : GeneralDialog(typeid(KeySetExpireDateDialog).name(), parent),
ui_(std::make_shared<Ui_ModifiedExpirationDateTime>()),
m_key_(GpgKeyGetter::GetInstance().GetKey(key_id)) {
init();
@@ -49,7 +49,7 @@ KeySetExpireDateDialog::KeySetExpireDateDialog(const KeyId& key_id,
KeySetExpireDateDialog::KeySetExpireDateDialog(const KeyId& key_id,
std::string subkey_fpr,
QWidget* parent)
- : QDialog(parent),
+ : GeneralDialog(typeid(KeySetExpireDateDialog).name(), parent),
ui_(std::make_shared<Ui_ModifiedExpirationDateTime>()),
m_key_(GpgKeyGetter::GetInstance().GetKey(key_id)),
m_subkey_(std::move(subkey_fpr)) {
diff --git a/src/ui/keypair_details/KeySetExpireDateDialog.h b/src/ui/dialog/keypair_details/KeySetExpireDateDialog.h
index 3c0b62f7..3cd6cd01 100644
--- a/src/ui/keypair_details/KeySetExpireDateDialog.h
+++ b/src/ui/dialog/keypair_details/KeySetExpireDateDialog.h
@@ -33,12 +33,13 @@
#include "core/model/GpgKey.h"
#include "core/model/GpgSubKey.h"
#include "ui/GpgFrontendUI.h"
+#include "ui/dialog/GeneralDialog.h"
class Ui_ModifiedExpirationDateTime;
namespace GpgFrontend::UI {
-class KeySetExpireDateDialog : public QDialog {
+class KeySetExpireDateDialog : public GeneralDialog {
Q_OBJECT
public:
/**
diff --git a/src/ui/keypair_details/KeyUIDSignDialog.cpp b/src/ui/dialog/keypair_details/KeyUIDSignDialog.cpp
index 2ed45512..0f7de587 100644
--- a/src/ui/keypair_details/KeyUIDSignDialog.cpp
+++ b/src/ui/dialog/keypair_details/KeyUIDSignDialog.cpp
@@ -24,7 +24,7 @@
*
*/
-#include "ui/keypair_details/KeyUIDSignDialog.h"
+#include "KeyUIDSignDialog.h"
#include "core/function/gpg/GpgKeyGetter.h"
#include "core/function/gpg/GpgKeyManager.h"
@@ -34,7 +34,9 @@ namespace GpgFrontend::UI {
KeyUIDSignDialog::KeyUIDSignDialog(const GpgKey& key, UIDArgsListPtr uid,
QWidget* parent)
- : QDialog(parent), m_uids_(std::move(uid)), m_key_(key) {
+ : GeneralDialog(typeid(KeyUIDSignDialog).name(), parent),
+ m_uids_(std::move(uid)),
+ m_key_(key) {
const auto key_id = m_key_.GetId();
m_key_list_ = new KeyList(KeyMenuAbility::NONE, this);
m_key_list_->AddListGroupTab(
diff --git a/src/ui/keypair_details/KeyUIDSignDialog.h b/src/ui/dialog/keypair_details/KeyUIDSignDialog.h
index 7c1cb58c..bfaff6d2 100644
--- a/src/ui/keypair_details/KeyUIDSignDialog.h
+++ b/src/ui/dialog/keypair_details/KeyUIDSignDialog.h
@@ -29,11 +29,12 @@
#include "core/GpgContext.h"
#include "ui/GpgFrontendUI.h"
+#include "ui/dialog/GeneralDialog.h"
#include "ui/widgets/KeyList.h"
namespace GpgFrontend::UI {
-class KeyUIDSignDialog : public QDialog {
+class KeyUIDSignDialog : public GeneralDialog {
Q_OBJECT
public:
diff --git a/src/ui/settings/SettingsAdvanced.cpp b/src/ui/dialog/settings/SettingsAdvanced.cpp
index 516d4d02..516d4d02 100644
--- a/src/ui/settings/SettingsAdvanced.cpp
+++ b/src/ui/dialog/settings/SettingsAdvanced.cpp
diff --git a/src/ui/settings/SettingsAdvanced.h b/src/ui/dialog/settings/SettingsAdvanced.h
index c1a3d5a6..c1a3d5a6 100644
--- a/src/ui/settings/SettingsAdvanced.h
+++ b/src/ui/dialog/settings/SettingsAdvanced.h
diff --git a/src/ui/settings/SettingsAppearance.cpp b/src/ui/dialog/settings/SettingsAppearance.cpp
index 7e54c9f8..17471a0d 100644
--- a/src/ui/settings/SettingsAppearance.cpp
+++ b/src/ui/dialog/settings/SettingsAppearance.cpp
@@ -114,11 +114,10 @@ AppearanceTab::AppearanceTab(QWidget* parent) : QWidget(parent) {
* appropriately
**********************************/
void AppearanceTab::SetSettings() {
+ SettingsObject general_settings_state("general_settings_state");
- SettingsObject main_windows_state("main_windows_state");
-
- int width = main_windows_state.Check("icon_size").Check("width", 24),
- height = main_windows_state.Check("icon_size").Check("height", 24);
+ int width = general_settings_state.Check("icon_size").Check("width", 24),
+ height = general_settings_state.Check("icon_size").Check("height", 24);
auto icon_size = QSize(width, height);
@@ -136,7 +135,7 @@ void AppearanceTab::SetSettings() {
// icon_style
int s_icon_style =
- main_windows_state.Check("icon_style", Qt::ToolButtonTextUnderIcon);
+ general_settings_state.Check("icon_style", Qt::ToolButtonTextUnderIcon);
auto icon_style = static_cast<Qt::ToolButtonStyle>(s_icon_style);
switch (icon_style) {
@@ -153,10 +152,10 @@ void AppearanceTab::SetSettings() {
break;
}
- bool window_save = main_windows_state.Check("window_save", true);
+ bool window_save = general_settings_state.Check("window_save", true);
if (window_save) window_size_check_box_->setCheckState(Qt::Checked);
- auto info_font_size = main_windows_state.Check("info_font_size", 10);
+ auto info_font_size = general_settings_state.Check("font_size", 10);
if (info_font_size < 9 || info_font_size > 18) info_font_size = 10;
info_board_font_size_spin_->setValue(info_font_size);
}
@@ -167,7 +166,7 @@ void AppearanceTab::SetSettings() {
*************************************/
void AppearanceTab::ApplySettings() {
- SettingsObject main_windows_state("main_windows_state");
+ SettingsObject general_settings_state("general_settings_state");
int icon_size = 24;
switch (icon_size_group_->checkedId()) {
@@ -182,8 +181,8 @@ void AppearanceTab::ApplySettings() {
break;
}
- main_windows_state["icon_size"]["width"] = icon_size;
- main_windows_state["icon_size"]["height"] = icon_size;
+ general_settings_state["icon_size"]["width"] = icon_size;
+ general_settings_state["icon_size"]["height"] = icon_size;
auto icon_style = Qt::ToolButtonTextUnderIcon;
switch (icon_style_group_->checkedId()) {
@@ -198,12 +197,11 @@ void AppearanceTab::ApplySettings() {
break;
}
- main_windows_state["icon_style"] = icon_style;
-
- main_windows_state["window_save"] = window_size_check_box_->isChecked();
+ general_settings_state["icon_style"] = icon_style;
- main_windows_state["info_font_size"] = info_board_font_size_spin_->value();
+ general_settings_state["window_save"] = window_size_check_box_->isChecked();
+ general_settings_state["info_font_size"] = info_board_font_size_spin_->value();
}
} // namespace GpgFrontend::UI
diff --git a/src/ui/settings/SettingsAppearance.h b/src/ui/dialog/settings/SettingsAppearance.h
index 7110d992..7110d992 100644
--- a/src/ui/settings/SettingsAppearance.h
+++ b/src/ui/dialog/settings/SettingsAppearance.h
diff --git a/src/ui/settings/SettingsDialog.cpp b/src/ui/dialog/settings/SettingsDialog.cpp
index eefdd3c7..e2677a0f 100644
--- a/src/ui/settings/SettingsDialog.cpp
+++ b/src/ui/dialog/settings/SettingsDialog.cpp
@@ -28,17 +28,18 @@
#include "SettingsDialog.h"
+#include "SettingsAdvanced.h"
+#include "SettingsAppearance.h"
+#include "SettingsGeneral.h"
+#include "SettingsKeyServer.h"
+#include "SettingsNetwork.h"
#include "core/function/GlobalSettingStation.h"
#include "ui/main_window/MainWindow.h"
-#include "ui/settings/SettingsAdvanced.h"
-#include "ui/settings/SettingsAppearance.h"
-#include "ui/settings/SettingsGeneral.h"
-#include "ui/settings/SettingsKeyServer.h"
-#include "ui/settings/SettingsNetwork.h"
namespace GpgFrontend::UI {
-SettingsDialog::SettingsDialog(QWidget* parent) : QDialog(parent) {
+SettingsDialog::SettingsDialog(QWidget* parent)
+ : GeneralDialog(typeid(SettingsDialog).name(), parent) {
tab_widget_ = new QTabWidget();
general_tab_ = new GeneralTab();
appearance_tab_ = new AppearanceTab();
diff --git a/src/ui/settings/SettingsDialog.h b/src/ui/dialog/settings/SettingsDialog.h
index e123cc6c..172370d0 100755..100644
--- a/src/ui/settings/SettingsDialog.h
+++ b/src/ui/dialog/settings/SettingsDialog.h
@@ -30,6 +30,7 @@
#define __SETTINGSDIALOG_H__
#include "ui/GpgFrontendUI.h"
+#include "ui/dialog/GeneralDialog.h"
#include "ui/widgets/KeyList.h"
namespace GpgFrontend::UI {
@@ -43,7 +44,7 @@ class NetworkTab;
* @brief
*
*/
-class SettingsDialog : public QDialog {
+class SettingsDialog : public GeneralDialog {
Q_OBJECT
public:
@@ -54,7 +55,7 @@ class SettingsDialog : public QDialog {
*/
explicit SettingsDialog(QWidget* parent = nullptr);
- GeneralTab* general_tab_; ///<
+ GeneralTab* general_tab_; ///<
AppearanceTab* appearance_tab_; ///<
KeyserverTab* key_server_tab_; ///<
NetworkTab* network_tab_; ///<
diff --git a/src/ui/settings/SettingsGeneral.cpp b/src/ui/dialog/settings/SettingsGeneral.cpp
index 3c7bca32..3c7bca32 100644
--- a/src/ui/settings/SettingsGeneral.cpp
+++ b/src/ui/dialog/settings/SettingsGeneral.cpp
diff --git a/src/ui/settings/SettingsGeneral.h b/src/ui/dialog/settings/SettingsGeneral.h
index b3e7d904..b3e7d904 100644
--- a/src/ui/settings/SettingsGeneral.h
+++ b/src/ui/dialog/settings/SettingsGeneral.h
diff --git a/src/ui/settings/SettingsKeyServer.cpp b/src/ui/dialog/settings/SettingsKeyServer.cpp
index 94655871..2c09b66c 100644
--- a/src/ui/settings/SettingsKeyServer.cpp
+++ b/src/ui/dialog/settings/SettingsKeyServer.cpp
@@ -120,23 +120,30 @@ KeyserverTab::KeyserverTab(QWidget* parent)
* appropriately
**********************************/
void KeyserverTab::SetSettings() {
- SettingsObject key_server_json("key_server");
-
- const auto key_server_list =
- key_server_json.Check("server_list", nlohmann::json::array());
+ try {
+ SettingsObject key_server_json("key_server");
- for (const auto& key_server : key_server_list) {
- const auto key_server_str = key_server.get<std::string>();
- this->key_server_str_list_.append(key_server_str.c_str());
- }
+ const auto key_server_list =
+ key_server_json.Check("server_list", nlohmann::json::array());
- int default_key_server_index = key_server_json.Check("default_server", 0);
- std::string default_key_server =
- key_server_list[default_key_server_index].get<std::string>();
+ for (const auto& key_server : key_server_list) {
+ const auto key_server_str = key_server.get<std::string>();
+ this->key_server_str_list_.append(key_server_str.c_str());
+ }
- if (!key_server_str_list_.contains(default_key_server.c_str()))
- key_server_str_list_.append(default_key_server.c_str());
- default_key_server_ = QString::fromStdString(default_key_server);
+ int default_key_server_index = key_server_json.Check("default_server", 0);
+ if (default_key_server_index >= key_server_list.size()) {
+ throw std::runtime_error("default_server index out of range");
+ }
+ std::string default_key_server =
+ key_server_list[default_key_server_index].get<std::string>();
+
+ if (!key_server_str_list_.contains(default_key_server.c_str()))
+ key_server_str_list_.append(default_key_server.c_str());
+ default_key_server_ = QString::fromStdString(default_key_server);
+ } catch (const std::exception& e) {
+ LOG(ERROR) << "Error reading key-server settings: " << e.what();
+ }
}
void KeyserverTab::slot_add_key_server() {
diff --git a/src/ui/settings/SettingsKeyServer.h b/src/ui/dialog/settings/SettingsKeyServer.h
index f983e69b..f983e69b 100644
--- a/src/ui/settings/SettingsKeyServer.h
+++ b/src/ui/dialog/settings/SettingsKeyServer.h
diff --git a/src/ui/settings/SettingsNetwork.cpp b/src/ui/dialog/settings/SettingsNetwork.cpp
index d4edae42..d4edae42 100644
--- a/src/ui/settings/SettingsNetwork.cpp
+++ b/src/ui/dialog/settings/SettingsNetwork.cpp
diff --git a/src/ui/settings/SettingsNetwork.h b/src/ui/dialog/settings/SettingsNetwork.h
index d4c0d00d..d4c0d00d 100644
--- a/src/ui/settings/SettingsNetwork.h
+++ b/src/ui/dialog/settings/SettingsNetwork.h