diff --git a/gpgfrontend.qrc b/gpgfrontend.qrc index d82a47fa..49a26dec 100644 --- a/gpgfrontend.qrc +++ b/gpgfrontend.qrc @@ -108,7 +108,9 @@ resource/lfs/icons/export-email.png resource/lfs/icons/warning-filling.png resource/lfs/icons/upgrade.png - resource/lfs/icons/batch.png + resource/lfs/icons/batch.png + resource/lfs/icons/encr-sign.png + resource/lfs/icons/decr-verify.png resource/lfs/test/data/pv1.key diff --git a/resource/lfs/icons/decr-verify.png b/resource/lfs/icons/decr-verify.png new file mode 100644 index 00000000..0385cabf Binary files /dev/null and b/resource/lfs/icons/decr-verify.png differ diff --git a/resource/lfs/icons/encr-sign.png b/resource/lfs/icons/encr-sign.png new file mode 100644 index 00000000..25275481 Binary files /dev/null and b/resource/lfs/icons/encr-sign.png differ diff --git a/resource/lfs/icons/file-operator.png b/resource/lfs/icons/file-operator.png index cab57a98..e547d886 100644 Binary files a/resource/lfs/icons/file-operator.png and b/resource/lfs/icons/file-operator.png differ diff --git a/src/core/typedef/GpgTypedef.h b/src/core/typedef/GpgTypedef.h index c052b6a2..fffc5cf4 100644 --- a/src/core/typedef/GpgTypedef.h +++ b/src/core/typedef/GpgTypedef.h @@ -62,11 +62,12 @@ using GpgOperationCallback = std::function; using GpgOperationFuture = std::future>; enum GpgOperation { - kENCRYPT, - kDECRYPT, - kSIGN, - kVERIFY, - kENCRYPT_SIGN, - kDECRYPT_VERIFY + kNONE = 0, + kENCRYPT = 1 << 0, + kDECRYPT = 1 << 1, + kSIGN = 1 << 2, + kVERIFY = 1 << 3, + kENCRYPT_SIGN = 1 << 4, + kDECRYPT_VERIFY = 1 << 5, }; } // namespace GpgFrontend \ No newline at end of file diff --git a/src/ui/dialog/settings/SettingsAppearance.cpp b/src/ui/dialog/settings/SettingsAppearance.cpp index d2648498..6c0d18c7 100644 --- a/src/ui/dialog/settings/SettingsAppearance.cpp +++ b/src/ui/dialog/settings/SettingsAppearance.cpp @@ -150,6 +150,19 @@ void AppearanceTab::SetSettings() { } else { ui_->themeComboBox->setCurrentIndex(target_theme_index); } + + ui_->encrCheckBox->setChecked( + (appearance.tool_bar_crypto_operas_type & GpgOperation::kENCRYPT) != 0); + ui_->decrCheckBox->setChecked( + (appearance.tool_bar_crypto_operas_type & GpgOperation::kDECRYPT) != 0); + ui_->signCheckBox->setChecked( + (appearance.tool_bar_crypto_operas_type & GpgOperation::kSIGN) != 0); + ui_->verifyCheckBox->setChecked( + (appearance.tool_bar_crypto_operas_type & GpgOperation::kVERIFY) != 0); + ui_->encrSignCheckBox->setChecked((appearance.tool_bar_crypto_operas_type & + GpgOperation::kENCRYPT_SIGN) != 0); + ui_->decrVerifyCheckBox->setChecked((appearance.tool_bar_crypto_operas_type & + GpgOperation::kDECRYPT_VERIFY) != 0); } void AppearanceTab::ApplySettings() { @@ -195,6 +208,20 @@ void AppearanceTab::ApplySettings() { appearance.text_editor_font_size = ui_->fontSizeTextEditorLabelSpinBox->value(); + appearance.tool_bar_crypto_operas_type = 0; + appearance.tool_bar_crypto_operas_type |= + ui_->encrCheckBox->isChecked() ? kENCRYPT : kNONE; + appearance.tool_bar_crypto_operas_type |= + ui_->decrCheckBox->isChecked() ? kDECRYPT : kNONE; + appearance.tool_bar_crypto_operas_type |= + ui_->signCheckBox->isChecked() ? kSIGN : kNONE; + appearance.tool_bar_crypto_operas_type |= + ui_->verifyCheckBox->isChecked() ? kVERIFY : kNONE; + appearance.tool_bar_crypto_operas_type |= + ui_->encrSignCheckBox->isChecked() ? kENCRYPT_SIGN : kNONE; + appearance.tool_bar_crypto_operas_type |= + ui_->decrVerifyCheckBox->isChecked() ? kDECRYPT_VERIFY : kNONE; + general_settings_state.Store(appearance.ToJson()); auto settings = GlobalSettingStation::GetInstance().GetSettings(); diff --git a/src/ui/main_window/MainWindow.cpp b/src/ui/main_window/MainWindow.cpp index f9d5d8be..4817cbcd 100644 --- a/src/ui/main_window/MainWindow.cpp +++ b/src/ui/main_window/MainWindow.cpp @@ -32,6 +32,7 @@ #include "core/function/GlobalSettingStation.h" #include "core/model/SettingsObject.h" #include "core/module/ModuleManager.h" +#include "struct/settings_object/AppearanceSO.h" #include "ui/UISignalStation.h" #include "ui/main_window/GeneralMainWindow.h" #include "ui/struct/settings_object/KeyServerSO.h" @@ -178,11 +179,44 @@ void MainWindow::restore_settings() { settings.setValue("gnupg/non_ascii_at_file_operation", true); } + prohibit_update_checking_ = + settings.value("network/prohibit_update_check").toBool(); + // set appearance + AppearanceSO const appearance(SettingsObject("general_settings_state")); + + crypt_tool_bar_->clear(); + + if ((appearance.tool_bar_crypto_operas_type & GpgOperation::kENCRYPT) != 0) { + crypt_tool_bar_->addAction(encrypt_act_); + } + if ((appearance.tool_bar_crypto_operas_type & GpgOperation::kDECRYPT) != 0) { + crypt_tool_bar_->addAction(decrypt_act_); + } + if ((appearance.tool_bar_crypto_operas_type & GpgOperation::kSIGN) != 0) { + crypt_tool_bar_->addAction(sign_act_); + } + if ((appearance.tool_bar_crypto_operas_type & GpgOperation::kVERIFY) != 0) { + crypt_tool_bar_->addAction(verify_act_); + } + if ((appearance.tool_bar_crypto_operas_type & GpgOperation::kENCRYPT_SIGN) != + 0) { + crypt_tool_bar_->addAction(encrypt_sign_act_); + } + if ((appearance.tool_bar_crypto_operas_type & + GpgOperation::kDECRYPT_VERIFY) != 0) { + crypt_tool_bar_->addAction(decrypt_verify_act_); + } + + icon_style_ = appearance.tool_bar_button_style; import_button_->setToolButtonStyle(icon_style_); + this->setToolButtonStyle(icon_style_); - prohibit_update_checking_ = - settings.value("network/prohibit_update_check").toBool(); + // icons ize + this->setIconSize( + QSize(appearance.tool_bar_icon_width, appearance.tool_bar_icon_height)); + import_button_->setIconSize( + QSize(appearance.tool_bar_icon_width, appearance.tool_bar_icon_height)); } void MainWindow::recover_editor_unsaved_pages_from_cache() { diff --git a/src/ui/main_window/MainWindowSlotUI.cpp b/src/ui/main_window/MainWindowSlotUI.cpp index 40df7dbc..dc282c64 100644 --- a/src/ui/main_window/MainWindowSlotUI.cpp +++ b/src/ui/main_window/MainWindowSlotUI.cpp @@ -103,15 +103,7 @@ void MainWindow::slot_open_settings_dialog() { connect(dialog, &SettingsDialog::finished, this, [&]() -> void { AppearanceSO appearance(SettingsObject("general_settings_state")); - this->setToolButtonStyle(appearance.tool_bar_button_style); - import_button_->setToolButtonStyle(appearance.tool_bar_button_style); - - // icons ize - this->setIconSize( - QSize(appearance.tool_bar_icon_width, appearance.tool_bar_icon_height)); - import_button_->setIconSize( - QSize(appearance.tool_bar_icon_width, appearance.tool_bar_icon_height)); - + restore_settings(); // restart main window if necessary if (restart_mode_ != kNonRestartCode) { if (edit_->MaybeSaveAnyTab()) { diff --git a/src/ui/main_window/MainWindowUI.cpp b/src/ui/main_window/MainWindowUI.cpp index 59ad8401..16b4eed6 100644 --- a/src/ui/main_window/MainWindowUI.cpp +++ b/src/ui/main_window/MainWindowUI.cpp @@ -28,8 +28,10 @@ #include "MainWindow.h" #include "core/function/GlobalSettingStation.h" +#include "core/model/SettingsObject.h" #include "core/module/ModuleManager.h" #include "dialog/controller/ModuleControllerDialog.h" +#include "struct/settings_object/AppearanceSO.h" #include "ui/UserInterfaceUtils.h" #include "ui/dialog/controller/GnuPGControllerDialog.h" #include "ui/dialog/help/AboutDialog.h" @@ -148,7 +150,7 @@ void MainWindow::create_actions() { &MainWindow::SlotGeneralEncrypt); encrypt_sign_act_ = - create_action("encrypt_sign", tr("Encrypt Sign"), ":/icons/compress.png", + create_action("encrypt_sign", tr("Encrypt Sign"), ":/icons/encr-sign.png", tr("Encrypt and Sign Message"), {QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_E)}); connect(encrypt_sign_act_, &QAction::triggered, this, @@ -162,7 +164,7 @@ void MainWindow::create_actions() { decrypt_verify_act_ = create_action("decrypt_verify", tr("Decrypt Verify"), - ":/icons/expand.png", tr("Decrypt and Verify Message"), + ":/icons/decr-verify.png", tr("Decrypt and Verify Message"), {QKeySequence(Qt::CTRL | Qt::SHIFT | Qt::Key_D)}); connect(decrypt_verify_act_, &QAction::triggered, this, &MainWindow::SlotGeneralDecryptVerify); @@ -498,12 +500,7 @@ void MainWindow::create_tool_bars() { crypt_tool_bar_ = addToolBar(tr("Operations")); crypt_tool_bar_->setObjectName("cryptToolBar"); - crypt_tool_bar_->addAction(encrypt_act_); - // crypt_tool_bar_->addAction(encrypt_sign_act_); - crypt_tool_bar_->addAction(decrypt_act_); - // crypt_tool_bar_->addAction(decrypt_verify_act_); - crypt_tool_bar_->addAction(sign_act_); - crypt_tool_bar_->addAction(verify_act_); + view_menu_->addAction(crypt_tool_bar_->toggleViewAction()); key_tool_bar_ = addToolBar(tr("Key")); diff --git a/src/ui/struct/settings_object/AppearanceSO.h b/src/ui/struct/settings_object/AppearanceSO.h index 4722ebd3..5f20d1fe 100644 --- a/src/ui/struct/settings_object/AppearanceSO.h +++ b/src/ui/struct/settings_object/AppearanceSO.h @@ -28,6 +28,8 @@ #pragma once +#include "core/typedef/GpgTypedef.h" + namespace GpgFrontend::UI { struct AppearanceSO { @@ -36,6 +38,9 @@ struct AppearanceSO { int tool_bar_icon_width = 24; int tool_bar_icon_height = 24; Qt::ToolButtonStyle tool_bar_button_style = Qt::ToolButtonTextUnderIcon; + int tool_bar_crypto_operas_type = GpgOperation::kENCRYPT | + GpgOperation::kDECRYPT | + GpgOperation::kSIGN | GpgOperation::kVERIFY; bool save_window_state; @@ -55,6 +60,9 @@ struct AppearanceSO { if (const auto v = j["tool_bar_button_style"]; v.isDouble()) { tool_bar_button_style = static_cast(v.toInt()); } + if (const auto v = j["tool_bar_crypto_operas_type"]; v.isDouble()) { + tool_bar_crypto_operas_type = static_cast(v.toInt()); + } if (const auto v = j["save_window_state"]; v.isBool()) { save_window_state = v.toBool(); @@ -68,6 +76,7 @@ struct AppearanceSO { j["tool_bar_icon_width"] = tool_bar_icon_width; j["tool_bar_icon_height"] = tool_bar_icon_height; j["tool_bar_button_style"] = tool_bar_button_style; + j["tool_bar_crypto_operas_type"] = tool_bar_crypto_operas_type; j["save_window_state"] = save_window_state; return j; diff --git a/ui/AppearanceSettings.ui b/ui/AppearanceSettings.ui index aed30461..ed6acea6 100644 --- a/ui/AppearanceSettings.ui +++ b/ui/AppearanceSettings.ui @@ -173,13 +173,82 @@ + + + + + + + 0 + 0 + + + + Crypto Operations + + + Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop + + + + + + + QLayout::SizeConstraint::SetDefaultConstraint + + + + + Verify + + + + + + + Decrypt Verify + + + + + + + Encrypt Sign + + + + + + + Encrypt + + + + + + + Sign + + + + + + + Decrypt + + + + + + + - Qt::Vertical + Qt::Orientation::Vertical