diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/core/model/GpgKeyGenerateInfo.cpp | 4 | ||||
-rw-r--r-- | src/core/model/GpgKeyGenerateInfo.h | 3 | ||||
-rw-r--r-- | src/ui/UserInterfaceUtils.cpp | 40 | ||||
-rw-r--r-- | src/ui/dialog/key_generate/KeyGenerateDialog.cpp | 13 | ||||
-rw-r--r-- | src/ui/function/GpgOperaHelper.cpp | 3 |
5 files changed, 12 insertions, 51 deletions
diff --git a/src/core/model/GpgKeyGenerateInfo.cpp b/src/core/model/GpgKeyGenerateInfo.cpp index a8dcbd19..b1dcaa7a 100644 --- a/src/core/model/GpgKeyGenerateInfo.cpp +++ b/src/core/model/GpgKeyGenerateInfo.cpp @@ -35,8 +35,8 @@ namespace GpgFrontend { -const KeyAlgo KeyGenerateInfo::kNoneAlgo = {"none", "None", "None", - 0, 0, "0.0.0"}; +const KeyAlgo KeyGenerateInfo::kNoneAlgo = { + "none", KeyGenerateInfo::tr("None"), "None", 0, 0, "0.0.0"}; const QContainer<KeyAlgo> KeyGenerateInfo::kPrimaryKeyAlgos = { kNoneAlgo, diff --git a/src/core/model/GpgKeyGenerateInfo.h b/src/core/model/GpgKeyGenerateInfo.h index 98902418..2956a00d 100644 --- a/src/core/model/GpgKeyGenerateInfo.h +++ b/src/core/model/GpgKeyGenerateInfo.h @@ -76,7 +76,8 @@ class GPGFRONTEND_CORE_EXPORT KeyAlgo { QString supported_version_; }; -class GPGFRONTEND_CORE_EXPORT KeyGenerateInfo { +class GPGFRONTEND_CORE_EXPORT KeyGenerateInfo : public QObject { + Q_OBJECT public: static const KeyAlgo kNoneAlgo; static const QContainer<KeyAlgo> kPrimaryKeyAlgos; diff --git a/src/ui/UserInterfaceUtils.cpp b/src/ui/UserInterfaceUtils.cpp index 379c2a2d..6ff044f0 100644 --- a/src/ui/UserInterfaceUtils.cpp +++ b/src/ui/UserInterfaceUtils.cpp @@ -51,23 +51,12 @@ #include "ui/dialog/controller/GnuPGControllerDialog.h" #include "ui/dialog/import_export/KeyServerImportDialog.h" #include "ui/struct/settings_object/KeyServerSO.h" -#include "ui/widgets/TextEdit.h" namespace GpgFrontend::UI { QScopedPointer<CommonUtils> CommonUtils::instance = QScopedPointer<CommonUtils>(nullptr); -void show_verify_details(QWidget *parent, int channel, - InfoBoardWidget *info_board, GpgError error, - const GpgVerifyResult &verify_result) { - // take out result - info_board->ResetOptionActionsMenu(); - info_board->AddOptionalAction( - QCoreApplication::tr("Show Verify Details"), - [=]() { VerifyDetailsDialog(parent, channel, error, verify_result); }); -} - void ImportUnknownKeyFromKeyserver( QWidget *parent, int channel, const GpgVerifyResultAnalyse &verify_result) { QMessageBox::StandardButton reply; @@ -91,35 +80,6 @@ void ImportUnknownKeyFromKeyserver( } } -void process_operation(QWidget *parent, const QString &waiting_title, - const Thread::Task::TaskRunnable func, - const Thread::Task::TaskCallback callback, - DataObjectPtr data_object) { - auto *dialog = new WaitingDialog(waiting_title, parent); - - auto *process_task = new Thread::Task(std::move(func), waiting_title, - data_object, std::move(callback)); - - QApplication::connect(process_task, &Thread::Task::SignalTaskEnd, dialog, - &QDialog::close); - QApplication::connect(process_task, &Thread::Task::SignalTaskEnd, dialog, - &QDialog::deleteLater); - - // a looper to wait for the operation - QEventLoop looper; - QApplication::connect(process_task, &Thread::Task::SignalTaskEnd, &looper, - &QEventLoop::quit); - - // post process task to task runner - Thread::TaskRunnerGetter::GetInstance() - .GetTaskRunner(Thread::TaskRunnerGetter::kTaskRunnerType_GPG) - ->PostTask(process_task); - - // block until task finished - // this is to keep reference vaild until task finished - looper.exec(); -} - auto CommonUtils::GetInstance() -> CommonUtils * { if (!instance) { instance.reset(new CommonUtils()); diff --git a/src/ui/dialog/key_generate/KeyGenerateDialog.cpp b/src/ui/dialog/key_generate/KeyGenerateDialog.cpp index 53ff3b1d..ab3a5ac8 100644 --- a/src/ui/dialog/key_generate/KeyGenerateDialog.cpp +++ b/src/ui/dialog/key_generate/KeyGenerateDialog.cpp @@ -252,6 +252,8 @@ void KeyGenerateDialog::refresh_widgets_state() { ui_->pExpireCheckBox->setChecked(gen_key_info_->IsNonExpired()); ui_->pExpireCheckBox->blockSignals(false); + ui_->generateButton->setDisabled(false); + if (gen_subkey_info_ == nullptr) { ui_->sTab->setDisabled(true); @@ -460,11 +462,7 @@ void KeyGenerateDialog::sync_gen_key_algo_info() { supported_primary_key_algos_); - ui_->generateButton->setDisabled(!found); - - if (found) { - gen_key_info_->SetAlgo(algo); - } + if (found) gen_key_info_->SetAlgo(found ? algo : KeyGenerateInfo::kNoneAlgo); } void KeyGenerateDialog::sync_gen_subkey_algo_info() { @@ -472,8 +470,9 @@ void KeyGenerateDialog::sync_gen_subkey_algo_info() { auto [s_found, algo] = GetAlgoByName(ui_->sAlgoComboBox->currentText(), supported_subkey_algos_); - ui_->generateButton->setDisabled(!s_found); - if (s_found) gen_subkey_info_->SetAlgo(algo); + if (s_found) { + gen_subkey_info_->SetAlgo(s_found ? algo : KeyGenerateInfo::kNoneAlgo); + } } } diff --git a/src/ui/function/GpgOperaHelper.cpp b/src/ui/function/GpgOperaHelper.cpp index 161db70e..e94befdb 100644 --- a/src/ui/function/GpgOperaHelper.cpp +++ b/src/ui/function/GpgOperaHelper.cpp @@ -536,7 +536,8 @@ auto GpgOperaHelper::BuildOperasDecryptVerify( void GpgOperaHelper::WaitForOpera(QWidget* parent, const QString& title, const OperaWaitingCb& opera) { QEventLoop looper; - QPointer<WaitingDialog> const dialog = new WaitingDialog(title, parent); + QPointer<WaitingDialog> const dialog = + new WaitingDialog(title, false, parent); connect(dialog, &QDialog::finished, &looper, &QEventLoop::quit); connect(dialog, &QDialog::finished, dialog, &QDialog::deleteLater); dialog->show(); |