aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/main_window/MainWindowUI.cpp
diff options
context:
space:
mode:
authorsaturneric <[email protected]>2024-01-12 06:02:37 +0000
committersaturneric <[email protected]>2024-01-12 06:02:37 +0000
commitbf538056b24a68b8fd235b1c50991ee8eb46a776 (patch)
treee1bab54095b80df62b321fb5bd69453f9f951b05 /src/ui/main_window/MainWindowUI.cpp
parentfeat: improve api and ui of keys import and export (diff)
downloadGpgFrontend-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.cpp28
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);