diff options
author | saturneric <[email protected]> | 2024-01-12 06:02:37 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2024-01-12 06:02:37 +0000 |
commit | bf538056b24a68b8fd235b1c50991ee8eb46a776 (patch) | |
tree | e1bab54095b80df62b321fb5bd69453f9f951b05 /src/ui/main_window/MainWindowUI.cpp | |
parent | feat: improve api and ui of keys import and export (diff) | |
download | GpgFrontend-bf538056b24a68b8fd235b1c50991ee8eb46a776.tar.gz GpgFrontend-bf538056b24a68b8fd235b1c50991ee8eb46a776.zip |
refactor: use QString instead of std::string and improve threading system
Diffstat (limited to 'src/ui/main_window/MainWindowUI.cpp')
-rw-r--r-- | src/ui/main_window/MainWindowUI.cpp | 28 |
1 files changed, 9 insertions, 19 deletions
diff --git a/src/ui/main_window/MainWindowUI.cpp b/src/ui/main_window/MainWindowUI.cpp index e710081c..88c198e4 100644 --- a/src/ui/main_window/MainWindowUI.cpp +++ b/src/ui/main_window/MainWindowUI.cpp @@ -187,8 +187,7 @@ void MainWindow::create_actions() { connect(encrypt_act_, &QAction::triggered, this, [this]() { if (edit_->SlotCurPageFileTreeView() != nullptr) { const auto* file_tree_view = edit_->SlotCurPageFileTreeView(); - const auto path_qstr = file_tree_view->GetSelected(); - const auto path = ConvertPathByOS(path_qstr); + const auto path = file_tree_view->GetSelected(); const auto file_info = QFileInfo(path); if (file_info.isFile()) { @@ -214,8 +213,7 @@ void MainWindow::create_actions() { connect(encrypt_sign_act_, &QAction::triggered, this, [this]() { if (edit_->SlotCurPageFileTreeView() != nullptr) { const auto* file_tree_view = edit_->SlotCurPageFileTreeView(); - const auto path_qstr = file_tree_view->GetSelected(); - const auto path = ConvertPathByOS(path_qstr); + const auto path = file_tree_view->GetSelected(); const auto file_info = QFileInfo(path); if (file_info.isFile()) { @@ -240,16 +238,13 @@ void MainWindow::create_actions() { connect(decrypt_act_, &QAction::triggered, this, [this]() { if (edit_->SlotCurPageFileTreeView() != nullptr) { const auto* file_tree_view = edit_->SlotCurPageFileTreeView(); - const auto path_qstr = file_tree_view->GetSelected(); - const auto path = ConvertPathByOS(path_qstr); + const auto path = file_tree_view->GetSelected(); const auto file_info = QFileInfo(path); if (file_info.isFile()) { - const std::string filename = path.filename().string(); - const std::string extension( - std::find(filename.begin(), filename.end(), '.'), filename.end()); + const QString extension = file_info.completeSuffix(); - if (extension == ".tar.gpg" || extension == ".tar.asc") { + if (extension == "tar.gpg" || extension == "tar.asc") { this->SlotArchiveDecrypt(path); } else { this->SlotFileDecrypt(path); @@ -273,14 +268,11 @@ void MainWindow::create_actions() { connect(decrypt_verify_act_, &QAction::triggered, this, [this]() { if (edit_->SlotCurPageFileTreeView() != nullptr) { const auto* file_tree_view = edit_->SlotCurPageFileTreeView(); - const auto path_qstr = file_tree_view->GetSelected(); - const auto path = ConvertPathByOS(path_qstr); + const auto path = file_tree_view->GetSelected(); const auto file_info = QFileInfo(path); if (file_info.isFile()) { - const std::string filename = path.filename().string(); - const std::string extension( - std::find(filename.begin(), filename.end(), '.'), filename.end()); + const QString extension = file_info.completeSuffix(); if (extension == ".tar.gpg" || extension == ".tar.asc") { this->SlotArchiveDecryptVerify(path); @@ -305,8 +297,7 @@ void MainWindow::create_actions() { connect(sign_act_, &QAction::triggered, this, [this]() { if (edit_->SlotCurPageFileTreeView() != nullptr) { const auto* file_tree_view = edit_->SlotCurPageFileTreeView(); - const auto path_qstr = file_tree_view->GetSelected(); - const auto path = ConvertPathByOS(path_qstr); + const auto path = file_tree_view->GetSelected(); const auto file_info = QFileInfo(path); if (file_info.isFile()) this->SlotFileSign(path); @@ -325,8 +316,7 @@ void MainWindow::create_actions() { connect(verify_act_, &QAction::triggered, this, [this]() { if (edit_->SlotCurPageFileTreeView() != nullptr) { const auto* file_tree_view = edit_->SlotCurPageFileTreeView(); - const auto path_qstr = file_tree_view->GetSelected(); - const auto path = ConvertPathByOS(path_qstr); + const auto path = file_tree_view->GetSelected(); const auto file_info = QFileInfo(path); if (file_info.isFile()) this->SlotFileVerify(path); |