diff options
author | saturneric <[email protected]> | 2024-11-26 16:35:25 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2024-11-26 16:35:25 +0000 |
commit | 6829d8ae46443f8ec2735ea8bff6306d8242309a (patch) | |
tree | 98119ec64cce3cfdbc79b13e5a27830962033168 | |
parent | fix: change "Information Board" to "Status Panel" (diff) | |
download | GpgFrontend-6829d8ae46443f8ec2735ea8bff6306d8242309a.tar.gz GpgFrontend-6829d8ae46443f8ec2735ea8bff6306d8242309a.zip |
fix: add ui status control for email operations
-rw-r--r-- | src/ui/main_window/MainWindow.h | 17 | ||||
-rw-r--r-- | src/ui/main_window/MainWindowSlotUI.cpp | 25 | ||||
-rw-r--r-- | src/ui/widgets/FilePage.cpp | 20 |
3 files changed, 38 insertions, 24 deletions
diff --git a/src/ui/main_window/MainWindow.h b/src/ui/main_window/MainWindow.h index d446bfb1..e10efb9b 100644 --- a/src/ui/main_window/MainWindow.h +++ b/src/ui/main_window/MainWindow.h @@ -53,16 +53,17 @@ class MainWindow : public GeneralMainWindow { /** * */ - struct CryptoMenu { + struct OperationMenu { using OperationType = unsigned int; - static constexpr OperationType None = 0; - static constexpr OperationType Encrypt = 1 << 0; - static constexpr OperationType Sign = 1 << 1; - static constexpr OperationType Decrypt = 1 << 2; - static constexpr OperationType Verify = 1 << 3; - static constexpr OperationType EncryptAndSign = 1 << 4; - static constexpr OperationType DecryptAndVerify = 1 << 5; + static constexpr OperationType kNone = 0; + static constexpr OperationType kEncrypt = 1 << 0; + static constexpr OperationType kSign = 1 << 1; + static constexpr OperationType kDecrypt = 1 << 2; + static constexpr OperationType kVerify = 1 << 3; + static constexpr OperationType kEncryptAndSign = 1 << 4; + static constexpr OperationType kDecryptAndVerify = 1 << 5; + static constexpr OperationType kVerifyEMail = 1 << 6; }; /** diff --git a/src/ui/main_window/MainWindowSlotUI.cpp b/src/ui/main_window/MainWindowSlotUI.cpp index aaf075d5..4a460005 100644 --- a/src/ui/main_window/MainWindowSlotUI.cpp +++ b/src/ui/main_window/MainWindowSlotUI.cpp @@ -80,6 +80,8 @@ void MainWindow::slot_switch_menu_control_mode(int index) { decrypt_act_->setDisabled(disable); decrypt_verify_act_->setDisabled(disable); + verify_email_by_eml_data_act_->setDisabled(disable); + redo_act_->setDisabled(disable); undo_act_->setDisabled(disable); zoom_out_act_->setDisabled(disable); @@ -174,7 +176,7 @@ void MainWindow::slot_cut_pgp_header() { void MainWindow::SlotSetRestartNeeded(int mode) { this->restart_mode_ = mode; } void MainWindow::SlotUpdateCryptoMenuStatus(unsigned int type) { - MainWindow::CryptoMenu::OperationType opera_type = type; + MainWindow::OperationMenu::OperationType opera_type = type; // refresh status to disable all verify_act_->setDisabled(true); @@ -184,25 +186,32 @@ void MainWindow::SlotUpdateCryptoMenuStatus(unsigned int type) { decrypt_act_->setDisabled(true); decrypt_verify_act_->setDisabled(true); - // enable according to type - if ((opera_type & MainWindow::CryptoMenu::Verify) != 0U) { + verify_email_by_eml_data_act_->setDisabled(true); + + // gnupg operations + if ((opera_type & MainWindow::OperationMenu::kVerify) != 0U) { verify_act_->setDisabled(false); } - if ((opera_type & MainWindow::CryptoMenu::Sign) != 0U) { + if ((opera_type & MainWindow::OperationMenu::kSign) != 0U) { sign_act_->setDisabled(false); } - if ((opera_type & MainWindow::CryptoMenu::Encrypt) != 0U) { + if ((opera_type & MainWindow::OperationMenu::kEncrypt) != 0U) { encrypt_act_->setDisabled(false); } - if ((opera_type & MainWindow::CryptoMenu::EncryptAndSign) != 0U) { + if ((opera_type & MainWindow::OperationMenu::kEncryptAndSign) != 0U) { encrypt_sign_act_->setDisabled(false); } - if ((opera_type & MainWindow::CryptoMenu::Decrypt) != 0U) { + if ((opera_type & MainWindow::OperationMenu::kDecrypt) != 0U) { decrypt_act_->setDisabled(false); } - if ((opera_type & MainWindow::CryptoMenu::DecryptAndVerify) != 0U) { + if ((opera_type & MainWindow::OperationMenu::kDecryptAndVerify) != 0U) { decrypt_verify_act_->setDisabled(false); } + + // email operations + if ((opera_type & MainWindow::OperationMenu::kVerifyEMail) != 0U) { + verify_email_by_eml_data_act_->setDisabled(false); + } } void MainWindow::SlotGeneralEncrypt(bool) { diff --git a/src/ui/widgets/FilePage.cpp b/src/ui/widgets/FilePage.cpp index b08a2153..4d9ce26a 100644 --- a/src/ui/widgets/FilePage.cpp +++ b/src/ui/widgets/FilePage.cpp @@ -124,8 +124,8 @@ void FilePage::keyPressEvent(QKeyEvent* event) { } void FilePage::update_main_basical_opera_menu(const QString& selected_path) { - MainWindow::CryptoMenu::OperationType operation_type = - MainWindow::CryptoMenu::None; + MainWindow::OperationMenu::OperationType operation_type = + MainWindow::OperationMenu::kNone; // abort... if (selected_path.isEmpty()) return; @@ -135,29 +135,33 @@ void FilePage::update_main_basical_opera_menu(const QString& selected_path) { if ((info.isDir() || info.isFile()) && (info.suffix() != "gpg" && info.suffix() != "pgp" && info.suffix() != "sig" && info.suffix() != "asc")) { - operation_type |= MainWindow::CryptoMenu::Encrypt; + operation_type |= MainWindow::OperationMenu::kEncrypt; } if ((info.isDir() || info.isFile()) && (info.suffix() != "gpg" && info.suffix() != "pgp" && info.suffix() != "sig" && info.suffix() != "asc")) { - operation_type |= MainWindow::CryptoMenu::EncryptAndSign; + operation_type |= MainWindow::OperationMenu::kEncryptAndSign; } if (info.isFile() && (info.suffix() == "gpg" || info.suffix() == "pgp" || info.suffix() == "asc")) { - operation_type |= MainWindow::CryptoMenu::Decrypt; - operation_type |= MainWindow::CryptoMenu::DecryptAndVerify; + operation_type |= MainWindow::OperationMenu::kDecrypt; + operation_type |= MainWindow::OperationMenu::kDecryptAndVerify; } if (info.isFile() && (info.suffix() != "gpg" && info.suffix() != "pgp" && info.suffix() != "sig" && info.suffix() != "asc")) { - operation_type |= MainWindow::CryptoMenu::Sign; + operation_type |= MainWindow::OperationMenu::kSign; } if (info.isFile() && (info.suffix() == "sig" || info.suffix() == "gpg" || info.suffix() == "pgp" || info.suffix() == "asc")) { - operation_type |= MainWindow::CryptoMenu::Verify; + operation_type |= MainWindow::OperationMenu::kVerify; + } + + if (info.isFile() && (info.suffix() == "eml")) { + operation_type |= MainWindow::OperationMenu::kVerifyEMail; } emit SignalMainWindowlUpdateBasicalOperaMenu(operation_type); |