fix: add ui status control for email operations
This commit is contained in:
parent
7db37d5f0b
commit
6829d8ae46
@ -53,16 +53,17 @@ class MainWindow : public GeneralMainWindow {
|
|||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
struct CryptoMenu {
|
struct OperationMenu {
|
||||||
using OperationType = unsigned int;
|
using OperationType = unsigned int;
|
||||||
|
|
||||||
static constexpr OperationType None = 0;
|
static constexpr OperationType kNone = 0;
|
||||||
static constexpr OperationType Encrypt = 1 << 0;
|
static constexpr OperationType kEncrypt = 1 << 0;
|
||||||
static constexpr OperationType Sign = 1 << 1;
|
static constexpr OperationType kSign = 1 << 1;
|
||||||
static constexpr OperationType Decrypt = 1 << 2;
|
static constexpr OperationType kDecrypt = 1 << 2;
|
||||||
static constexpr OperationType Verify = 1 << 3;
|
static constexpr OperationType kVerify = 1 << 3;
|
||||||
static constexpr OperationType EncryptAndSign = 1 << 4;
|
static constexpr OperationType kEncryptAndSign = 1 << 4;
|
||||||
static constexpr OperationType DecryptAndVerify = 1 << 5;
|
static constexpr OperationType kDecryptAndVerify = 1 << 5;
|
||||||
|
static constexpr OperationType kVerifyEMail = 1 << 6;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -80,6 +80,8 @@ void MainWindow::slot_switch_menu_control_mode(int index) {
|
|||||||
decrypt_act_->setDisabled(disable);
|
decrypt_act_->setDisabled(disable);
|
||||||
decrypt_verify_act_->setDisabled(disable);
|
decrypt_verify_act_->setDisabled(disable);
|
||||||
|
|
||||||
|
verify_email_by_eml_data_act_->setDisabled(disable);
|
||||||
|
|
||||||
redo_act_->setDisabled(disable);
|
redo_act_->setDisabled(disable);
|
||||||
undo_act_->setDisabled(disable);
|
undo_act_->setDisabled(disable);
|
||||||
zoom_out_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::SlotSetRestartNeeded(int mode) { this->restart_mode_ = mode; }
|
||||||
|
|
||||||
void MainWindow::SlotUpdateCryptoMenuStatus(unsigned int type) {
|
void MainWindow::SlotUpdateCryptoMenuStatus(unsigned int type) {
|
||||||
MainWindow::CryptoMenu::OperationType opera_type = type;
|
MainWindow::OperationMenu::OperationType opera_type = type;
|
||||||
|
|
||||||
// refresh status to disable all
|
// refresh status to disable all
|
||||||
verify_act_->setDisabled(true);
|
verify_act_->setDisabled(true);
|
||||||
@ -184,25 +186,32 @@ void MainWindow::SlotUpdateCryptoMenuStatus(unsigned int type) {
|
|||||||
decrypt_act_->setDisabled(true);
|
decrypt_act_->setDisabled(true);
|
||||||
decrypt_verify_act_->setDisabled(true);
|
decrypt_verify_act_->setDisabled(true);
|
||||||
|
|
||||||
// enable according to type
|
verify_email_by_eml_data_act_->setDisabled(true);
|
||||||
if ((opera_type & MainWindow::CryptoMenu::Verify) != 0U) {
|
|
||||||
|
// gnupg operations
|
||||||
|
if ((opera_type & MainWindow::OperationMenu::kVerify) != 0U) {
|
||||||
verify_act_->setDisabled(false);
|
verify_act_->setDisabled(false);
|
||||||
}
|
}
|
||||||
if ((opera_type & MainWindow::CryptoMenu::Sign) != 0U) {
|
if ((opera_type & MainWindow::OperationMenu::kSign) != 0U) {
|
||||||
sign_act_->setDisabled(false);
|
sign_act_->setDisabled(false);
|
||||||
}
|
}
|
||||||
if ((opera_type & MainWindow::CryptoMenu::Encrypt) != 0U) {
|
if ((opera_type & MainWindow::OperationMenu::kEncrypt) != 0U) {
|
||||||
encrypt_act_->setDisabled(false);
|
encrypt_act_->setDisabled(false);
|
||||||
}
|
}
|
||||||
if ((opera_type & MainWindow::CryptoMenu::EncryptAndSign) != 0U) {
|
if ((opera_type & MainWindow::OperationMenu::kEncryptAndSign) != 0U) {
|
||||||
encrypt_sign_act_->setDisabled(false);
|
encrypt_sign_act_->setDisabled(false);
|
||||||
}
|
}
|
||||||
if ((opera_type & MainWindow::CryptoMenu::Decrypt) != 0U) {
|
if ((opera_type & MainWindow::OperationMenu::kDecrypt) != 0U) {
|
||||||
decrypt_act_->setDisabled(false);
|
decrypt_act_->setDisabled(false);
|
||||||
}
|
}
|
||||||
if ((opera_type & MainWindow::CryptoMenu::DecryptAndVerify) != 0U) {
|
if ((opera_type & MainWindow::OperationMenu::kDecryptAndVerify) != 0U) {
|
||||||
decrypt_verify_act_->setDisabled(false);
|
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) {
|
void MainWindow::SlotGeneralEncrypt(bool) {
|
||||||
|
@ -124,8 +124,8 @@ void FilePage::keyPressEvent(QKeyEvent* event) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void FilePage::update_main_basical_opera_menu(const QString& selected_path) {
|
void FilePage::update_main_basical_opera_menu(const QString& selected_path) {
|
||||||
MainWindow::CryptoMenu::OperationType operation_type =
|
MainWindow::OperationMenu::OperationType operation_type =
|
||||||
MainWindow::CryptoMenu::None;
|
MainWindow::OperationMenu::kNone;
|
||||||
|
|
||||||
// abort...
|
// abort...
|
||||||
if (selected_path.isEmpty()) return;
|
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()) &&
|
if ((info.isDir() || info.isFile()) &&
|
||||||
(info.suffix() != "gpg" && info.suffix() != "pgp" &&
|
(info.suffix() != "gpg" && info.suffix() != "pgp" &&
|
||||||
info.suffix() != "sig" && info.suffix() != "asc")) {
|
info.suffix() != "sig" && info.suffix() != "asc")) {
|
||||||
operation_type |= MainWindow::CryptoMenu::Encrypt;
|
operation_type |= MainWindow::OperationMenu::kEncrypt;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((info.isDir() || info.isFile()) &&
|
if ((info.isDir() || info.isFile()) &&
|
||||||
(info.suffix() != "gpg" && info.suffix() != "pgp" &&
|
(info.suffix() != "gpg" && info.suffix() != "pgp" &&
|
||||||
info.suffix() != "sig" && info.suffix() != "asc")) {
|
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" ||
|
if (info.isFile() && (info.suffix() == "gpg" || info.suffix() == "pgp" ||
|
||||||
info.suffix() == "asc")) {
|
info.suffix() == "asc")) {
|
||||||
operation_type |= MainWindow::CryptoMenu::Decrypt;
|
operation_type |= MainWindow::OperationMenu::kDecrypt;
|
||||||
operation_type |= MainWindow::CryptoMenu::DecryptAndVerify;
|
operation_type |= MainWindow::OperationMenu::kDecryptAndVerify;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (info.isFile() && (info.suffix() != "gpg" && info.suffix() != "pgp" &&
|
if (info.isFile() && (info.suffix() != "gpg" && info.suffix() != "pgp" &&
|
||||||
info.suffix() != "sig" && info.suffix() != "asc")) {
|
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" ||
|
if (info.isFile() && (info.suffix() == "sig" || info.suffix() == "gpg" ||
|
||||||
info.suffix() == "pgp" || info.suffix() == "asc")) {
|
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);
|
emit SignalMainWindowlUpdateBasicalOperaMenu(operation_type);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user