aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2022-07-22 17:21:48 +0000
committerSaturneric <[email protected]>2022-07-22 17:21:48 +0000
commit8729378555af829cdb5ac1f0ab4b0dedff613644 (patch)
tree94ea60e78e3128c85429ac8f7b63fd7006beb96d
parentfix: fix some issues (diff)
downloadGpgFrontend-8729378555af829cdb5ac1f0ab4b0dedff613644.tar.gz
GpgFrontend-8729378555af829cdb5ac1f0ab4b0dedff613644.zip
feat(ui): use general main window and dialog class
1. store window size and position 2. store icon size and style
-rw-r--r--src/ui/GpgFrontendApplication.cpp1
-rw-r--r--src/ui/dialog/GeneralDialog.cpp87
-rw-r--r--src/ui/dialog/GeneralDialog.h69
-rwxr-xr-xsrc/ui/dialog/QuitDialog.cpp4
-rwxr-xr-xsrc/ui/dialog/QuitDialog.h3
-rw-r--r--src/ui/dialog/Wizard.h2
-rw-r--r--src/ui/help/AboutDialog.cpp3
-rw-r--r--src/ui/help/AboutDialog.h3
-rw-r--r--src/ui/import_export/ExportKeyPackageDialog.cpp2
-rw-r--r--src/ui/import_export/ExportKeyPackageDialog.h3
-rw-r--r--src/ui/import_export/KeyImportDetailDialog.cpp6
-rw-r--r--src/ui/import_export/KeyImportDetailDialog.h3
-rw-r--r--src/ui/import_export/KeyServerImportDialog.cpp101
-rw-r--r--src/ui/import_export/KeyServerImportDialog.h9
-rw-r--r--src/ui/import_export/KeyUploadDialog.cpp8
-rw-r--r--src/ui/import_export/KeyUploadDialog.h3
-rw-r--r--src/ui/key_generate/KeygenDialog.cpp2
-rw-r--r--src/ui/key_generate/KeygenDialog.h3
-rw-r--r--src/ui/key_generate/SubkeyGenerateDialog.cpp3
-rw-r--r--src/ui/key_generate/SubkeyGenerateDialog.h3
-rw-r--r--src/ui/keypair_details/KeyDetailsDialog.cpp2
-rw-r--r--src/ui/keypair_details/KeyDetailsDialog.h3
-rw-r--r--src/ui/keypair_details/KeyNewUIDDialog.cpp12
-rw-r--r--src/ui/keypair_details/KeyNewUIDDialog.h3
-rw-r--r--src/ui/keypair_details/KeySetExpireDateDialog.cpp4
-rw-r--r--src/ui/keypair_details/KeySetExpireDateDialog.h3
-rw-r--r--src/ui/keypair_details/KeyUIDSignDialog.cpp4
-rw-r--r--src/ui/keypair_details/KeyUIDSignDialog.h3
-rw-r--r--src/ui/main_window/GeneralMainWindow.cpp126
-rw-r--r--src/ui/main_window/GeneralMainWindow.h80
-rw-r--r--[-rwxr-xr-x]src/ui/main_window/KeyMgmt.cpp (renamed from src/ui/KeyMgmt.cpp)111
-rw-r--r--[-rwxr-xr-x]src/ui/main_window/KeyMgmt.h (renamed from src/ui/KeyMgmt.h)16
-rw-r--r--src/ui/main_window/MainWindow.cpp58
-rw-r--r--src/ui/main_window/MainWindow.h9
-rw-r--r--src/ui/settings/SettingsDialog.cpp3
-rwxr-xr-xsrc/ui/settings/SettingsDialog.h3
36 files changed, 464 insertions, 294 deletions
diff --git a/src/ui/GpgFrontendApplication.cpp b/src/ui/GpgFrontendApplication.cpp
index 57b36152..2045746f 100644
--- a/src/ui/GpgFrontendApplication.cpp
+++ b/src/ui/GpgFrontendApplication.cpp
@@ -65,7 +65,6 @@ GpgFrontendApplication *GpgFrontendApplication::GetInstance(int argc,
if (instance != nullptr) {
instance->quit();
delete instance;
- } else {
}
instance = new GpgFrontendApplication(static_argc, static_argv);
}
diff --git a/src/ui/dialog/GeneralDialog.cpp b/src/ui/dialog/GeneralDialog.cpp
new file mode 100644
index 00000000..457aa142
--- /dev/null
+++ b/src/ui/dialog/GeneralDialog.cpp
@@ -0,0 +1,87 @@
+/*
+ * 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);
+
+ auto pos = QPoint(x, y);
+
+ int width =
+ general_windows_state.Check("window_size").Check("width", 800),
+ height =
+ general_windows_state.Check("window_size").Check("height", 450);
+
+ auto size = QSize(width, height);
+ this->resize(size);
+ this->move(pos);
+ }
+
+ } 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..e401de85
--- /dev/null
+++ b/src/ui/dialog/GeneralDialog.h
@@ -0,0 +1,69 @@
+/*
+ * 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_; ///<
+
+};
+}
+
+
+
+#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..82a97cd4 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/dialog/Wizard.h b/src/ui/dialog/Wizard.h
index eb093550..8f418ed1 100644
--- a/src/ui/dialog/Wizard.h
+++ b/src/ui/dialog/Wizard.h
@@ -31,7 +31,7 @@
#include "core/GpgConstants.h"
#include "ui/GpgFrontendUI.h"
-#include "ui/KeyMgmt.h"
+#include "main_window/KeyMgmt.h"
#include "ui/key_generate/KeygenDialog.h"
#include "ui/settings/SettingsDialog.h"
diff --git a/src/ui/help/AboutDialog.cpp b/src/ui/help/AboutDialog.cpp
index e8fbeb1b..16f68958 100644
--- a/src/ui/help/AboutDialog.cpp
+++ b/src/ui/help/AboutDialog.cpp
@@ -35,7 +35,8 @@
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;
diff --git a/src/ui/help/AboutDialog.h b/src/ui/help/AboutDialog.h
index 40d93f3e..09a63734 100644
--- a/src/ui/help/AboutDialog.h
+++ b/src/ui/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/import_export/ExportKeyPackageDialog.cpp b/src/ui/import_export/ExportKeyPackageDialog.cpp
index d6f303f6..357812c0 100644
--- a/src/ui/import_export/ExportKeyPackageDialog.cpp
+++ b/src/ui/import_export/ExportKeyPackageDialog.cpp
@@ -36,7 +36,7 @@
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);
diff --git a/src/ui/import_export/ExportKeyPackageDialog.h b/src/ui/import_export/ExportKeyPackageDialog.h
index ecf13b1d..c5f9a2b1 100644
--- a/src/ui/import_export/ExportKeyPackageDialog.h
+++ b/src/ui/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/import_export/KeyImportDetailDialog.cpp
index 766d2d81..31183a34 100644
--- a/src/ui/import_export/KeyImportDetailDialog.cpp
+++ b/src/ui/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/import_export/KeyImportDetailDialog.h
index a648f205..06f44e94 100644
--- a/src/ui/import_export/KeyImportDetailDialog.h
+++ b/src/ui/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/import_export/KeyServerImportDialog.cpp
index 3a61dbbe..6430a22e 100644
--- a/src/ui/import_export/KeyServerImportDialog.cpp
+++ b/src/ui/import_export/KeyServerImportDialog.cpp
@@ -41,7 +41,8 @@
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();
@@ -118,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);
@@ -155,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);
- // save window pos and size to configure file
- connect(this, &KeyServerImportDialog::finished, this,
- &KeyServerImportDialog::slot_save_window_state);
+ // 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);
}
QComboBox* KeyServerImportDialog::create_comboBox() {
@@ -555,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/import_export/KeyServerImportDialog.h
index 6bde96b8..fd912bdd 100644
--- a/src/ui/import_export/KeyServerImportDialog.h
+++ b/src/ui/import_export/KeyServerImportDialog.h
@@ -34,6 +34,7 @@
#include "KeyImportDetailDialog.h"
#include "core/GpgContext.h"
#include "ui/GpgFrontendUI.h"
+#include "ui/dialog/GeneralDialog.h"
#include "ui/widgets/KeyList.h"
namespace GpgFrontend::UI {
@@ -42,7 +43,7 @@ namespace GpgFrontend::UI {
* @brief
*
*/
-class KeyServerImportDialog : public QDialog {
+class KeyServerImportDialog : public GeneralDialog {
Q_OBJECT
public:
@@ -116,12 +117,6 @@ class KeyServerImportDialog : public QDialog {
*/
void slot_search();
- /**
- * @brief
- *
- */
- void slot_save_window_state();
-
private:
/**
* @brief Create a keys table object
diff --git a/src/ui/import_export/KeyUploadDialog.cpp b/src/ui/import_export/KeyUploadDialog.cpp
index a0436a8e..055f2e1f 100644
--- a/src/ui/import_export/KeyUploadDialog.cpp
+++ b/src/ui/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/import_export/KeyUploadDialog.h
index 05cba083..d621f33a 100644
--- a/src/ui/import_export/KeyUploadDialog.h
+++ b/src/ui/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/key_generate/KeygenDialog.cpp
index d5ca801d..1295a7ac 100644
--- a/src/ui/key_generate/KeygenDialog.cpp
+++ b/src/ui/key_generate/KeygenDialog.cpp
@@ -35,7 +35,7 @@
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/key_generate/KeygenDialog.h
index 751ebdd8..baf10dbf 100644
--- a/src/ui/key_generate/KeygenDialog.h
+++ b/src/ui/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/key_generate/SubkeyGenerateDialog.cpp
index 2b9e076d..5aa70825 100644
--- a/src/ui/key_generate/SubkeyGenerateDialog.cpp
+++ b/src/ui/key_generate/SubkeyGenerateDialog.cpp
@@ -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/key_generate/SubkeyGenerateDialog.h
index 4ab90ad4..1e6608b2 100644
--- a/src/ui/key_generate/SubkeyGenerateDialog.h
+++ b/src/ui/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/keypair_details/KeyDetailsDialog.cpp
index 3b3e8818..dc3df9d4 100644
--- a/src/ui/keypair_details/KeyDetailsDialog.cpp
+++ b/src/ui/keypair_details/KeyDetailsDialog.cpp
@@ -35,7 +35,7 @@
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/keypair_details/KeyDetailsDialog.h
index e6f4472c..1ddcda00 100644
--- a/src/ui/keypair_details/KeyDetailsDialog.h
+++ b/src/ui/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/keypair_details/KeyNewUIDDialog.cpp
index 9ff73f9e..5b286603 100644
--- a/src/ui/keypair_details/KeyNewUIDDialog.cpp
+++ b/src/ui/keypair_details/KeyNewUIDDialog.cpp
@@ -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/keypair_details/KeyNewUIDDialog.h
index 24f2c6b1..291b59c4 100644
--- a/src/ui/keypair_details/KeyNewUIDDialog.h
+++ b/src/ui/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/KeySetExpireDateDialog.cpp b/src/ui/keypair_details/KeySetExpireDateDialog.cpp
index f2ccc240..1f28736f 100644
--- a/src/ui/keypair_details/KeySetExpireDateDialog.cpp
+++ b/src/ui/keypair_details/KeySetExpireDateDialog.cpp
@@ -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/keypair_details/KeySetExpireDateDialog.h
index 3c0b62f7..3cd6cd01 100644
--- a/src/ui/keypair_details/KeySetExpireDateDialog.h
+++ b/src/ui/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/keypair_details/KeyUIDSignDialog.cpp
index 2ed45512..b1845501 100644
--- a/src/ui/keypair_details/KeyUIDSignDialog.cpp
+++ b/src/ui/keypair_details/KeyUIDSignDialog.cpp
@@ -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/keypair_details/KeyUIDSignDialog.h
index 7c1cb58c..d64ce57c 100644
--- a/src/ui/keypair_details/KeyUIDSignDialog.h
+++ b/src/ui/keypair_details/KeyUIDSignDialog.h
@@ -30,10 +30,11 @@
#include "core/GpgContext.h"
#include "ui/GpgFrontendUI.h"
#include "ui/widgets/KeyList.h"
+#include "ui/dialog/GeneralDialog.h"
namespace GpgFrontend::UI {
-class KeyUIDSignDialog : public QDialog {
+class KeyUIDSignDialog : public GeneralDialog {
Q_OBJECT
public:
diff --git a/src/ui/main_window/GeneralMainWindow.cpp b/src/ui/main_window/GeneralMainWindow.cpp
new file mode 100644
index 00000000..d7d93c3d
--- /dev/null
+++ b/src/ui/main_window/GeneralMainWindow.cpp
@@ -0,0 +1,126 @@
+/**
+ * Copyright (C) 2021 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 "GeneralMainWindow.h"
+
+#include <utility>
+
+#include "ui/struct/SettingsObject.h"
+
+GpgFrontend::UI::GeneralMainWindow::GeneralMainWindow(std::string name,
+ QWidget* parent)
+ : name_(std::move(name)), QMainWindow(parent) {
+ slot_restore_settings();
+}
+
+GpgFrontend::UI::GeneralMainWindow::~GeneralMainWindow() = default;
+
+void GpgFrontend::UI::GeneralMainWindow::closeEvent(QCloseEvent* event) {
+ slot_save_settings();
+ QMainWindow::closeEvent(event);
+}
+
+void GpgFrontend::UI::GeneralMainWindow::slot_restore_settings() noexcept {
+ try {
+ LOG(INFO) << name_ << _("Called");
+
+ SettingsObject general_windows_state(name_ + "_state");
+
+ std::string window_state = general_windows_state.Check(
+ "window_state", saveState().toBase64().toStdString());
+
+ // state sets pos & size of dock-widgets
+ this->restoreState(
+ QByteArray::fromBase64(QByteArray::fromStdString(window_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);
+
+ auto pos = QPoint(x, y);
+
+ int width =
+ general_windows_state.Check("window_size").Check("width", 800),
+ height =
+ general_windows_state.Check("window_size").Check("height", 450);
+
+ auto size = QSize(width, height);
+ this->resize(size);
+ this->move(pos);
+ }
+
+ int width = general_windows_state.Check("icon_size").Check("width", 24),
+ height = general_windows_state.Check("icon_size").Check("height", 24);
+ LOG(INFO) << "icon_size" << width << height;
+
+ icon_size_ = {width, height};
+ font_size_ = general_windows_state.Check("font_size", 10);
+
+ this->setIconSize(icon_size_);
+
+ // icon_style
+ int s_icon_style =
+ general_windows_state.Check("icon_style", Qt::ToolButtonTextUnderIcon);
+ auto icon_style = static_cast<Qt::ToolButtonStyle>(s_icon_style);
+ this->setToolButtonStyle(icon_style);
+
+ } catch (...) {
+ LOG(ERROR) << name_ << "error";
+ }
+}
+
+void GpgFrontend::UI::GeneralMainWindow::slot_save_settings() noexcept {
+ try {
+ LOG(INFO) << name_ << _("Called");
+
+ SettingsObject general_windows_state(name_ + "_state");
+
+ // window position and size
+ general_windows_state["window_state"] =
+ saveState().toBase64().toStdString();
+ 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;
+
+ // icon size
+ general_windows_state["icon_size"]["width"] = icon_size_.width();
+ general_windows_state["icon_size"]["height"] = icon_size_.height();
+
+ // font size
+ general_windows_state["font_size"] = font_size_;
+
+ } catch (...) {
+ LOG(ERROR) << name_ << "error";
+ }
+}
diff --git a/src/ui/main_window/GeneralMainWindow.h b/src/ui/main_window/GeneralMainWindow.h
new file mode 100644
index 00000000..143096bb
--- /dev/null
+++ b/src/ui/main_window/GeneralMainWindow.h
@@ -0,0 +1,80 @@
+/**
+ * Copyright (C) 2021 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_GENERALMAINWINDOW_H
+#define GPGFRONTEND_GENERALMAINWINDOW_H
+
+#include "ui/GpgFrontendUI.h"
+
+namespace GpgFrontend::UI {
+
+/**
+ *
+ */
+class GeneralMainWindow : public QMainWindow {
+ public:
+ /**
+ *
+ * @param name
+ */
+ explicit GeneralMainWindow(std::string name, QWidget* parent = nullptr);
+
+ /**
+ *
+ */
+ ~GeneralMainWindow() override;
+
+ protected:
+
+ /**
+ *
+ * @param event
+ */
+ void closeEvent(QCloseEvent* event);
+
+ QSize icon_size_{}; ///<
+ int font_size_{}; ///<
+
+ private slots:
+ /**
+ *
+ */
+ void slot_restore_settings() noexcept;
+
+ /**
+ *
+ */
+ void slot_save_settings() noexcept;
+
+ private:
+
+ std::string name_; ///<
+};
+} // namespace GpgFrontend::UI
+
+#endif // GPGFRONTEND_GENERALMAINWINDOW_H
diff --git a/src/ui/KeyMgmt.cpp b/src/ui/main_window/KeyMgmt.cpp
index 30bc8a1b..dd0f4dd0 100755..100644
--- a/src/ui/KeyMgmt.cpp
+++ b/src/ui/main_window/KeyMgmt.cpp
@@ -26,24 +26,26 @@
*
*/
-#include "ui/KeyMgmt.h"
+#include "KeyMgmt.h"
#include <utility>
+#include "core/function/GlobalSettingStation.h"
+#include "core/function/KeyPackageOperator.h"
#include "core/function/gpg/GpgKeyGetter.h"
#include "core/function/gpg/GpgKeyImportExporter.h"
#include "core/function/gpg/GpgKeyOpera.h"
-#include "core/function/KeyPackageOperator.h"
#include "ui/SignalStation.h"
#include "ui/UserInterfaceUtils.h"
#include "ui/import_export/ExportKeyPackageDialog.h"
#include "ui/key_generate/SubkeyGenerateDialog.h"
#include "ui/main_window/MainWindow.h"
-#include "core/function/GlobalSettingStation.h"
namespace GpgFrontend::UI {
-KeyMgmt::KeyMgmt(QWidget* parent) : QMainWindow(parent) {
+KeyMgmt::KeyMgmt(QWidget* parent)
+ : GeneralMainWindow("key_management", parent) {
+
/* the list of Keys available*/
key_list_ = new KeyList(KeyMenuAbility::ALL, this);
@@ -105,53 +107,6 @@ KeyMgmt::KeyMgmt(QWidget* parent) : QMainWindow(parent) {
auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
- try {
- int width = settings.lookup("window.icon_size.width");
- int height = settings.lookup("window.icon_size.height");
-
- this->setIconSize(QSize(width, height));
-
- } catch (...) {
- LOG(ERROR) << _("Setting Operation Error") << _("icon_size");
- }
-
- // icon_style
- try {
- int s_icon_style = settings.lookup("window.icon_style");
- auto icon_style = static_cast<Qt::ToolButtonStyle>(s_icon_style);
- this->setToolButtonStyle(icon_style);
- } catch (...) {
- LOG(ERROR) << _("Setting Operation Error") << _("icon_style");
- }
-
- auto pos = QPoint(50, 50);
- LOG(INFO) << "parent" << parent;
- if (parent) pos += parent->pos();
- LOG(INFO) << "pos default" << pos.x() << pos.y();
- auto size = QSize(900, 600);
-
- try {
- int x, y, width, height;
- x = settings.lookup("window.key_management.position.x");
- y = settings.lookup("window.key_management.position.y");
- width = settings.lookup("window.key_management.size.width");
- height = settings.lookup("window.key_management.size.height");
- pos = QPoint(x, y);
- size = QSize(width, height);
-
- std::string window_state =
- settings.lookup("window.key_management.window_state");
-
- // state sets pos & size of dock-widgets
- this->restoreState(
- QByteArray::fromBase64(QByteArray::fromStdString(window_state)));
-
- } catch (...) {
- LOG(WARNING) << "cannot read pos or size from settings";
- }
-
- this->resize(size);
- this->move(pos);
this->statusBar()->show();
setWindowTitle(_("KeyPair Management"));
@@ -406,10 +361,6 @@ void KeyMgmt::SlotGenerateKeyDialog() {
keyGenDialog->show();
}
-void KeyMgmt::closeEvent(QCloseEvent* event) {
- SlotSaveWindowState();
- QMainWindow::closeEvent(event);
-}
void KeyMgmt::SlotGenerateSubKey() {
auto keys_selected = key_list_->GetSelected();
@@ -434,52 +385,6 @@ void KeyMgmt::SlotGenerateSubKey() {
auto dialog = new SubkeyGenerateDialog(key.GetId(), this);
dialog->show();
}
-void KeyMgmt::SlotSaveWindowState() {
- auto& settings =
- GpgFrontend::GlobalSettingStation::GetInstance().GetUISettings();
-
- if (!settings.exists("window") ||
- settings.lookup("window").getType() != libconfig::Setting::TypeGroup)
- settings.add("window", libconfig::Setting::TypeGroup);
-
- auto& window = settings["window"];
-
- if (!window.exists("key_management") ||
- window.lookup("key_management").getType() !=
- libconfig::Setting::TypeGroup)
- window.add("key_management", libconfig::Setting::TypeGroup);
-
- auto& key_management = window["key_management"];
-
- if (!key_management.exists("position") ||
- key_management.lookup("position").getType() !=
- libconfig::Setting::TypeGroup) {
- auto& position =
- key_management.add("position", libconfig::Setting::TypeGroup);
- position.add("x", libconfig::Setting::TypeInt) = pos().x();
- position.add("y", libconfig::Setting::TypeInt) = pos().y();
- } else {
- key_management["position"]["x"] = pos().x();
- key_management["position"]["y"] = pos().y();
- }
-
- if (!key_management.exists("size") ||
- key_management.lookup("size").getType() !=
- libconfig::Setting::TypeGroup) {
- auto& size = key_management.add("size", libconfig::Setting::TypeGroup);
- size.add("width", libconfig::Setting::TypeInt) = QWidget::width();
- size.add("height", libconfig::Setting::TypeInt) = QWidget::height();
- } else {
- key_management["size"]["width"] = QWidget::width();
- key_management["size"]["height"] = QWidget::height();
- }
-
- if (!key_management.exists("window_state"))
- key_management.add("window_state", libconfig::Setting::TypeString) =
- saveState().toBase64().toStdString();
-
- GlobalSettingStation::GetInstance().SyncSettings();
-}
void KeyMgmt::SlotExportAsOpenSSHFormat() {
ByteArrayPtr key_export_data = nullptr;
@@ -527,7 +432,6 @@ void KeyMgmt::SlotExportAsOpenSSHFormat() {
}
void KeyMgmt::SlotImportKeyPackage() {
-
LOG(INFO) << "Importing key package...";
auto key_package_file_name = QFileDialog::getOpenFileName(
@@ -538,8 +442,7 @@ void KeyMgmt::SlotImportKeyPackage() {
this, _("Import Key Package Passphrase File"), {},
QString(_("Key Package Passphrase File")) + " (*.key);;All Files (*)");
- if(key_package_file_name.isEmpty() || key_file_name.isEmpty())
- return;
+ if (key_package_file_name.isEmpty() || key_file_name.isEmpty()) return;
GpgImportInformation info;
diff --git a/src/ui/KeyMgmt.h b/src/ui/main_window/KeyMgmt.h
index 25ee80c5..06ad0c1b 100755..100644
--- a/src/ui/KeyMgmt.h
+++ b/src/ui/main_window/KeyMgmt.h
@@ -35,6 +35,7 @@
#include "ui/key_generate/KeygenDialog.h"
#include "ui/keypair_details/KeyDetailsDialog.h"
#include "ui/widgets/KeyList.h"
+#include "ui/main_window/GeneralMainWindow.h"
namespace GpgFrontend::UI {
@@ -42,7 +43,7 @@ namespace GpgFrontend::UI {
* @brief
*
*/
-class KeyMgmt : public QMainWindow {
+class KeyMgmt : public GeneralMainWindow {
Q_OBJECT
public:
@@ -107,12 +108,6 @@ class KeyMgmt : public QMainWindow {
* @brief
*
*/
- void SlotSaveWindowState();
-
- /**
- * @brief
- *
- */
void SlotImportKeyPackage();
signals:
@@ -177,13 +172,6 @@ class KeyMgmt : public QMainWindow {
QAction* show_key_details_act_{}; ///<
KeyServerImportDialog* import_dialog_{}; ///<
- protected:
- /**
- * @brief
- *
- * @param event
- */
- void closeEvent(QCloseEvent* event) override;
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/main_window/MainWindow.cpp b/src/ui/main_window/MainWindow.cpp
index e6da65d2..949e394f 100644
--- a/src/ui/main_window/MainWindow.cpp
+++ b/src/ui/main_window/MainWindow.cpp
@@ -36,7 +36,7 @@
namespace GpgFrontend::UI {
-MainWindow::MainWindow() {
+MainWindow::MainWindow(): GeneralMainWindow("main_window") {
this->setMinimumSize(1200, 700);
this->setWindowTitle(qApp->applicationName());
}
@@ -135,52 +135,6 @@ void MainWindow::restore_settings() {
LOG(INFO) << _("Called");
try {
- LOG(INFO) << "restore settings main_windows_state";
-
- SettingsObject main_windows_state("main_windows_state");
-
- std::string window_state = main_windows_state.Check(
- "window_state", saveState().toBase64().toStdString());
- // state sets pos & size of dock-widgets
- this->restoreState(
- QByteArray::fromBase64(QByteArray::fromStdString(window_state)));
-
- bool window_save = main_windows_state.Check("window_save", true);
-
- // Restore window size & location
- if (window_save) {
- int x = main_windows_state.Check("window_pos").Check("x", 100),
- y = main_windows_state.Check("window_pos").Check("y", 100);
-
- auto pos = QPoint(x, y);
-
- int width = main_windows_state.Check("window_size").Check("width", 800),
- height = main_windows_state.Check("window_size").Check("height", 450);
-
- auto size = QSize(width, height);
- this->resize(size);
- this->move(pos);
- } else {
- this->resize(QSize(800, 450));
- this->move(QPoint(100, 100));
- }
-
- int width = main_windows_state.Check("icon_size").Check("width", 24),
- height = main_windows_state.Check("icon_size").Check("height", 24);
- LOG(INFO) << "icon_size" << width << height;
-
- main_windows_state.Check("info_font_size", 10);
-
- // icon_style
- int s_icon_style =
- main_windows_state.Check("icon_style", Qt::ToolButtonTextUnderIcon);
- auto icon_style = static_cast<Qt::ToolButtonStyle>(s_icon_style);
- this->setToolButtonStyle(icon_style);
- import_button_->setToolButtonStyle(icon_style);
-
- // icons ize
- this->setIconSize(QSize(width, height));
- import_button_->setIconSize(QSize(width, height));
LOG(INFO) << "restore settings key_server";
@@ -253,16 +207,6 @@ void MainWindow::save_settings() {
auto &settings = GlobalSettingStation::GetInstance().GetUISettings();
try {
- SettingsObject main_windows_state("main_windows_state");
-
- // window position and size
- main_windows_state["window_state"] = saveState().toBase64().toStdString();
- main_windows_state["window_pos"]["x"] = pos().x();
- main_windows_state["window_pos"]["y"] = pos().y();
-
- main_windows_state["window_size"]["width"] = size().width();
- main_windows_state["window_size"]["height"] = size().height();
- main_windows_state["window_save"] = true;
bool save_key_checked = settings.lookup("general.save_key_checked");
diff --git a/src/ui/main_window/MainWindow.h b/src/ui/main_window/MainWindow.h
index a0f1a5d4..23053a6f 100644
--- a/src/ui/main_window/MainWindow.h
+++ b/src/ui/main_window/MainWindow.h
@@ -34,7 +34,7 @@
#include "core/function/result_analyse/GpgEncryptResultAnalyse.h"
#include "core/function/result_analyse/GpgSignResultAnalyse.h"
#include "ui/GpgFrontendUI.h"
-#include "ui/KeyMgmt.h"
+#include "KeyMgmt.h"
#include "ui/dialog/WaitingDialog.h"
#include "ui/dialog/Wizard.h"
#include "ui/help/AboutDialog.h"
@@ -43,16 +43,21 @@
#include "ui/widgets/FindWidget.h"
#include "ui/widgets/InfoBoardWidget.h"
#include "ui/widgets/TextEdit.h"
+#include "ui/main_window/GeneralMainWindow.h"
namespace GpgFrontend::UI {
/**
* @brief
*
*/
-class MainWindow : public QMainWindow {
+class MainWindow : public GeneralMainWindow {
Q_OBJECT
public:
+
+ /**
+ *
+ */
struct CryptoMenu {
using OperationType = unsigned int;
diff --git a/src/ui/settings/SettingsDialog.cpp b/src/ui/settings/SettingsDialog.cpp
index eefdd3c7..f0aed7c2 100644
--- a/src/ui/settings/SettingsDialog.cpp
+++ b/src/ui/settings/SettingsDialog.cpp
@@ -38,7 +38,8 @@
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/settings/SettingsDialog.h
index e123cc6c..acb60bd3 100755
--- a/src/ui/settings/SettingsDialog.h
+++ b/src/ui/settings/SettingsDialog.h
@@ -31,6 +31,7 @@
#include "ui/GpgFrontendUI.h"
#include "ui/widgets/KeyList.h"
+#include "ui/dialog/GeneralDialog.h"
namespace GpgFrontend::UI {
@@ -43,7 +44,7 @@ class NetworkTab;
* @brief
*
*/
-class SettingsDialog : public QDialog {
+class SettingsDialog : public GeneralDialog {
Q_OBJECT
public: