diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/ui/main_window/MainWindow.h | 6 | ||||
-rw-r--r-- | src/ui/main_window/MainWindowGpgOperaFunction.cpp | 24 | ||||
-rw-r--r-- | src/ui/main_window/MainWindowSlotUI.cpp | 24 | ||||
-rw-r--r-- | src/ui/widgets/FilePage.cpp | 14 | ||||
-rw-r--r-- | src/ui/widgets/FilePage.h | 9 |
5 files changed, 44 insertions, 33 deletions
diff --git a/src/ui/main_window/MainWindow.h b/src/ui/main_window/MainWindow.h index 9f18c510..8ec6bffd 100644 --- a/src/ui/main_window/MainWindow.h +++ b/src/ui/main_window/MainWindow.h @@ -206,7 +206,7 @@ class MainWindow : public GeneralMainWindow { /** * @details Open dialog for encrypting file. */ - void SlotFileEncrypt(const QStringList& paths); + void SlotFileEncrypt(const QStringList& paths, bool ascii); /** * @brief @@ -220,7 +220,7 @@ class MainWindow : public GeneralMainWindow { * * @param path */ - void SlotFileSign(const QStringList& paths); + void SlotFileSign(const QStringList& paths, bool ascii); /** * @brief @@ -241,7 +241,7 @@ class MainWindow : public GeneralMainWindow { * * @param path */ - void SlotFileEncryptSign(const QStringList& paths); + void SlotFileEncryptSign(const QStringList& paths, bool ascii); /** * @brief diff --git a/src/ui/main_window/MainWindowGpgOperaFunction.cpp b/src/ui/main_window/MainWindowGpgOperaFunction.cpp index 984acb2f..7632fdd6 100644 --- a/src/ui/main_window/MainWindowGpgOperaFunction.cpp +++ b/src/ui/main_window/MainWindowGpgOperaFunction.cpp @@ -289,13 +289,9 @@ void MainWindow::SlotDecryptVerify() { } } -void MainWindow::SlotFileEncrypt(const QStringList& paths) { +void MainWindow::SlotFileEncrypt(const QStringList& paths, bool ascii) { auto contexts = QSharedPointer<GpgOperaContextBasement>::create(); - - bool const non_ascii_at_file_operation = - GetSettings().value("gnupg/non_ascii_at_file_operation", true).toBool(); - - contexts->ascii = !non_ascii_at_file_operation; + contexts->ascii = ascii; if (!encrypt_operation_key_validate(contexts)) return; @@ -362,13 +358,10 @@ void MainWindow::SlotFileDecrypt(const QStringList& paths) { exec_operas_helper(tr("Decrypting"), contexts); } -void MainWindow::SlotFileSign(const QStringList& paths) { +void MainWindow::SlotFileSign(const QStringList& paths, bool ascii) { auto contexts = QSharedPointer<GpgOperaContextBasement>::create(); - bool const non_ascii_at_file_operation = - GetSettings().value("gnupg/non_ascii_at_file_operation", true).toBool(); - - contexts->ascii = !non_ascii_at_file_operation; + contexts->ascii = ascii; auto key_ids = m_key_list_->GetChecked(); contexts->keys = check_keys_helper( @@ -445,13 +438,9 @@ void MainWindow::SlotFileVerify(const QStringList& paths) { } } -void MainWindow::SlotFileEncryptSign(const QStringList& paths) { +void MainWindow::SlotFileEncryptSign(const QStringList& paths, bool ascii) { auto contexts = QSharedPointer<GpgOperaContextBasement>::create(); - - bool const non_ascii_at_file_operation = - GetSettings().value("gnupg/non_ascii_at_file_operation", true).toBool(); - - contexts->ascii = !non_ascii_at_file_operation; + contexts->ascii = ascii; auto key_ids = m_key_list_->GetChecked(); contexts->keys = check_keys_helper( @@ -491,7 +480,6 @@ void MainWindow::SlotFileEncryptSign(const QStringList& paths) { void MainWindow::SlotFileDecryptVerify(const QStringList& paths) { auto contexts = QSharedPointer<GpgOperaContextBasement>::create(); - contexts->ascii = true; if (!check_read_file_paths_helper(paths)) return; diff --git a/src/ui/main_window/MainWindowSlotUI.cpp b/src/ui/main_window/MainWindowSlotUI.cpp index acc8f5a8..fd5c0d8f 100644 --- a/src/ui/main_window/MainWindowSlotUI.cpp +++ b/src/ui/main_window/MainWindowSlotUI.cpp @@ -200,10 +200,10 @@ void MainWindow::SlotUpdateCryptoMenuStatus(unsigned int type) { void MainWindow::SlotGeneralEncrypt(bool) { if (edit_->CurPageFileTreeView() != nullptr) { - const auto* file_tree_view = edit_->CurPageFileTreeView(); - const auto paths = file_tree_view->GetSelected(); - - this->SlotFileEncrypt(paths); + const auto* file_page = edit_->CurPageFileTreeView(); + const auto paths = file_page->GetSelected(); + this->SlotFileEncrypt(paths, file_page->IsASCIIMode()); + return; } if (edit_->CurEMailPage() != nullptr) { @@ -236,10 +236,10 @@ void MainWindow::SlotGeneralDecrypt(bool) { void MainWindow::SlotGeneralSign(bool) { if (edit_->CurPageFileTreeView() != nullptr) { - const auto* file_tree_view = edit_->CurPageFileTreeView(); - const auto paths = file_tree_view->GetSelected(); - - this->SlotFileSign(paths); + const auto* file_page = edit_->CurPageFileTreeView(); + const auto paths = file_page->GetSelected(); + this->SlotFileSign(paths, file_page->IsASCIIMode()); + return; } if (edit_->CurEMailPage() != nullptr) { @@ -268,10 +268,10 @@ void MainWindow::SlotGeneralVerify(bool) { void MainWindow::SlotGeneralEncryptSign(bool) { if (edit_->CurPageFileTreeView() != nullptr) { - const auto* file_tree_view = edit_->CurPageFileTreeView(); - const auto paths = file_tree_view->GetSelected(); - - this->SlotFileEncryptSign(paths); + const auto* file_page = edit_->CurPageFileTreeView(); + const auto paths = file_page->GetSelected(); + this->SlotFileEncryptSign(paths, file_page->IsASCIIMode()); + return; } if (edit_->CurEMailPage() != nullptr) { diff --git a/src/ui/widgets/FilePage.cpp b/src/ui/widgets/FilePage.cpp index fb27163f..605ae1d2 100644 --- a/src/ui/widgets/FilePage.cpp +++ b/src/ui/widgets/FilePage.cpp @@ -29,6 +29,7 @@ #include "ui/widgets/FilePage.h" #include "core/GpgModel.h" +#include "core/function/GlobalSettingStation.h" #include "ui/UISignalStation.h" #include "ui/main_window/MainWindow.h" #include "ui_FilePage.h" @@ -73,8 +74,19 @@ FilePage::FilePage(QWidget* parent, const QString& target_path) connect(show_system_act, &QAction::triggered, file_tree_view_, &FileTreeView::SlotShowSystemFile); option_popup_menu_->addAction(show_system_act); + + auto* switch_asc_mode_act = new QAction(tr("ASCII Mode"), this); + switch_asc_mode_act->setCheckable(true); + connect(switch_asc_mode_act, &QAction::triggered, this, + [=](bool on) { ascii_mode_ = on; }); + option_popup_menu_->addAction(switch_asc_mode_act); + ui_->optionsButton->setMenu(option_popup_menu_); + ascii_mode_ = !( + GetSettings().value("gnupg/non_ascii_at_file_operation", true).toBool()); + switch_asc_mode_act->setChecked(ascii_mode_); + connect(ui_->pathEdit, &QLineEdit::textChanged, [=]() { auto path = ui_->pathEdit->text(); auto dir = QDir(path); @@ -193,4 +205,6 @@ void FilePage::update_main_basic_opera_menu(const QStringList& selected_paths) { auto FilePage::IsBatchMode() const -> bool { return ui_->batchModeButton->isChecked(); } + +auto FilePage::IsASCIIMode() const -> bool { return ascii_mode_; } } // namespace GpgFrontend::UI diff --git a/src/ui/widgets/FilePage.h b/src/ui/widgets/FilePage.h index b302740b..7c90b62f 100644 --- a/src/ui/widgets/FilePage.h +++ b/src/ui/widgets/FilePage.h @@ -65,6 +65,14 @@ class FilePage : public QWidget { */ [[nodiscard]] auto IsBatchMode() const -> bool; + /** + * @brief + * + * @return true + * @return false + */ + [[nodiscard]] auto IsASCIIMode() const -> bool; + public slots: /** * @brief @@ -119,6 +127,7 @@ class FilePage : public QWidget { QMenu* popup_menu_{}; ///< QMenu* option_popup_menu_{}; ///< FileTreeView* file_tree_view_; + bool ascii_mode_; private slots: |