aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2022-07-22 18:54:52 +0000
committerSaturneric <[email protected]>2022-07-22 18:56:08 +0000
commitff73042072c1937c8ee20cabab3f16cf38d588b1 (patch)
treef269b6178a5318cbf1c7945bbcd6d7a0736d104f
parentrefactor(ui): adjust file structure (diff)
downloadGpgFrontend-ff73042072c1937c8ee20cabab3f16cf38d588b1.tar.gz
GpgFrontend-ff73042072c1937c8ee20cabab3f16cf38d588b1.zip
fix(ui): fix signer picker and other issues
1. signer picker can cancel its operation now 2. fix window title of "Export As Key Package"
-rw-r--r--src/ui/dialog/GeneralDialog.cpp17
-rw-r--r--src/ui/dialog/GeneralDialog.h2
-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/details/SignatureDetailsDialog.h1
-rw-r--r--src/ui/dialog/import_export/ExportKeyPackageDialog.cpp2
-rw-r--r--src/ui/main_window/GeneralMainWindow.cpp12
-rw-r--r--src/ui/main_window/GeneralMainWindow.h2
-rw-r--r--src/ui/main_window/MainWindowFileSlotFunction.cpp5
-rw-r--r--src/ui/main_window/MainWindowSlotFunction.cpp9
10 files changed, 57 insertions, 33 deletions
diff --git a/src/ui/dialog/GeneralDialog.cpp b/src/ui/dialog/GeneralDialog.cpp
index 457aa142..d07c2497 100644
--- a/src/ui/dialog/GeneralDialog.cpp
+++ b/src/ui/dialog/GeneralDialog.cpp
@@ -50,16 +50,17 @@ void GpgFrontend::UI::GeneralDialog::slot_restore_settings() noexcept {
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);
+ this->move({x, y});
+ pos_ = {x, y};
int width =
- general_windows_state.Check("window_size").Check("width", 800),
+ general_windows_state.Check("window_size").Check("width", 400),
height =
- general_windows_state.Check("window_size").Check("height", 450);
+ general_windows_state.Check("window_size").Check("height", 247);
+
+ this->resize({width, height});
+ size_ = {width, height};
- auto size = QSize(width, height);
- this->resize(size);
- this->move(pos);
}
} catch (...) {
@@ -77,8 +78,8 @@ void GpgFrontend::UI::GeneralDialog::slot_save_settings() noexcept {
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_size"]["width"] = size_.width();
+ general_windows_state["window_size"]["height"] = size_.height();
general_windows_state["window_save"] = true;
} catch (...) {
diff --git a/src/ui/dialog/GeneralDialog.h b/src/ui/dialog/GeneralDialog.h
index 037277fa..ca480c8b 100644
--- a/src/ui/dialog/GeneralDialog.h
+++ b/src/ui/dialog/GeneralDialog.h
@@ -58,6 +58,8 @@ class GeneralDialog : public QDialog {
private:
std::string name_; ///<
+ QPoint pos_; ///<
+ QSize size_; ///<
};
} // namespace GpgFrontend::UI
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/details/SignatureDetailsDialog.h b/src/ui/dialog/details/SignatureDetailsDialog.h
index 847b320b..7b01d054 100644
--- a/src/ui/dialog/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/dialog/import_export/ExportKeyPackageDialog.cpp b/src/ui/dialog/import_export/ExportKeyPackageDialog.cpp
index 074f07ba..312cd946 100644
--- a/src/ui/dialog/import_export/ExportKeyPackageDialog.cpp
+++ b/src/ui/dialog/import_export/ExportKeyPackageDialog.cpp
@@ -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/main_window/GeneralMainWindow.cpp b/src/ui/main_window/GeneralMainWindow.cpp
index d7d93c3d..42e53ac3 100644
--- a/src/ui/main_window/GeneralMainWindow.cpp
+++ b/src/ui/main_window/GeneralMainWindow.cpp
@@ -65,16 +65,16 @@ void GpgFrontend::UI::GeneralMainWindow::slot_restore_settings() noexcept {
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);
+ this->move({x, y});
+ pos_ = {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);
+ this->resize({width, height});
+ size_ = {width, height};
}
int width = general_windows_state.Check("icon_size").Check("width", 24),
@@ -109,8 +109,8 @@ void GpgFrontend::UI::GeneralMainWindow::slot_save_settings() noexcept {
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_size"]["width"] = size_.width();
+ general_windows_state["window_size"]["height"] = size_.height();
general_windows_state["window_save"] = true;
// icon size
diff --git a/src/ui/main_window/GeneralMainWindow.h b/src/ui/main_window/GeneralMainWindow.h
index 14b5d534..6718a074 100644
--- a/src/ui/main_window/GeneralMainWindow.h
+++ b/src/ui/main_window/GeneralMainWindow.h
@@ -72,6 +72,8 @@ class GeneralMainWindow : public QMainWindow {
private:
std::string name_; ///<
+ QPoint pos_; ///<
+ QSize size_; ///<
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/main_window/MainWindowFileSlotFunction.cpp b/src/ui/main_window/MainWindowFileSlotFunction.cpp
index 4ab23a22..526c27c0 100644
--- a/src/ui/main_window/MainWindowFileSlotFunction.cpp
+++ b/src/ui/main_window/MainWindowFileSlotFunction.cpp
@@ -32,8 +32,8 @@
#include "core/function/gpg/GpgFileOpera.h"
#include "core/function/gpg/GpgKeyGetter.h"
#include "core/thread/Task.h"
+#include "dialog/SignersPicker.h"
#include "ui/UserInterfaceUtils.h"
-#include "ui/widgets/SignersPicker.h"
namespace GpgFrontend::UI {
@@ -618,6 +618,9 @@ void MainWindow::SlotFileEncryptSign() {
connect(signersPicker, &SignersPicker::finished, &loop, &QEventLoop::quit);
loop.exec();
+ // return when canceled
+ if (!signersPicker->GetStatus()) return;
+
auto signer_key_ids = signersPicker->GetCheckedSigners();
auto p_signer_keys = GpgKeyGetter::GetInstance().GetKeys(signer_key_ids);
diff --git a/src/ui/main_window/MainWindowSlotFunction.cpp b/src/ui/main_window/MainWindowSlotFunction.cpp
index 9108a124..f715046c 100644
--- a/src/ui/main_window/MainWindowSlotFunction.cpp
+++ b/src/ui/main_window/MainWindowSlotFunction.cpp
@@ -26,7 +26,6 @@
*
*/
-#include <cstddef>
#include <memory>
#include <string>
#include <utility>
@@ -34,15 +33,12 @@
#include "MainWindow.h"
#include "core/GpgConstants.h"
#include "core/GpgModel.h"
-#include "core/function/GlobalSettingStation.h"
#include "core/function/gpg/GpgBasicOperator.h"
#include "core/function/gpg/GpgKeyGetter.h"
#include "core/function/gpg/GpgKeyImportExporter.h"
-#include "core/model/GpgKey.h"
-#include "core/thread/TaskRunner.h"
#include "ui/UserInterfaceUtils.h"
#include "ui/dialog/help/AboutDialog.h"
-#include "ui/widgets/SignersPicker.h"
+#include "dialog/SignersPicker.h"
namespace GpgFrontend::UI {
/**
@@ -427,6 +423,9 @@ void MainWindow::slot_encrypt_sign() {
connect(signersPicker, &SignersPicker::finished, &loop, &QEventLoop::quit);
loop.exec();
+ // return when canceled
+ if (!signersPicker->GetStatus()) return;
+
auto signer_key_ids = signersPicker->GetCheckedSigners();
auto signer_keys = GpgKeyGetter::GetInstance().GetKeys(signer_key_ids);