fix: discover and fix some bugs
This commit is contained in:
parent
bb6488d84c
commit
9ea9c03263
@ -131,7 +131,7 @@ auto StartApplication(InitArgs args) -> int {
|
||||
SPDLOG_INFO("GpgFrontend is about to exit.");
|
||||
|
||||
// deep restart mode
|
||||
if (return_from_event_loop_code == GpgFrontend::kRestartCode ||
|
||||
if (return_from_event_loop_code == GpgFrontend::kDeepRestartCode ||
|
||||
return_from_event_loop_code == kCrashCode) {
|
||||
// log for debug
|
||||
SPDLOG_DEBUG(
|
||||
|
@ -54,7 +54,7 @@ class GPGFRONTEND_CORE_EXPORT CoreSignalStation : public QObject {
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
void SignalUserInputPassphraseDone(QString passparase);
|
||||
void SignalUserInputPassphraseDone();
|
||||
|
||||
/**
|
||||
* @brief
|
||||
|
@ -30,6 +30,8 @@
|
||||
|
||||
#include <gpg-error.h>
|
||||
#include <gpgme.h>
|
||||
#include <qeventloop.h>
|
||||
#include <qobject.h>
|
||||
#include <unistd.h>
|
||||
|
||||
#include "core/function/CoreSignalStation.h"
|
||||
@ -42,6 +44,7 @@
|
||||
#include "core/utils/CacheUtils.h"
|
||||
#include "core/utils/CommonUtils.h"
|
||||
#include "core/utils/GpgUtils.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
|
||||
#ifdef _WIN32
|
||||
#include <windows.h>
|
||||
@ -256,8 +259,15 @@ class GpgContext::Impl : public SingletonFunctionObject<GpgContext::Impl> {
|
||||
if (passphrase.empty()) {
|
||||
// user input passphrase
|
||||
SPDLOG_DEBUG("might need user to input passparase");
|
||||
passphrase = p_ctx->ShowPasswordInputDialog();
|
||||
|
||||
p_ctx->ShowPasswordInputDialog();
|
||||
passphrase = GetTempCacheValue("__key_passphrase");
|
||||
|
||||
SPDLOG_DEBUG("use may has inputed the passphrase");
|
||||
|
||||
if (passphrase.empty()) {
|
||||
SPDLOG_ERROR("cannot get passphrase from use or passphrase is empty");
|
||||
|
||||
gpgme_io_write(fd, "\n", 1);
|
||||
return gpgme_error_from_errno(GPG_ERR_CANCELED);
|
||||
}
|
||||
@ -285,27 +295,16 @@ class GpgContext::Impl : public SingletonFunctionObject<GpgContext::Impl> {
|
||||
return GPG_ERR_NO_ERROR;
|
||||
}
|
||||
|
||||
auto ShowPasswordInputDialog() -> std::string {
|
||||
void ShowPasswordInputDialog() {
|
||||
emit parent_->SignalNeedUserInputPassphrase();
|
||||
|
||||
std::string final_passphrase;
|
||||
bool input_done = false;
|
||||
SPDLOG_DEBUG("loop start to wait from user");
|
||||
auto connection = QObject::connect(
|
||||
CoreSignalStation::GetInstance(),
|
||||
&CoreSignalStation::SignalUserInputPassphraseDone, parent_,
|
||||
[&](const QString &passphrase) {
|
||||
SPDLOG_DEBUG("SignalUserInputPassphraseDone emitted");
|
||||
final_passphrase = passphrase.toStdString();
|
||||
input_done = true;
|
||||
});
|
||||
while (!input_done) {
|
||||
QCoreApplication::processEvents(QEventLoop::AllEvents, 800);
|
||||
}
|
||||
QObject::disconnect(connection);
|
||||
QEventLoop looper;
|
||||
QObject::connect(CoreSignalStation::GetInstance(),
|
||||
&CoreSignalStation::SignalUserInputPassphraseDone, &looper,
|
||||
&QEventLoop::quit);
|
||||
looper.exec();
|
||||
|
||||
SPDLOG_DEBUG("lopper end");
|
||||
return final_passphrase;
|
||||
SPDLOG_DEBUG("show password input dialog done");
|
||||
}
|
||||
|
||||
private:
|
||||
@ -390,7 +389,7 @@ GpgContext::operator gpgme_ctx_t() const {
|
||||
return static_cast<gpgme_ctx_t>(*p_);
|
||||
}
|
||||
|
||||
auto GpgContext::ShowPasswordInputDialog() -> std::string {
|
||||
void GpgContext::ShowPasswordInputDialog() {
|
||||
return p_->ShowPasswordInputDialog();
|
||||
}
|
||||
|
||||
|
@ -71,7 +71,7 @@ class GPGFRONTEND_CORE_EXPORT GpgContext
|
||||
|
||||
void SetPassphraseCb(gpgme_passphrase_cb_t passphrase_cb) const;
|
||||
|
||||
auto ShowPasswordInputDialog() -> std::string;
|
||||
void ShowPasswordInputDialog();
|
||||
|
||||
signals:
|
||||
void SignalNeedUserInputPassphrase();
|
||||
|
@ -28,17 +28,15 @@
|
||||
|
||||
#include "SignalStation.h"
|
||||
|
||||
#include "ui/UserInterfaceUtils.h"
|
||||
|
||||
namespace GpgFrontend::UI {
|
||||
|
||||
std::unique_ptr<SignalStation> SignalStation::_instance = nullptr;
|
||||
std::unique_ptr<SignalStation> SignalStation::instance = nullptr;
|
||||
|
||||
SignalStation* SignalStation::GetInstance() {
|
||||
if (_instance == nullptr) {
|
||||
_instance = std::make_unique<SignalStation>();
|
||||
auto SignalStation::GetInstance() -> SignalStation* {
|
||||
if (instance == nullptr) {
|
||||
instance = std::make_unique<SignalStation>();
|
||||
}
|
||||
return _instance.get();
|
||||
return instance.get();
|
||||
}
|
||||
|
||||
} // namespace GpgFrontend::UI
|
||||
|
@ -28,7 +28,6 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ui/GpgFrontendUI.h"
|
||||
#include "ui/widgets/InfoBoardWidget.h"
|
||||
|
||||
namespace GpgFrontend::UI {
|
||||
@ -39,7 +38,7 @@ namespace GpgFrontend::UI {
|
||||
*/
|
||||
class SignalStation : public QObject {
|
||||
Q_OBJECT
|
||||
static std::unique_ptr<SignalStation> _instance;
|
||||
static std::unique_ptr<SignalStation> instance;
|
||||
|
||||
public:
|
||||
/**
|
||||
@ -47,7 +46,7 @@ class SignalStation : public QObject {
|
||||
*
|
||||
* @return SignalStation*
|
||||
*/
|
||||
static SignalStation* GetInstance();
|
||||
static auto GetInstance() -> SignalStation*;
|
||||
|
||||
signals:
|
||||
/**
|
||||
|
@ -36,13 +36,14 @@
|
||||
#include "core/GpgConstants.h"
|
||||
#include "core/function/CacheManager.h"
|
||||
#include "core/function/CoreSignalStation.h"
|
||||
#include "core/function/GlobalSettingStation.h"
|
||||
#include "core/function/gpg/GpgKeyGetter.h"
|
||||
#include "core/module/ModuleManager.h"
|
||||
#include "core/thread/Task.h"
|
||||
#include "core/thread/TaskRunner.h"
|
||||
#include "core/thread/TaskRunnerGetter.h"
|
||||
#include "core/utils/CacheUtils.h"
|
||||
#include "core/utils/IOUtils.h"
|
||||
#include "spdlog/spdlog.h"
|
||||
#include "ui/SignalStation.h"
|
||||
#include "ui/dialog/WaitingDialog.h"
|
||||
#include "ui/dialog/gnupg/GnuPGControllerDialog.h"
|
||||
@ -436,7 +437,7 @@ void CommonUtils::SlotImportKeyFromKeyServer(
|
||||
}
|
||||
|
||||
void CommonUtils::slot_update_key_status() {
|
||||
auto refresh_task = new Thread::Task(
|
||||
auto *refresh_task = new Thread::Task(
|
||||
[](DataObjectPtr) -> int {
|
||||
// flush key cache for all GpgKeyGetter Intances.
|
||||
for (const auto &channel_id : GpgKeyGetter::GetAllChannelId()) {
|
||||
@ -446,8 +447,7 @@ void CommonUtils::slot_update_key_status() {
|
||||
},
|
||||
"update_key_database_task");
|
||||
connect(refresh_task, &Thread::Task::SignalTaskEnd, this,
|
||||
&CommonUtils::SignalKeyDatabaseRefreshDone,
|
||||
Qt::BlockingQueuedConnection);
|
||||
&CommonUtils::SignalKeyDatabaseRefreshDone);
|
||||
|
||||
// post the task to the default task runner
|
||||
Thread::TaskRunnerGetter::GetInstance().GetTaskRunner()->PostTask(
|
||||
@ -464,11 +464,10 @@ void CommonUtils::slot_popup_passphrase_input_dialog() {
|
||||
dialog->resize(500, 80);
|
||||
dialog->exec();
|
||||
|
||||
QString password = dialog->textValue();
|
||||
dialog->deleteLater();
|
||||
SetTempCacheValue("__key_passphrase", dialog->textValue().toStdString());
|
||||
|
||||
// send signal
|
||||
emit SignalUserInputPassphraseDone(password);
|
||||
emit SignalUserInputPassphraseDone();
|
||||
}
|
||||
|
||||
void CommonUtils::SlotRestartApplication(int code) {
|
||||
|
@ -198,7 +198,7 @@ class CommonUtils : public QWidget {
|
||||
* @brief
|
||||
*
|
||||
*/
|
||||
void SignalUserInputPassphraseDone(QString passphrase);
|
||||
void SignalUserInputPassphraseDone();
|
||||
|
||||
/**
|
||||
* @brief
|
||||
|
@ -166,7 +166,7 @@ void KeyGenDialog::slot_key_gen_accept() {
|
||||
ResetTempCacheValue("__key_passphrase");
|
||||
}
|
||||
|
||||
SPDLOG_DEBUG("generate done");
|
||||
SPDLOG_DEBUG("key generation done");
|
||||
|
||||
if (gpgme_err_code(error) == GPG_ERR_NO_ERROR) {
|
||||
auto* msg_box = new QMessageBox(qobject_cast<QWidget*>(this->parent()));
|
||||
@ -177,14 +177,15 @@ void KeyGenDialog::slot_key_gen_accept() {
|
||||
msg_box->setModal(true);
|
||||
msg_box->open();
|
||||
|
||||
SPDLOG_DEBUG("generate success");
|
||||
SPDLOG_DEBUG("key generate successful");
|
||||
|
||||
emit SignalKeyGenerated();
|
||||
this->close();
|
||||
} else {
|
||||
QMessageBox::critical(this, _("Failure"), _("Key generation failed."));
|
||||
}
|
||||
|
||||
this->done(0);
|
||||
|
||||
} else {
|
||||
/**
|
||||
* create error message
|
||||
@ -200,7 +201,7 @@ void KeyGenDialog::slot_key_gen_accept() {
|
||||
}
|
||||
|
||||
void KeyGenDialog::slot_expire_box_changed() {
|
||||
if (expire_check_box_->checkState()) {
|
||||
if (expire_check_box_->checkState() != 0U) {
|
||||
date_edit_->setEnabled(false);
|
||||
} else {
|
||||
date_edit_->setEnabled(true);
|
||||
|
@ -45,32 +45,32 @@ KeyPairUIDTab::KeyPairUIDTab(const std::string& key_id, QWidget* parent)
|
||||
create_uid_popup_menu();
|
||||
create_sign_popup_menu();
|
||||
|
||||
auto uidButtonsLayout = new QGridLayout();
|
||||
auto* uid_buttons_layout = new QGridLayout();
|
||||
|
||||
auto addUIDButton = new QPushButton(_("New UID"));
|
||||
auto manageUIDButton = new QPushButton(_("UID Management"));
|
||||
auto* add_uid_button = new QPushButton(_("New UID"));
|
||||
auto manage_uid_button = new QPushButton(_("UID Management"));
|
||||
|
||||
if (m_key_.IsHasMasterKey()) {
|
||||
manageUIDButton->setMenu(manage_selected_uid_menu_);
|
||||
manage_uid_button->setMenu(manage_selected_uid_menu_);
|
||||
} else {
|
||||
manageUIDButton->setDisabled(true);
|
||||
manage_uid_button->setDisabled(true);
|
||||
}
|
||||
|
||||
uidButtonsLayout->addWidget(addUIDButton, 0, 1);
|
||||
uidButtonsLayout->addWidget(manageUIDButton, 0, 2);
|
||||
uid_buttons_layout->addWidget(add_uid_button, 0, 1);
|
||||
uid_buttons_layout->addWidget(manage_uid_button, 0, 2);
|
||||
|
||||
auto grid_layout = new QGridLayout();
|
||||
auto* grid_layout = new QGridLayout();
|
||||
|
||||
grid_layout->addWidget(uid_list_, 0, 0);
|
||||
grid_layout->addLayout(uidButtonsLayout, 1, 0);
|
||||
grid_layout->addLayout(uid_buttons_layout, 1, 0);
|
||||
grid_layout->setContentsMargins(0, 10, 0, 0);
|
||||
|
||||
auto uid_group_box = new QGroupBox();
|
||||
auto* uid_group_box = new QGroupBox();
|
||||
uid_group_box->setLayout(grid_layout);
|
||||
uid_group_box->setTitle(_("UIDs"));
|
||||
|
||||
auto tofu_group_box = new QGroupBox();
|
||||
auto tofu_vbox_layout = new QVBoxLayout();
|
||||
auto* tofu_group_box = new QGroupBox();
|
||||
auto* tofu_vbox_layout = new QVBoxLayout();
|
||||
tofu_group_box->setLayout(tofu_vbox_layout);
|
||||
tofu_group_box->setTitle(_("TOFU"));
|
||||
#if !defined(RELEASE)
|
||||
@ -78,25 +78,25 @@ KeyPairUIDTab::KeyPairUIDTab(const std::string& key_id, QWidget* parent)
|
||||
tofu_vbox_layout->addWidget(tofu_tabs_);
|
||||
#endif
|
||||
|
||||
auto sign_grid_layout = new QGridLayout();
|
||||
auto* sign_grid_layout = new QGridLayout();
|
||||
sign_grid_layout->addWidget(sig_list_, 0, 0);
|
||||
sign_grid_layout->setContentsMargins(0, 10, 0, 0);
|
||||
|
||||
auto sign_group_box = new QGroupBox();
|
||||
auto* sign_group_box = new QGroupBox();
|
||||
sign_group_box->setLayout(sign_grid_layout);
|
||||
sign_group_box->setTitle(_("Signature of Selected UID"));
|
||||
|
||||
auto vboxLayout = new QVBoxLayout();
|
||||
vboxLayout->addWidget(uid_group_box);
|
||||
auto* vbox_layout = new QVBoxLayout();
|
||||
vbox_layout->addWidget(uid_group_box);
|
||||
#if !defined(RELEASE)
|
||||
// Function needed testing
|
||||
vboxLayout->addWidget(tofu_group_box);
|
||||
vbox_layout->addWidget(tofu_group_box);
|
||||
#endif
|
||||
vboxLayout->addWidget(sign_group_box);
|
||||
vbox_layout->addWidget(sign_group_box);
|
||||
|
||||
vboxLayout->setContentsMargins(0, 0, 0, 0);
|
||||
vbox_layout->setContentsMargins(0, 0, 0, 0);
|
||||
|
||||
connect(addUIDButton, &QPushButton::clicked, this,
|
||||
connect(add_uid_button, &QPushButton::clicked, this,
|
||||
&KeyPairUIDTab::slot_add_uid);
|
||||
connect(uid_list_, &QTableWidget::itemSelectionChanged, this,
|
||||
&KeyPairUIDTab::slot_refresh_tofu_info);
|
||||
@ -112,7 +112,7 @@ KeyPairUIDTab::KeyPairUIDTab(const std::string& key_id, QWidget* parent)
|
||||
SignalStation::GetInstance(),
|
||||
&SignalStation::SignalKeyDatabaseRefresh);
|
||||
|
||||
setLayout(vboxLayout);
|
||||
setLayout(vbox_layout);
|
||||
setAttribute(Qt::WA_DeleteOnClose, true);
|
||||
|
||||
slot_refresh_uid_list();
|
||||
@ -184,13 +184,13 @@ void KeyPairUIDTab::slot_refresh_uid_list() {
|
||||
uid_list_->setRowCount(buffered_uids_.size());
|
||||
|
||||
for (const auto& uid : buffered_uids_) {
|
||||
auto* tmp0 = new QTableWidgetItem(QString::fromStdString(uid.GetUID()));
|
||||
auto* tmp0 = new QTableWidgetItem(QString::fromStdString(uid.GetName()));
|
||||
uid_list_->setItem(row, 1, tmp0);
|
||||
|
||||
auto* tmp1 = new QTableWidgetItem(QString::fromStdString(uid.GetUID()));
|
||||
auto* tmp1 = new QTableWidgetItem(QString::fromStdString(uid.GetEmail()));
|
||||
uid_list_->setItem(row, 2, tmp1);
|
||||
|
||||
auto* tmp2 = new QTableWidgetItem(QString::fromStdString(uid.GetUID()));
|
||||
auto* tmp2 = new QTableWidgetItem(QString::fromStdString(uid.GetComment()));
|
||||
uid_list_->setItem(row, 3, tmp2);
|
||||
|
||||
auto* tmp3 = new QTableWidgetItem(QString::number(row));
|
||||
@ -243,10 +243,11 @@ void KeyPairUIDTab::slot_refresh_tofu_info() {
|
||||
}
|
||||
|
||||
void KeyPairUIDTab::slot_refresh_sig_list() {
|
||||
int uidRow = 0, sigRow = 0;
|
||||
int uid_row = 0;
|
||||
int sig_row = 0;
|
||||
for (const auto& uid : buffered_uids_) {
|
||||
// Only Show Selected UID Signatures
|
||||
if (!uid_list_->item(uidRow++, 0)->isSelected()) {
|
||||
if (!uid_list_->item(uid_row++, 0)->isSelected()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -263,22 +264,22 @@ void KeyPairUIDTab::slot_refresh_sig_list() {
|
||||
|
||||
for (const auto& sig : buffered_signatures_) {
|
||||
auto* tmp0 = new QTableWidgetItem(QString::fromStdString(sig.GetKeyID()));
|
||||
sig_list_->setItem(sigRow, 0, tmp0);
|
||||
sig_list_->setItem(sig_row, 0, tmp0);
|
||||
|
||||
if (gpgme_err_code(sig.GetStatus()) == GPG_ERR_NO_PUBKEY) {
|
||||
auto* tmp2 = new QTableWidgetItem("<Unknown>");
|
||||
sig_list_->setItem(sigRow, 1, tmp2);
|
||||
sig_list_->setItem(sig_row, 1, tmp2);
|
||||
|
||||
auto* tmp3 = new QTableWidgetItem("<Unknown>");
|
||||
sig_list_->setItem(sigRow, 2, tmp3);
|
||||
sig_list_->setItem(sig_row, 2, tmp3);
|
||||
} else {
|
||||
auto* tmp2 =
|
||||
new QTableWidgetItem(QString::fromStdString(sig.GetName()));
|
||||
sig_list_->setItem(sigRow, 1, tmp2);
|
||||
sig_list_->setItem(sig_row, 1, tmp2);
|
||||
|
||||
auto* tmp3 =
|
||||
new QTableWidgetItem(QString::fromStdString(sig.GetEmail()));
|
||||
sig_list_->setItem(sigRow, 2, tmp3);
|
||||
sig_list_->setItem(sig_row, 2, tmp3);
|
||||
}
|
||||
#ifdef GPGFRONTEND_GUI_QT6
|
||||
auto* tmp4 = new QTableWidgetItem(QLocale::system().toString(
|
||||
@ -287,12 +288,11 @@ void KeyPairUIDTab::slot_refresh_sig_list() {
|
||||
auto* tmp4 = new QTableWidgetItem(QLocale::system().toString(
|
||||
QDateTime::fromTime_t(to_time_t(sig.GetCreateTime()))));
|
||||
#endif
|
||||
sig_list_->setItem(sigRow, 3, tmp4);
|
||||
sig_list_->setItem(sig_row, 3, tmp4);
|
||||
|
||||
#ifdef GPGFRONTEND_GUI_QT6
|
||||
auto* tmp5 = new QTableWidgetItem(
|
||||
boost::posix_time::to_time_t(
|
||||
boost::posix_time::ptime(sig.GetExpireTime())) == 0
|
||||
boost::posix_time::to_time_t(sig.GetExpireTime()) == 0
|
||||
? _("Never Expires")
|
||||
: QLocale::system().toString(QDateTime::fromSecsSinceEpoch(
|
||||
to_time_t(sig.GetExpireTime()))));
|
||||
@ -305,9 +305,9 @@ void KeyPairUIDTab::slot_refresh_sig_list() {
|
||||
QDateTime::fromTime_t(to_time_t(sig.GetExpireTime()))));
|
||||
#endif
|
||||
tmp5->setTextAlignment(Qt::AlignCenter);
|
||||
sig_list_->setItem(sigRow, 4, tmp5);
|
||||
sig_list_->setItem(sig_row, 4, tmp5);
|
||||
|
||||
sigRow++;
|
||||
sig_row++;
|
||||
}
|
||||
|
||||
break;
|
||||
@ -324,16 +324,17 @@ void KeyPairUIDTab::slot_add_sign() {
|
||||
return;
|
||||
}
|
||||
|
||||
auto keySignDialog =
|
||||
auto* key_sign_dialog =
|
||||
new KeyUIDSignDialog(m_key_, std::move(selected_uids), this);
|
||||
keySignDialog->show();
|
||||
key_sign_dialog->show();
|
||||
}
|
||||
|
||||
UIDArgsListPtr KeyPairUIDTab::get_uid_checked() {
|
||||
auto KeyPairUIDTab::get_uid_checked() -> UIDArgsListPtr {
|
||||
auto selected_uids = std::make_unique<UIDArgsList>();
|
||||
for (int i = 0; i < uid_list_->rowCount(); i++) {
|
||||
if (uid_list_->item(i, 0)->checkState() == Qt::Checked)
|
||||
if (uid_list_->item(i, 0)->checkState() == Qt::Checked) {
|
||||
selected_uids->push_back(buffered_uids_[i].GetUID());
|
||||
}
|
||||
}
|
||||
return selected_uids;
|
||||
}
|
||||
@ -341,24 +342,25 @@ UIDArgsListPtr KeyPairUIDTab::get_uid_checked() {
|
||||
void KeyPairUIDTab::create_manage_uid_menu() {
|
||||
manage_selected_uid_menu_ = new QMenu(this);
|
||||
|
||||
auto* signUIDAct = new QAction(_("Sign Selected UID(s)"), this);
|
||||
connect(signUIDAct, &QAction::triggered, this, &KeyPairUIDTab::slot_add_sign);
|
||||
auto* delUIDAct = new QAction(_("Delete Selected UID(s)"), this);
|
||||
connect(delUIDAct, &QAction::triggered, this, &KeyPairUIDTab::slot_del_uid);
|
||||
auto* sign_uid_act = new QAction(_("Sign Selected UID(s)"), this);
|
||||
connect(sign_uid_act, &QAction::triggered, this,
|
||||
&KeyPairUIDTab::slot_add_sign);
|
||||
auto* del_uid_act = new QAction(_("Delete Selected UID(s)"), this);
|
||||
connect(del_uid_act, &QAction::triggered, this, &KeyPairUIDTab::slot_del_uid);
|
||||
|
||||
if (m_key_.IsHasMasterKey()) {
|
||||
manage_selected_uid_menu_->addAction(signUIDAct);
|
||||
manage_selected_uid_menu_->addAction(delUIDAct);
|
||||
manage_selected_uid_menu_->addAction(sign_uid_act);
|
||||
manage_selected_uid_menu_->addAction(del_uid_act);
|
||||
}
|
||||
}
|
||||
|
||||
void KeyPairUIDTab::slot_add_uid() {
|
||||
auto keyNewUIDDialog = new KeyNewUIDDialog(m_key_.GetId(), this);
|
||||
connect(keyNewUIDDialog, &KeyNewUIDDialog::finished, this,
|
||||
auto* key_new_uid_dialog = new KeyNewUIDDialog(m_key_.GetId(), this);
|
||||
connect(key_new_uid_dialog, &KeyNewUIDDialog::finished, this,
|
||||
&KeyPairUIDTab::slot_add_uid_result);
|
||||
connect(keyNewUIDDialog, &KeyNewUIDDialog::finished, keyNewUIDDialog,
|
||||
connect(key_new_uid_dialog, &KeyNewUIDDialog::finished, key_new_uid_dialog,
|
||||
&KeyPairUIDTab::deleteLater);
|
||||
keyNewUIDDialog->show();
|
||||
key_new_uid_dialog->show();
|
||||
}
|
||||
|
||||
void KeyPairUIDTab::slot_add_uid_result(int result) {
|
||||
@ -414,9 +416,10 @@ void KeyPairUIDTab::slot_set_primary_uid() {
|
||||
auto selected_uids = get_uid_selected();
|
||||
|
||||
if (selected_uids->empty()) {
|
||||
auto emptyUIDMsg = new QMessageBox();
|
||||
emptyUIDMsg->setText("Please select one UID before doing this operation.");
|
||||
emptyUIDMsg->exec();
|
||||
auto* empty_uid_msg = new QMessageBox();
|
||||
empty_uid_msg->setText(
|
||||
"Please select one UID before doing this operation.");
|
||||
empty_uid_msg->exec();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -444,7 +447,7 @@ void KeyPairUIDTab::slot_set_primary_uid() {
|
||||
}
|
||||
}
|
||||
|
||||
UIDArgsListPtr KeyPairUIDTab::get_uid_selected() {
|
||||
auto KeyPairUIDTab::get_uid_selected() -> UIDArgsListPtr {
|
||||
auto uids = std::make_unique<UIDArgsList>();
|
||||
for (int i = 0; i < uid_list_->rowCount(); i++) {
|
||||
if (uid_list_->item(i, 0)->isSelected()) {
|
||||
@ -454,7 +457,7 @@ UIDArgsListPtr KeyPairUIDTab::get_uid_selected() {
|
||||
return uids;
|
||||
}
|
||||
|
||||
SignIdArgsListPtr KeyPairUIDTab::get_sign_selected() {
|
||||
auto KeyPairUIDTab::get_sign_selected() -> SignIdArgsListPtr {
|
||||
auto signatures = std::make_unique<SignIdArgsList>();
|
||||
for (int i = 0; i < sig_list_->rowCount(); i++) {
|
||||
if (sig_list_->item(i, 0)->isSelected()) {
|
||||
@ -468,20 +471,20 @@ SignIdArgsListPtr KeyPairUIDTab::get_sign_selected() {
|
||||
void KeyPairUIDTab::create_uid_popup_menu() {
|
||||
uid_popup_menu_ = new QMenu(this);
|
||||
|
||||
auto* serPrimaryUIDAct = new QAction(_("Set As Primary"), this);
|
||||
connect(serPrimaryUIDAct, &QAction::triggered, this,
|
||||
auto* ser_primary_uid_act = new QAction(_("Set As Primary"), this);
|
||||
connect(ser_primary_uid_act, &QAction::triggered, this,
|
||||
&KeyPairUIDTab::slot_set_primary_uid);
|
||||
auto* signUIDAct = new QAction(_("Sign UID"), this);
|
||||
connect(signUIDAct, &QAction::triggered, this,
|
||||
auto* sign_uid_act = new QAction(_("Sign UID"), this);
|
||||
connect(sign_uid_act, &QAction::triggered, this,
|
||||
&KeyPairUIDTab::slot_add_sign_single);
|
||||
auto* delUIDAct = new QAction(_("Delete UID"), this);
|
||||
connect(delUIDAct, &QAction::triggered, this,
|
||||
auto* del_uid_act = new QAction(_("Delete UID"), this);
|
||||
connect(del_uid_act, &QAction::triggered, this,
|
||||
&KeyPairUIDTab::slot_del_uid_single);
|
||||
|
||||
if (m_key_.IsHasMasterKey()) {
|
||||
uid_popup_menu_->addAction(serPrimaryUIDAct);
|
||||
uid_popup_menu_->addAction(signUIDAct);
|
||||
uid_popup_menu_->addAction(delUIDAct);
|
||||
uid_popup_menu_->addAction(ser_primary_uid_act);
|
||||
uid_popup_menu_->addAction(sign_uid_act);
|
||||
uid_popup_menu_->addAction(del_uid_act);
|
||||
}
|
||||
}
|
||||
|
||||
@ -502,9 +505,9 @@ void KeyPairUIDTab::slot_add_sign_single() {
|
||||
return;
|
||||
}
|
||||
|
||||
auto keySignDialog =
|
||||
auto* key_sign_dialog =
|
||||
new KeyUIDSignDialog(m_key_, std::move(selected_uids), this);
|
||||
keySignDialog->show();
|
||||
key_sign_dialog->show();
|
||||
}
|
||||
|
||||
void KeyPairUIDTab::slot_del_uid_single() {
|
||||
@ -543,10 +546,11 @@ void KeyPairUIDTab::slot_del_uid_single() {
|
||||
void KeyPairUIDTab::create_sign_popup_menu() {
|
||||
sign_popup_menu_ = new QMenu(this);
|
||||
|
||||
auto* delSignAct = new QAction(_("Delete(Revoke) Key Signature"), this);
|
||||
connect(delSignAct, &QAction::triggered, this, &KeyPairUIDTab::slot_del_sign);
|
||||
auto* del_sign_act = new QAction(_("Delete(Revoke) Key Signature"), this);
|
||||
connect(del_sign_act, &QAction::triggered, this,
|
||||
&KeyPairUIDTab::slot_del_sign);
|
||||
|
||||
sign_popup_menu_->addAction(delSignAct);
|
||||
sign_popup_menu_->addAction(del_sign_act);
|
||||
}
|
||||
|
||||
void KeyPairUIDTab::slot_del_sign() {
|
||||
|
@ -31,8 +31,7 @@
|
||||
#include <string>
|
||||
#include <utility>
|
||||
|
||||
#include "core/function/gpg/GpgContext.h"
|
||||
#include "ui/dialog/import_export/KeyImportDetailDialog.h"
|
||||
#include "core/GpgModel.h"
|
||||
|
||||
class Ui_KeyList;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user