aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/dialog
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui/dialog')
-rw-r--r--src/ui/dialog/GeneralDialog.cpp104
-rw-r--r--src/ui/dialog/details/VerifyDetailsDialog.h1
-rw-r--r--src/ui/dialog/help/AboutDialog.cpp11
-rw-r--r--src/ui/dialog/help/AboutDialog.h1
-rw-r--r--src/ui/dialog/help/GnupgTab.cpp7
-rw-r--r--src/ui/dialog/import_export/KeyImportDetailDialog.cpp41
-rw-r--r--src/ui/dialog/import_export/KeyServerImportDialog.cpp21
-rw-r--r--src/ui/dialog/key_generate/KeygenDialog.cpp29
-rw-r--r--src/ui/dialog/key_generate/KeygenDialog.h1
-rw-r--r--src/ui/dialog/key_generate/SubkeyGenerateDialog.cpp27
-rw-r--r--src/ui/dialog/key_generate/SubkeyGenerateDialog.h1
-rw-r--r--src/ui/dialog/keypair_details/KeyPairOperaTab.cpp32
-rw-r--r--src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp2
-rw-r--r--src/ui/dialog/keypair_details/KeySetExpireDateDialog.cpp2
-rw-r--r--src/ui/dialog/settings/SettingsGeneral.cpp29
-rw-r--r--src/ui/dialog/settings/SettingsKeyServer.cpp5
-rw-r--r--src/ui/dialog/settings/SettingsNetwork.cpp133
17 files changed, 314 insertions, 133 deletions
diff --git a/src/ui/dialog/GeneralDialog.cpp b/src/ui/dialog/GeneralDialog.cpp
index 9367aa44..90c56b8a 100644
--- a/src/ui/dialog/GeneralDialog.cpp
+++ b/src/ui/dialog/GeneralDialog.cpp
@@ -57,53 +57,17 @@ void GpgFrontend::UI::GeneralDialog::slot_restore_settings() noexcept {
size_ = {width, height};
- if (this->parent() != nullptr) {
- QPoint parent_pos = {0, 0};
- QSize parent_size = {0, 0};
-
- auto *parent_widget = qobject_cast<QWidget *>(this->parent());
- if (parent_widget != nullptr) {
- parent_pos = parent_widget->pos();
- parent_size = parent_widget->size();
- }
-
- auto *parent_dialog = qobject_cast<QDialog *>(this->parent());
- if (parent_dialog != nullptr) {
- parent_pos = parent_dialog->pos();
- parent_size = parent_dialog->size();
- }
-
- auto *parent_window = qobject_cast<QMainWindow *>(this->parent());
- if (parent_window != nullptr) {
- parent_pos = parent_window->pos();
- parent_size = parent_window->size();
- }
-
- SPDLOG_DEBUG("parent pos x: {} y: {}", parent_pos.x(), parent_pos.y());
-
- SPDLOG_DEBUG("parent size width: {} height: {}", parent_size.width(),
- parent_size.height());
-
- SPDLOG_DEBUG("this dialog size width: {} height: {}", size_.width(),
- size_.height());
-
- if (parent_pos != QPoint{0, 0}) {
- QPoint parent_center{parent_pos.x() + parent_size.width() / 2,
- parent_pos.y() + parent_size.height() / 2};
-
- pos_ = {parent_center.x() - size_.width() / 2,
- parent_center.y() - size_.height() / 2};
-
- // record parent_pos_
- this->parent_pos_ = parent_pos;
- this->parent_size_ = parent_size;
- }
+ // check for valid
+ if (!pos_.isNull() && pos_.x() > 50 && pos_.y() > 50 && size_.isValid()) {
+ this->move(pos_);
+ this->resize(size_);
+ return;
}
-
- this->move(pos_);
- this->resize(size_);
}
+ // default action
+ movePosition2CenterOfParent();
+
} catch (...) {
SPDLOG_ERROR(name_, "error");
}
@@ -148,8 +112,56 @@ void GpgFrontend::UI::GeneralDialog::setPosCenterOfScreen() {
*
*/
void GpgFrontend::UI::GeneralDialog::movePosition2CenterOfParent() {
- SPDLOG_DEBUG("parent pos x: {} y: {}", parent_pos_.x(), parent_pos_.y());
+ // read pos and size from parent
+ if (this->parent() != nullptr) {
+ QPoint parent_pos = {0, 0};
+ QSize parent_size = {0, 0};
+
+ auto *parent_widget = qobject_cast<QWidget *>(this->parent());
+ if (parent_widget != nullptr) {
+ parent_pos = parent_widget->pos();
+ parent_size = parent_widget->size();
+ }
+
+ auto *parent_dialog = qobject_cast<QDialog *>(this->parent());
+ if (parent_dialog != nullptr) {
+ parent_pos = parent_dialog->pos();
+ parent_size = parent_dialog->size();
+ }
+
+ auto *parent_window = qobject_cast<QMainWindow *>(this->parent());
+ if (parent_window != nullptr) {
+ parent_pos = parent_window->pos();
+ parent_size = parent_window->size();
+ }
+
+ SPDLOG_DEBUG("parent pos x: {} y: {}", parent_pos.x(), parent_pos.y());
+ SPDLOG_DEBUG("parent size width: {} height: {}", parent_size.width(),
+ parent_size.height());
+
+ SPDLOG_DEBUG("this dialog size width: {} height: {}", size_.width(),
+ size_.height());
+
+ if (parent_pos != QPoint{0, 0}) {
+ QPoint parent_center{parent_pos.x() + parent_size.width() / 2,
+ parent_pos.y() + parent_size.height() / 2};
+
+ pos_ = {parent_center.x() - size_.width() / 2,
+ parent_center.y() - size_.height() / 2};
+
+ // record parent_pos_
+ this->parent_pos_ = parent_pos;
+ this->parent_size_ = parent_size;
+ }
+ } else {
+ // reset parent's pos and size
+ this->parent_pos_ = QPoint{0, 0};
+ this->parent_size_ = QSize{0, 0};
+ }
+
+ // log for debug
+ SPDLOG_DEBUG("parent pos x: {} y: {}", parent_pos_.x(), parent_pos_.y());
SPDLOG_DEBUG("parent size width: {}", parent_size_.width(),
"height:", parent_size_.height());
@@ -164,5 +176,7 @@ void GpgFrontend::UI::GeneralDialog::movePosition2CenterOfParent() {
pos_ = {parent_center.x() - size_.width() / 2,
parent_center.y() - size_.height() / 2};
this->move(pos_);
+ } else {
+ setPosCenterOfScreen();
}
} \ No newline at end of file
diff --git a/src/ui/dialog/details/VerifyDetailsDialog.h b/src/ui/dialog/details/VerifyDetailsDialog.h
index 97e2cc2d..5bc09884 100644
--- a/src/ui/dialog/details/VerifyDetailsDialog.h
+++ b/src/ui/dialog/details/VerifyDetailsDialog.h
@@ -60,7 +60,6 @@ class VerifyDetailsDialog : public QDialog {
void slot_refresh();
private:
- KeyList* key_list_; ///<
QHBoxLayout* main_layout_; ///<
QWidget* m_vbox_{}; ///<
QByteArray* input_data_{}; ///<
diff --git a/src/ui/dialog/help/AboutDialog.cpp b/src/ui/dialog/help/AboutDialog.cpp
index 3cf6c2a2..faf2b316 100644
--- a/src/ui/dialog/help/AboutDialog.cpp
+++ b/src/ui/dialog/help/AboutDialog.cpp
@@ -28,6 +28,8 @@
#include "AboutDialog.h"
+#include <openssl/opensslv.h>
+
#include "GpgFrontendBuildInfo.h"
#include "core/function/GlobalSettingStation.h"
#include "core/thread/TaskRunnerGetter.h"
@@ -83,9 +85,9 @@ InfoTab::InfoTab(QWidget* parent) : QWidget(parent) {
"<center><b>" + qApp->applicationVersion() + "</b></center>" +
"<center>" + GIT_VERSION + "</center>" + "<br><center>" +
_("GpgFrontend is an easy-to-use, compact, cross-platform, "
- "and installation-free gpg front-end tool."
- "It visualizes most of the common operations of gpg commands."
- "It's licensed under the GPL v3") +
+ "and installation-free GnuPG Frontend."
+ "It visualizes most of the common operations of GnuPG."
+ "GpgFrontend is licensed under the GPLv3") +
"<br><br>"
"<b>" +
_("Developer:") + "</b><br>" + "Saturneric" + "<br><br>" +
@@ -94,7 +96,8 @@ InfoTab::InfoTab(QWidget* parent) : QWidget(parent) {
" <a href=\"https://github.com/saturneric/GpgFrontend\">GitHub</a> " +
_("or send a mail to my mailing list at") + " <a " +
"href=\"mailto:[email protected]\">[email protected]</a>." + "<br><br> " +
- _("Built with Qt") + " " + qVersion() + " " + _("and GPGME") + " " +
+ _("Built with Qt") + " " + qVersion() + ", " + OPENSSL_VERSION_TEXT +
+ " " + _("and") + " " + "GPGME" + " " +
GpgFrontend::GpgContext::GetInstance()
.GetInfo(false)
.GpgMEVersion.c_str() +
diff --git a/src/ui/dialog/help/AboutDialog.h b/src/ui/dialog/help/AboutDialog.h
index 09a63734..6d7ce265 100644
--- a/src/ui/dialog/help/AboutDialog.h
+++ b/src/ui/dialog/help/AboutDialog.h
@@ -80,7 +80,6 @@ class UpdateTab : public QWidget {
QLabel* upgrade_label_; ///<
QProgressBar* pb_; ///<
QString current_version_; ///<
- QPushButton* download_button_; ///<
public:
/**
diff --git a/src/ui/dialog/help/GnupgTab.cpp b/src/ui/dialog/help/GnupgTab.cpp
index 2758cbe1..996d4ad9 100644
--- a/src/ui/dialog/help/GnupgTab.cpp
+++ b/src/ui/dialog/help/GnupgTab.cpp
@@ -42,7 +42,10 @@ GpgFrontend::UI::GnupgTab::GnupgTab(QWidget* parent)
QStringList components_column_titles;
components_column_titles << _("Name") << _("Description") << _("Version")
- << _("Checksum") << _("Path");
+ << _("Checksum") << _("Binary Path");
+
+ ui_->tabWidget->setTabText(0, _("Components"));
+ ui_->tabWidget->setTabText(1, _("Configurations"));
ui_->componentDetailsTable->setColumnCount(components_column_titles.length());
ui_->componentDetailsTable->setHorizontalHeaderLabels(
@@ -52,7 +55,7 @@ GpgFrontend::UI::GnupgTab::GnupgTab(QWidget* parent)
QAbstractItemView::SelectRows);
QStringList configurations_column_titles;
- configurations_column_titles << _("Name") << _("Path");
+ configurations_column_titles << _("Key") << _("Value");
ui_->configurationDetailsTable->setColumnCount(
configurations_column_titles.length());
diff --git a/src/ui/dialog/import_export/KeyImportDetailDialog.cpp b/src/ui/dialog/import_export/KeyImportDetailDialog.cpp
index e9b1af93..32ae63fa 100644
--- a/src/ui/dialog/import_export/KeyImportDetailDialog.cpp
+++ b/src/ui/dialog/import_export/KeyImportDetailDialog.cpp
@@ -124,7 +124,6 @@ void KeyImportDetailDialog::create_general_info_box() {
new QLabel(QString(_("Private Unchanged")) + ": "), row, 0);
generalInfoBoxLayout->addWidget(
new QLabel(QString::number(m_result_.secret_unchanged)), row, 1);
- row++;
}
}
@@ -162,36 +161,36 @@ void KeyImportDetailDialog::create_keys_table() {
keys_table_->resizeColumnsToContents();
}
-QString KeyImportDetailDialog::get_status_string(int keyStatus) {
- QString statusString;
+QString KeyImportDetailDialog::get_status_string(int key_status) {
+ QString status_string;
// keystatus is greater than 15, if key is private
- if (keyStatus > 15) {
- statusString.append(_("Private"));
- keyStatus = keyStatus - 16;
+ if (key_status > 15) {
+ status_string.append(_("Private"));
+ key_status = key_status - 16;
} else {
- statusString.append(_("Public"));
+ status_string.append(_("Public"));
}
- if (keyStatus == 0) {
- statusString.append(", " + QString(_("Unchanged")));
+ if (key_status == 0) {
+ status_string.append(", " + QString(_("Unchanged")));
} else {
- if (keyStatus == 1) {
- statusString.append(", " + QString(_("New Key")));
+ if (key_status == 1) {
+ status_string.append(", " + QString(_("New Key")));
} else {
- if (keyStatus > 7) {
- statusString.append(", " + QString(_("New Subkey")));
- keyStatus = keyStatus - 8;
+ if (key_status > 7) {
+ status_string.append(", " + QString(_("New Subkey")));
+ return status_string;
}
- if (keyStatus > 3) {
- statusString.append(", " + QString(_("New Signature")));
- keyStatus = keyStatus - 4;
+ if (key_status > 3) {
+ status_string.append(", " + QString(_("New Signature")));
+ return status_string;
}
- if (keyStatus > 1) {
- statusString.append(", " + QString(_("New UID")));
- keyStatus = keyStatus - 2;
+ if (key_status > 1) {
+ status_string.append(", " + QString(_("New UID")));
+ return status_string;
}
}
}
- return statusString;
+ return status_string;
}
void KeyImportDetailDialog::create_button_box() {
diff --git a/src/ui/dialog/import_export/KeyServerImportDialog.cpp b/src/ui/dialog/import_export/KeyServerImportDialog.cpp
index 713c5a58..5692f607 100644
--- a/src/ui/dialog/import_export/KeyServerImportDialog.cpp
+++ b/src/ui/dialog/import_export/KeyServerImportDialog.cpp
@@ -47,6 +47,23 @@ KeyServerImportDialog::KeyServerImportDialog(bool automatic, QWidget* parent)
// Layout for messagebox
auto* message_layout = new QHBoxLayout();
+ // get settings
+ auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
+ // read settings
+ bool forbid_all_gnupg_connection = false;
+ try {
+ forbid_all_gnupg_connection =
+ settings.lookup("network.forbid_all_gnupg_connection");
+ } catch (...) {
+ SPDLOG_ERROR("setting operation error: forbid_all_gnupg_connection");
+ }
+
+ if (forbid_all_gnupg_connection) {
+ QMessageBox::critical(this, "Forbidden", "GnuPG is in offline mode now.");
+ this->close();
+ this->deleteLater();
+ }
+
if (automatic) {
setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
} else {
@@ -249,6 +266,10 @@ void KeyServerImportDialog::slot_search() {
Thread::TaskRunnerGetter::GetInstance()
.GetTaskRunner(Thread::TaskRunnerGetter::kTaskRunnerType_Network)
->PostTask(task);
+
+ QEventLoop loop;
+ connect(task, &Thread::Task::SignalTaskEnd, &loop, &QEventLoop::quit);
+ loop.exec();
}
void KeyServerImportDialog::slot_search_finished(
diff --git a/src/ui/dialog/key_generate/KeygenDialog.cpp b/src/ui/dialog/key_generate/KeygenDialog.cpp
index d6f61215..ea874ed2 100644
--- a/src/ui/dialog/key_generate/KeygenDialog.cpp
+++ b/src/ui/dialog/key_generate/KeygenDialog.cpp
@@ -28,6 +28,8 @@
#include "KeygenDialog.h"
+#include <qobject.h>
+
#include "core/common/CoreCommonUtil.h"
#include "core/function/GlobalSettingStation.h"
#include "core/function/gpg/GpgKeyOpera.h"
@@ -53,6 +55,16 @@ KeyGenDialog::KeyGenDialog(QWidget* parent)
SPDLOG_ERROR("setting operation error: longer_expiration_date");
}
+ bool use_pinentry_as_password_input_dialog = false;
+ try {
+ use_pinentry_as_password_input_dialog =
+ settings.lookup("general.use_pinentry_as_password_input_dialog");
+ } catch (...) {
+ SPDLOG_ERROR(
+ "setting operation error: use_pinentry_as_password_input_dialog");
+ }
+ use_pinentry_ = use_pinentry_as_password_input_dialog;
+
max_date_time_ = longer_expiration_date
? QDateTime::currentDateTime().toLocalTime().addYears(30)
: QDateTime::currentDateTime().toLocalTime().addYears(2);
@@ -111,7 +123,8 @@ void KeyGenDialog::slot_key_gen_accept() {
error_stream << " " << _("Expiration time too long.") << std::endl;
}
- if (passphrase_edit_->isEnabled() && passphrase_edit_->text().size() == 0) {
+ if (!use_pinentry_ && passphrase_edit_->isEnabled() &&
+ passphrase_edit_->text().size() == 0) {
error_stream << " " << _("Password is empty.") << std::endl;
}
@@ -139,7 +152,7 @@ void KeyGenDialog::slot_key_gen_accept() {
#endif
}
- if (!gen_key_info_->IsNoPassPhrase()) {
+ if (!use_pinentry_ && !gen_key_info_->IsNoPassPhrase()) {
CoreCommonUtil::GetInstance()->SetTempCacheValue(
"__key_passphrase", this->passphrase_edit_->text().toStdString());
}
@@ -160,14 +173,14 @@ void KeyGenDialog::slot_key_gen_accept() {
dialog->close();
- if (!gen_key_info_->IsNoPassPhrase()) {
+ if (!use_pinentry_ && !gen_key_info_->IsNoPassPhrase()) {
CoreCommonUtil::GetInstance()->ResetTempCacheValue("__key_passphrase");
}
SPDLOG_DEBUG("generate done");
if (gpgme_err_code(error) == GPG_ERR_NO_ERROR) {
- auto* msg_box = new QMessageBox((QWidget*)this->parent());
+ auto* msg_box = new QMessageBox(qobject_cast<QWidget*>(this->parent()));
msg_box->setAttribute(Qt::WA_DeleteOnClose);
msg_box->setStandardButtons(QMessageBox::Ok);
msg_box->setWindowTitle(_("Success"));
@@ -391,6 +404,7 @@ QGroupBox* KeyGenDialog::create_basic_info_group_box() {
expire_check_box_->setCheckState(Qt::Unchecked);
passphrase_edit_->setEchoMode(QLineEdit::Password);
+ passphrase_edit_->setHidden(use_pinentry_);
no_pass_phrase_check_box_ = new QCheckBox(this);
no_pass_phrase_check_box_->setCheckState(Qt::Unchecked);
@@ -404,8 +418,9 @@ QGroupBox* KeyGenDialog::create_basic_info_group_box() {
vbox1->addWidget(new QLabel(QString(_("Never Expire")) + ": "), 3, 3);
vbox1->addWidget(new QLabel(QString(_("KeySize (in Bit)")) + ": "), 4, 0);
vbox1->addWidget(new QLabel(QString(_("Key Type")) + ": "), 5, 0);
- vbox1->addWidget(new QLabel(QString(_("Password")) + ": "), 6, 0);
- vbox1->addWidget(new QLabel(QString(_("Non Pass Phrase")) + ": "), 6, 3);
+ if (!use_pinentry_)
+ vbox1->addWidget(new QLabel(QString(_("Password")) + ": "), 6, 0);
+ vbox1->addWidget(new QLabel(QString(_("Non Pass Phrase"))), 6, 3);
vbox1->addWidget(name_edit_, 0, 1, 1, 3);
vbox1->addWidget(email_edit_, 1, 1, 1, 3);
@@ -414,7 +429,7 @@ QGroupBox* KeyGenDialog::create_basic_info_group_box() {
vbox1->addWidget(expire_check_box_, 3, 2);
vbox1->addWidget(key_size_spin_box_, 4, 1);
vbox1->addWidget(key_type_combo_box_, 5, 1);
- vbox1->addWidget(passphrase_edit_, 6, 1);
+ if (!use_pinentry_) vbox1->addWidget(passphrase_edit_, 6, 1);
vbox1->addWidget(no_pass_phrase_check_box_, 6, 2);
auto basicInfoGroupBox = new QGroupBox();
diff --git a/src/ui/dialog/key_generate/KeygenDialog.h b/src/ui/dialog/key_generate/KeygenDialog.h
index a1d7f39a..31b5f9c7 100644
--- a/src/ui/dialog/key_generate/KeygenDialog.h
+++ b/src/ui/dialog/key_generate/KeygenDialog.h
@@ -103,6 +103,7 @@ class KeyGenDialog : public GeneralDialog {
///< of the Key
QDateTime max_date_time_; ///<
std::vector<QCheckBox*> key_usage_check_boxes_; ///< ENCR, SIGN, CERT, AUTH
+ bool use_pinentry_ = false;
/**
* @brief
diff --git a/src/ui/dialog/key_generate/SubkeyGenerateDialog.cpp b/src/ui/dialog/key_generate/SubkeyGenerateDialog.cpp
index 50f38413..f4263962 100644
--- a/src/ui/dialog/key_generate/SubkeyGenerateDialog.cpp
+++ b/src/ui/dialog/key_generate/SubkeyGenerateDialog.cpp
@@ -52,6 +52,16 @@ SubkeyGenerateDialog::SubkeyGenerateDialog(const KeyId& key_id, QWidget* parent)
SPDLOG_ERROR("setting operation error: longer_expiration_date");
}
+ bool use_pinentry_as_password_input_dialog = false;
+ try {
+ use_pinentry_as_password_input_dialog =
+ settings.lookup("general.use_pinentry_as_password_input_dialog");
+ } catch (...) {
+ SPDLOG_ERROR(
+ "setting operation error: use_pinentry_as_password_input_dialog");
+ }
+ use_pinentry_ = use_pinentry_as_password_input_dialog;
+
max_date_time_ = longer_expiration_date
? QDateTime::currentDateTime().toLocalTime().addYears(30)
: QDateTime::currentDateTime().toLocalTime().addYears(2);
@@ -148,20 +158,24 @@ QGroupBox* SubkeyGenerateDialog::create_basic_info_group_box() {
expire_check_box_ = new QCheckBox(this);
expire_check_box_->setCheckState(Qt::Unchecked);
+ passphrase_edit_->setEchoMode(QLineEdit::Password);
+ passphrase_edit_->setHidden(use_pinentry_);
+
auto* vbox1 = new QGridLayout;
vbox1->addWidget(new QLabel(QString(_("Key Type")) + ": "), 0, 0);
vbox1->addWidget(new QLabel(QString(_("KeySize (in Bit)")) + ": "), 1, 0);
vbox1->addWidget(new QLabel(QString(_("Expiration Date")) + ": "), 2, 0);
vbox1->addWidget(new QLabel(QString(_("Never Expire"))), 2, 3);
- vbox1->addWidget(new QLabel(QString(_("Password")) + ": "), 3, 0);
+ if (!use_pinentry_)
+ vbox1->addWidget(new QLabel(QString(_("Password")) + ": "), 3, 0);
vbox1->addWidget(new QLabel(QString(_("Non Pass Phrase"))), 3, 3);
vbox1->addWidget(key_type_combo_box_, 0, 1);
vbox1->addWidget(key_size_spin_box_, 1, 1);
vbox1->addWidget(date_edit_, 2, 1);
vbox1->addWidget(expire_check_box_, 2, 2);
- vbox1->addWidget(passphrase_edit_, 3, 1);
+ if (!use_pinentry_) vbox1->addWidget(passphrase_edit_, 3, 1);
vbox1->addWidget(no_pass_phrase_check_box_, 3, 2);
auto basicInfoGroupBox = new QGroupBox();
@@ -265,7 +279,8 @@ void SubkeyGenerateDialog::slot_key_gen_accept() {
err_stream << " " << _("Expiration time no more than 2 years.") << " ";
}
- if (passphrase_edit_->isEnabled() && passphrase_edit_->text().size() == 0) {
+ if (!use_pinentry_ && passphrase_edit_->isEnabled() &&
+ passphrase_edit_->text().size() == 0) {
err_stream << " " << _("Password is empty.") << std::endl;
}
@@ -286,7 +301,7 @@ void SubkeyGenerateDialog::slot_key_gen_accept() {
#endif
}
- if (!gen_key_info_->IsNoPassPhrase()) {
+ if (!use_pinentry_ && !gen_key_info_->IsNoPassPhrase()) {
CoreCommonUtil::GetInstance()->SetTempCacheValue(
"__key_passphrase", this->passphrase_edit_->text().toStdString());
}
@@ -307,12 +322,12 @@ void SubkeyGenerateDialog::slot_key_gen_accept() {
}
waiting_dialog->close();
- if (!gen_key_info_->IsNoPassPhrase()) {
+ if (!use_pinentry_ && !gen_key_info_->IsNoPassPhrase()) {
CoreCommonUtil::GetInstance()->ResetTempCacheValue("__key_passphrase");
}
if (check_gpg_error_2_err_code(error) == GPG_ERR_NO_ERROR) {
- auto* msg_box = new QMessageBox((QWidget*)this->parent());
+ auto* msg_box = new QMessageBox(qobject_cast<QWidget*>(this->parent()));
msg_box->setAttribute(Qt::WA_DeleteOnClose);
msg_box->setStandardButtons(QMessageBox::Ok);
msg_box->setWindowTitle(_("Success"));
diff --git a/src/ui/dialog/key_generate/SubkeyGenerateDialog.h b/src/ui/dialog/key_generate/SubkeyGenerateDialog.h
index 731bb951..2b88bd61 100644
--- a/src/ui/dialog/key_generate/SubkeyGenerateDialog.h
+++ b/src/ui/dialog/key_generate/SubkeyGenerateDialog.h
@@ -74,6 +74,7 @@ class SubkeyGenerateDialog : public GeneralDialog {
std::vector<QCheckBox*> key_usage_check_boxes_; ///< ENCR, SIGN, CERT, AUTH
QDateTime max_date_time_; ///<
+ bool use_pinentry_ = false;
/**
* @brief Create a key usage group box object
diff --git a/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp b/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp
index a1452033..9be77923 100644
--- a/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp
+++ b/src/ui/dialog/keypair_details/KeyPairOperaTab.cpp
@@ -27,6 +27,7 @@
#include "KeyPairOperaTab.h"
#include "KeySetExpireDateDialog.h"
+#include "core/function/GlobalSettingStation.h"
#include "core/function/gpg/GpgKeyImportExporter.h"
#include "core/function/gpg/GpgKeyOpera.h"
#include "ui/SignalStation.h"
@@ -73,10 +74,23 @@ KeyPairOperaTab::KeyPairOperaTab(const std::string& key_id, QWidget* parent)
}
auto advance_h_box_layout = new QHBoxLayout();
+
+ // get settings
+ auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
+ // read settings
+ bool forbid_all_gnupg_connection = false;
+ try {
+ forbid_all_gnupg_connection =
+ settings.lookup("network.forbid_all_gnupg_connection");
+ } catch (...) {
+ SPDLOG_ERROR("setting operation error: forbid_all_gnupg_connection");
+ }
+
auto* key_server_opera_button =
new QPushButton(_("Key Server Operation (Pubkey)"));
key_server_opera_button->setStyleSheet("text-align:center;");
key_server_opera_button->setMenu(key_server_opera_menu_);
+ key_server_opera_button->setDisabled(forbid_all_gnupg_connection);
advance_h_box_layout->addWidget(key_server_opera_button);
if (m_key_.IsPrivateKey() && m_key_.IsHasMasterKey()) {
@@ -147,8 +161,13 @@ void KeyPairOperaTab::slot_export_public_key() {
}
// generate a file name
+#ifndef WINDOWS
auto file_string = m_key_.GetName() + "<" + m_key_.GetEmail() + ">(" +
m_key_.GetId() + ")_pub.asc";
+#else
+ auto file_string = m_key_.GetName() + "[" + m_key_.GetEmail() + "](" +
+ m_key_.GetId() + ")_pub.asc";
+#endif
std::replace(file_string.begin(), file_string.end(), ' ', '_');
auto file_name =
@@ -193,8 +212,14 @@ void KeyPairOperaTab::slot_export_short_private_key() {
return;
}
+ // generate a file name
+#ifndef WINDOWS
auto file_string = m_key_.GetName() + "<" + m_key_.GetEmail() + ">(" +
m_key_.GetId() + ")_short_secret.asc";
+#else
+ auto file_string = m_key_.GetName() + "[" + m_key_.GetEmail() + "](" +
+ m_key_.GetId() + ")_short_secret.asc";
+#endif
std::replace(file_string.begin(), file_string.end(), ' ', '_');
auto file_name =
@@ -235,8 +260,15 @@ void KeyPairOperaTab::slot_export_private_key() {
_("An error occurred during the export operation."));
return;
}
+
+ // generate a file name
+#ifndef WINDOWS
auto file_string = m_key_.GetName() + "<" + m_key_.GetEmail() + ">(" +
m_key_.GetId() + ")_full_secret.asc";
+#else
+ auto file_string = m_key_.GetName() + "[" + m_key_.GetEmail() + "](" +
+ m_key_.GetId() + ")_full_secret.asc";
+#endif
std::replace(file_string.begin(), file_string.end(), ' ', '_');
auto file_name =
diff --git a/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp b/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp
index d1367541..9c243a39 100644
--- a/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp
+++ b/src/ui/dialog/keypair_details/KeyPairSubkeyTab.cpp
@@ -312,7 +312,7 @@ void KeyPairSubkeyTab::slot_refresh_subkey_detail() {
}
fingerprint_var_label_->setText(
- QString::fromStdString(subkey.GetFingerprint()));
+ QString::fromStdString(beautify_fingerprint(subkey.GetFingerprint())));
}
void KeyPairSubkeyTab::create_subkey_opera_menu() {
diff --git a/src/ui/dialog/keypair_details/KeySetExpireDateDialog.cpp b/src/ui/dialog/keypair_details/KeySetExpireDateDialog.cpp
index d09662e1..89d2ce74 100644
--- a/src/ui/dialog/keypair_details/KeySetExpireDateDialog.cpp
+++ b/src/ui/dialog/keypair_details/KeySetExpireDateDialog.cpp
@@ -79,7 +79,7 @@ void KeySetExpireDateDialog::slot_confirm() {
auto err = GpgKeyOpera::GetInstance().SetExpire(m_key_, m_subkey_, expires);
if (check_gpg_error_2_err_code(err) == GPG_ERR_NO_ERROR) {
- auto* msg_box = new QMessageBox((QWidget*)this->parent());
+ auto* msg_box = new QMessageBox(qobject_cast<QWidget*>(this->parent()));
msg_box->setAttribute(Qt::WA_DeleteOnClose);
msg_box->setStandardButtons(QMessageBox::Ok);
msg_box->setWindowTitle(_("Success"));
diff --git a/src/ui/dialog/settings/SettingsGeneral.cpp b/src/ui/dialog/settings/SettingsGeneral.cpp
index 7e48b4e1..17d9251c 100644
--- a/src/ui/dialog/settings/SettingsGeneral.cpp
+++ b/src/ui/dialog/settings/SettingsGeneral.cpp
@@ -47,7 +47,7 @@ GeneralTab::GeneralTab(QWidget* parent)
ui_->saveCheckedKeysCheckBox->setText(
_("Save checked private keys on exit and restore them on next start."));
ui_->clearGpgPasswordCacheCheckBox->setText(
- "Clear gpg password cache when closing GpgFrontend.");
+ _("Clear gpg password cache when closing GpgFrontend."));
ui_->importConfirmationBox->setTitle(_("Operation"));
ui_->longerKeyExpirationDateCheckBox->setText(
@@ -57,6 +57,8 @@ GeneralTab::GeneralTab(QWidget* parent)
ui_->gnupgDatabaseBox->setTitle(_("GnuPG"));
ui_->asciiModeCheckBox->setText(_("No ASCII Mode"));
+ ui_->usePinentryAsPasswordInputDialogCheckBox->setText(
+ _("Use Pinentry as Password Input Dialog"));
ui_->useCustomGnuPGInstallPathCheckBox->setText(_("Use Custom GnuPG"));
ui_->useCustomGnuPGInstallPathButton->setText(_("Select GnuPG Path"));
ui_->keyDatabseUseCustomCheckBox->setText(
@@ -167,6 +169,12 @@ GeneralTab::GeneralTab(QWidget* parent)
}
});
+ connect(ui_->usePinentryAsPasswordInputDialogCheckBox,
+ &QCheckBox::stateChanged, this, [=](int state) {
+ // announce the restart
+ this->slot_gnupg_stettings_changed();
+ });
+
SetSettings();
}
@@ -260,6 +268,16 @@ void GeneralTab::SetSettings() {
SPDLOG_ERROR("setting operation error: use_custom_gnupg_install_path");
}
+ try {
+ bool use_pinentry_as_password_input_dialog =
+ settings.lookup("general.use_pinentry_as_password_input_dialog");
+ if (use_pinentry_as_password_input_dialog)
+ ui_->usePinentryAsPasswordInputDialogCheckBox->setCheckState(Qt::Checked);
+ } catch (...) {
+ SPDLOG_ERROR(
+ "setting operation error: use_pinentry_as_password_input_dialog");
+ }
+
this->slot_update_custom_gnupg_install_path_label(
ui_->useCustomGnuPGInstallPathCheckBox->checkState());
}
@@ -343,6 +361,15 @@ void GeneralTab::ApplySettings() {
general["use_custom_gnupg_install_path"] =
ui_->useCustomGnuPGInstallPathCheckBox->isChecked();
}
+
+ if (!general.exists("use_pinentry_as_password_input_dialog"))
+ general.add("use_pinentry_as_password_input_dialog",
+ libconfig::Setting::TypeBoolean) =
+ ui_->usePinentryAsPasswordInputDialogCheckBox->isChecked();
+ else {
+ general["use_pinentry_as_password_input_dialog"] =
+ ui_->usePinentryAsPasswordInputDialogCheckBox->isChecked();
+ }
}
#ifdef MULTI_LANG_SUPPORT
diff --git a/src/ui/dialog/settings/SettingsKeyServer.cpp b/src/ui/dialog/settings/SettingsKeyServer.cpp
index 8719ab9a..83bd2c80 100644
--- a/src/ui/dialog/settings/SettingsKeyServer.cpp
+++ b/src/ui/dialog/settings/SettingsKeyServer.cpp
@@ -284,6 +284,11 @@ void KeyserverTab::slot_test_listed_key_server() {
Thread::TaskRunnerGetter::GetInstance()
.GetTaskRunner(Thread::TaskRunnerGetter::kTaskRunnerType_Network)
->PostTask(task);
+
+ QEventLoop loop;
+ connect(task, &Thread::Task::SignalTaskEnd, &loop, &QEventLoop::quit);
+ connect(waiting_dialog, &QProgressDialog::canceled, &loop, &QEventLoop::quit);
+ loop.exec();
}
void KeyserverTab::contextMenuEvent(QContextMenuEvent* event) {
diff --git a/src/ui/dialog/settings/SettingsNetwork.cpp b/src/ui/dialog/settings/SettingsNetwork.cpp
index fe3d450e..0713856d 100644
--- a/src/ui/dialog/settings/SettingsNetwork.cpp
+++ b/src/ui/dialog/settings/SettingsNetwork.cpp
@@ -29,7 +29,7 @@
#include "SettingsNetwork.h"
#include "core/function/GlobalSettingStation.h"
-#include "ui/thread/ProxyConnectionTestThread.h"
+#include "ui/thread/ProxyConnectionTestTask.h"
#include "ui_NetworkSettings.h"
GpgFrontend::UI::NetworkTab::NetworkTab(QWidget *parent)
@@ -37,7 +37,28 @@ GpgFrontend::UI::NetworkTab::NetworkTab(QWidget *parent)
ui_->setupUi(this);
connect(ui_->enableProxyCheckBox, &QCheckBox::stateChanged, this,
- [=](int state) { switch_ui_enabled(state == Qt::Checked); });
+ [=](int state) {
+ switch_ui_enabled(state == Qt::Checked);
+ // when selecting no proxy option, apply it immediately
+ if (state != Qt::Checked) apply_proxy_settings();
+ });
+
+ connect(
+ ui_->autoImportMissingKeyCheckBox, &QCheckBox::stateChanged, this,
+ [=](int state) {
+ ui_->forbidALLGnuPGNetworkConnectionCheckBox->setCheckState(
+ state == Qt::Checked
+ ? Qt::Unchecked
+ : ui_->forbidALLGnuPGNetworkConnectionCheckBox->checkState());
+ });
+
+ connect(ui_->forbidALLGnuPGNetworkConnectionCheckBox,
+ &QCheckBox::stateChanged, this, [=](int state) {
+ ui_->autoImportMissingKeyCheckBox->setCheckState(
+ state == Qt::Checked
+ ? Qt::Unchecked
+ : ui_->autoImportMissingKeyCheckBox->checkState());
+ });
connect(
ui_->proxyTypeComboBox, &QComboBox::currentTextChanged, this,
@@ -47,7 +68,7 @@ GpgFrontend::UI::NetworkTab::NetworkTab(QWidget *parent)
&NetworkTab::slot_test_proxy_connection_result);
ui_->proxyGroupBox->setTitle(_("Proxy"));
- ui_->capabilityGroupBox->setTitle(_("Network Capability"));
+ ui_->capabilityGroupBox->setTitle(_("Network Ability"));
ui_->operationsGroupBox->setTitle(_("Operations"));
ui_->enableProxyCheckBox->setText(_("Enable Proxy"));
@@ -59,12 +80,18 @@ GpgFrontend::UI::NetworkTab::NetworkTab(QWidget *parent)
ui_->usernameLabel->setText(_("Username"));
ui_->passwordLabel->setText(_("Password"));
- ui_->forbidALLCheckBox->setText(_("Forbid all network connection."));
- ui_->forbidALLCheckBox->setDisabled(true);
+ ui_->checkProxyConnectionButton->setText(
+ _("Apply Proxy Settings and Check Proxy Connection"));
+ ui_->forbidALLGnuPGNetworkConnectionCheckBox->setText(
+ _("Forbid all GnuPG network connection."));
ui_->prohibitUpdateCheck->setText(
_("Prohibit checking for version updates when the program starts."));
- ui_->checkProxyConnectionButton->setText(_("Check Proxy Connection"));
+ ui_->autoImportMissingKeyCheckBox->setText(
+ _("Automatically import a missing key for signature verification."));
+ ui_->networkAbilityTipsLabel->setText(
+ _("Tips: These Option Changes take effect only after the "
+ "application restart."));
SetSettings();
}
@@ -120,21 +147,17 @@ void GpgFrontend::UI::NetworkTab::SetSettings() {
SPDLOG_ERROR("setting operation error: proxy_enable");
}
- {
- auto state = ui_->enableProxyCheckBox->checkState();
- switch_ui_enabled(state == Qt::Checked);
- }
-
- ui_->forbidALLCheckBox->setCheckState(Qt::Unchecked);
+ ui_->forbidALLGnuPGNetworkConnectionCheckBox->setCheckState(Qt::Unchecked);
try {
- bool forbid_all_connection =
- settings.lookup("network.forbid_all_connection");
- if (forbid_all_connection)
- ui_->forbidALLCheckBox->setCheckState(Qt::Checked);
+ bool forbid_all_gnupg_connection =
+ settings.lookup("network.forbid_all_gnupg_connection");
+ if (forbid_all_gnupg_connection)
+ ui_->forbidALLGnuPGNetworkConnectionCheckBox->setCheckState(Qt::Checked);
else
- ui_->forbidALLCheckBox->setCheckState(Qt::Unchecked);
+ ui_->forbidALLGnuPGNetworkConnectionCheckBox->setCheckState(
+ Qt::Unchecked);
} catch (...) {
- SPDLOG_ERROR("setting operation error: forbid_all_connection");
+ SPDLOG_ERROR("setting operation error: forbid_all_gnupg_connection");
}
ui_->prohibitUpdateCheck->setCheckState(Qt::Unchecked);
@@ -148,6 +171,21 @@ void GpgFrontend::UI::NetworkTab::SetSettings() {
} catch (...) {
SPDLOG_ERROR("setting operation error: prohibit_update_checking");
}
+
+ ui_->autoImportMissingKeyCheckBox->setCheckState(Qt::Unchecked);
+ try {
+ bool auto_import_missing_key =
+ settings.lookup("network.auto_import_missing_key");
+ if (auto_import_missing_key)
+ ui_->autoImportMissingKeyCheckBox->setCheckState(Qt::Checked);
+ else
+ ui_->autoImportMissingKeyCheckBox->setCheckState(Qt::Unchecked);
+ } catch (...) {
+ SPDLOG_ERROR("setting operation error: auto_import_missing_key");
+ }
+
+ switch_ui_enabled(ui_->enableProxyCheckBox->isChecked());
+ switch_ui_proxy_type(ui_->proxyTypeComboBox->currentText());
}
void GpgFrontend::UI::NetworkTab::ApplySettings() {
@@ -207,11 +245,13 @@ void GpgFrontend::UI::NetworkTab::ApplySettings() {
auto &network = settings["network"];
- if (!network.exists("forbid_all_connection"))
- network.add("forbid_all_connection", libconfig::Setting::TypeBoolean) =
- ui_->forbidALLCheckBox->isChecked();
+ if (!network.exists("forbid_all_gnupg_connection"))
+ network.add("forbid_all_gnupg_connection",
+ libconfig::Setting::TypeBoolean) =
+ ui_->forbidALLGnuPGNetworkConnectionCheckBox->isChecked();
else {
- network["forbid_all_connection"] = ui_->forbidALLCheckBox->isChecked();
+ network["forbid_all_gnupg_connection"] =
+ ui_->forbidALLGnuPGNetworkConnectionCheckBox->isChecked();
}
if (!network.exists("prohibit_update_checking"))
@@ -221,6 +261,14 @@ void GpgFrontend::UI::NetworkTab::ApplySettings() {
network["prohibit_update_checking"] = ui_->prohibitUpdateCheck->isChecked();
}
+ if (!network.exists("auto_import_missing_key"))
+ network.add("auto_import_missing_key", libconfig::Setting::TypeBoolean) =
+ ui_->autoImportMissingKeyCheckBox->isChecked();
+ else {
+ network["auto_import_missing_key"] =
+ ui_->autoImportMissingKeyCheckBox->isChecked();
+ }
+
apply_proxy_settings();
}
@@ -232,9 +280,9 @@ void GpgFrontend::UI::NetworkTab::slot_test_proxy_connection_result() {
tr("Server Url"), QLineEdit::Normal,
"https://", &ok);
if (ok && !url.isEmpty()) {
- auto thread = new ProxyConnectionTestThread(url, 800, this);
- connect(thread,
- &GpgFrontend::UI::ProxyConnectionTestThread::
+ auto task = new ProxyConnectionTestTask(url, 800);
+ connect(task,
+ &GpgFrontend::UI::ProxyConnectionTestTask::
SignalProxyConnectionTestResult,
this, [=](const QString &result) {
if (result == "Reachable") {
@@ -248,7 +296,6 @@ void GpgFrontend::UI::NetworkTab::slot_test_proxy_connection_result() {
"proxy server. Proxy settings may be invalid."));
}
});
- connect(thread, &QThread::finished, thread, &QThread::deleteLater);
// Waiting Dialog
auto *waiting_dialog = new QProgressDialog(this);
@@ -261,43 +308,43 @@ void GpgFrontend::UI::NetworkTab::slot_test_proxy_connection_result() {
waiting_dialog_label->setWordWrap(true);
waiting_dialog->setLabel(waiting_dialog_label);
waiting_dialog->resize(420, 120);
- connect(thread, &QThread::finished, [=]() {
- waiting_dialog->finished(0);
+ connect(task, &Thread::Task::SignalTaskEnd, [=]() {
+ waiting_dialog->close();
waiting_dialog->deleteLater();
});
- connect(waiting_dialog, &QProgressDialog::canceled, [=]() {
- SPDLOG_DEBUG("cancel clicked");
- if (thread->isRunning()) thread->terminate();
- });
// Show Waiting Dialog
waiting_dialog->show();
waiting_dialog->setFocus();
- thread->start();
+ Thread::TaskRunnerGetter::GetInstance()
+ .GetTaskRunner(Thread::TaskRunnerGetter::kTaskRunnerType_Network)
+ ->PostTask(task);
+
QEventLoop loop;
- connect(thread, &QThread::finished, &loop, &QEventLoop::quit);
+ connect(task, &Thread::Task::SignalTaskEnd, &loop, &QEventLoop::quit);
+ connect(waiting_dialog, &QProgressDialog::canceled, &loop,
+ &QEventLoop::quit);
loop.exec();
}
}
void GpgFrontend::UI::NetworkTab::apply_proxy_settings() {
// apply settings
- QNetworkProxy _proxy;
+ QNetworkProxy proxy;
if (ui_->enableProxyCheckBox->isChecked() &&
proxy_type_ != QNetworkProxy::DefaultProxy) {
- _proxy.setType(proxy_type_);
- _proxy.setHostName(ui_->proxyServerAddressEdit->text());
- _proxy.setPort(ui_->portSpin->value());
+ proxy.setType(proxy_type_);
+ proxy.setHostName(ui_->proxyServerAddressEdit->text());
+ proxy.setPort(ui_->portSpin->value());
if (!ui_->usernameEdit->text().isEmpty()) {
- _proxy.setUser(ui_->usernameEdit->text());
- _proxy.setPassword(ui_->passwordEdit->text());
+ proxy.setUser(ui_->usernameEdit->text());
+ proxy.setPassword(ui_->passwordEdit->text());
}
} else {
- _proxy.setType(proxy_type_);
+ proxy.setType(proxy_type_);
}
-
- QNetworkProxy::setApplicationProxy(_proxy);
+ QNetworkProxy::setApplicationProxy(proxy);
}
void GpgFrontend::UI::NetworkTab::switch_ui_enabled(bool enabled) {