diff options
author | saturneric <[email protected]> | 2024-01-01 09:50:54 +0000 |
---|---|---|
committer | saturneric <[email protected]> | 2024-01-01 09:50:54 +0000 |
commit | dcdd494d7f6654a5e2d608d37f69e16cb15fa845 (patch) | |
tree | da6dd3b048beb13496cf44c39769dca93e360fc4 /src | |
parent | feat: improve file browser's functions and tidy up codes (diff) | |
download | GpgFrontend-dcdd494d7f6654a5e2d608d37f69e16cb15fa845.tar.gz GpgFrontend-dcdd494d7f6654a5e2d608d37f69e16cb15fa845.zip |
fix: find and solve some issues
Diffstat (limited to 'src')
-rw-r--r-- | src/core/utils/GpgUtils.cpp | 8 | ||||
-rw-r--r-- | src/ui/dialog/SignersPicker.cpp | 14 | ||||
-rw-r--r-- | src/ui/main_window/MainWindowFileSlotFunction.cpp | 30 | ||||
-rw-r--r-- | src/ui/widgets/FilePage.cpp | 4 | ||||
-rw-r--r-- | src/ui/widgets/FileTreeView.cpp | 7 | ||||
-rw-r--r-- | src/ui/widgets/FileTreeView.h | 7 |
6 files changed, 30 insertions, 40 deletions
diff --git a/src/core/utils/GpgUtils.cpp b/src/core/utils/GpgUtils.cpp index 20a96e12..cd5a6772 100644 --- a/src/core/utils/GpgUtils.cpp +++ b/src/core/utils/GpgUtils.cpp @@ -30,8 +30,6 @@ #include <boost/algorithm/string.hpp> -#include "core/utils/IOUtils.h" - namespace GpgFrontend { static inline void Ltrim(std::string& s) { @@ -131,7 +129,7 @@ auto SetExtensionOfOutputFile(std::filesystem::path path, GpgOperation opera, case kENCRYPT: case kSIGN: case kENCRYPT_SIGN: - extension += ".asc"; + extension = path.extension().string() + ".asc"; break; default: break; @@ -140,10 +138,10 @@ auto SetExtensionOfOutputFile(std::filesystem::path path, GpgOperation opera, switch (opera) { case kENCRYPT: case kENCRYPT_SIGN: - extension += ".gpg"; + extension = path.extension().string() + ".gpg"; break; case kSIGN: - extension = ".sig"; + extension = path.extension().string() + ".sig"; break; default: break; diff --git a/src/ui/dialog/SignersPicker.cpp b/src/ui/dialog/SignersPicker.cpp index 93f13471..3edde0be 100644 --- a/src/ui/dialog/SignersPicker.cpp +++ b/src/ui/dialog/SignersPicker.cpp @@ -35,8 +35,8 @@ namespace GpgFrontend::UI { SignersPicker::SignersPicker(QWidget* parent) : GeneralDialog(typeid(SignersPicker).name(), parent) { - auto confirm_button = new QPushButton(_("Confirm")); - auto cancel_button = new QPushButton(_("Cancel")); + auto* confirm_button = new QPushButton(_("Confirm")); + auto* cancel_button = new QPushButton(_("Cancel")); connect(confirm_button, &QPushButton::clicked, [=]() { this->accepted_ = true; }); @@ -44,7 +44,7 @@ SignersPicker::SignersPicker(QWidget* parent) connect(cancel_button, &QPushButton::clicked, this, &QDialog::reject); /*Setup KeyList*/ - key_list_ = new KeyList(false, this); + key_list_ = new KeyList(0U, this); key_list_->AddListGroupTab( _("Signers"), "signers", KeyListRow::ONLY_SECRET_KEY, KeyListColumn::NAME | KeyListColumn::EmailAddress | KeyListColumn::Usage, @@ -70,15 +70,17 @@ SignersPicker::SignersPicker(QWidget* parent) Qt::CustomizeWindowHint); this->setModal(true); - this->setWindowTitle("Signers Picker"); + this->setWindowTitle(_("Signers Picker")); this->setMinimumWidth(480); + + movePosition2CenterOfParent(); this->show(); } -GpgFrontend::KeyIdArgsListPtr SignersPicker::GetCheckedSigners() { +auto SignersPicker::GetCheckedSigners() -> GpgFrontend::KeyIdArgsListPtr { return key_list_->GetPrivateChecked(); } -bool SignersPicker::GetStatus() const { return this->accepted_; } +auto SignersPicker::GetStatus() const -> bool { return this->accepted_; } } // namespace GpgFrontend::UI diff --git a/src/ui/main_window/MainWindowFileSlotFunction.cpp b/src/ui/main_window/MainWindowFileSlotFunction.cpp index 9401a072..43e96fcf 100644 --- a/src/ui/main_window/MainWindowFileSlotFunction.cpp +++ b/src/ui/main_window/MainWindowFileSlotFunction.cpp @@ -439,22 +439,27 @@ void MainWindow::SlotFileVerify(std::filesystem::path path) { std::filesystem::path sign_file_path = path; std::filesystem::path data_file_path; - if (path.extension() == ".gpg") { + bool const prossible_singleton_target = + path.extension() == ".gpg" || path.extension() == ".pgp"; + if (prossible_singleton_target) { swap(data_file_path, sign_file_path); - } else if (path.extension() == ".sig" || path.extension() == ".asc") { + } else { data_file_path = sign_file_path.parent_path() / sign_file_path.stem(); } - if (path.extension() != ".gpg" && !std::filesystem::exists(data_file_path)) { + if (!prossible_singleton_target && !std::filesystem::exists(data_file_path)) { bool ok; QString const text = QInputDialog::getText( - this, _("Origin file to verify"), _("Filepath"), QLineEdit::Normal, - data_file_path.u8string().c_str(), &ok); - if (ok && !text.isEmpty()) { - data_file_path = text.toStdString(); - } else { - return; - } + this, _("File to be Verified"), + _("Please provide An ABSOLUTE Path \n" + "If Data And Signature is COMBINED within a single file, " + "KEEP THIS EMPTY: "), + QLineEdit::Normal, data_file_path.u8string().c_str(), &ok); + + if (!ok) return; + + data_file_path = + text.isEmpty() ? path : std::filesystem::path{text.toStdString()}; } if (!is_regular_file(data_file_path) || @@ -466,8 +471,9 @@ void MainWindow::SlotFileVerify(std::filesystem::path path) { return; } - SPDLOG_DEBUG("data path: {}", data_file_path.u8string()); - SPDLOG_DEBUG("sign path: {}", sign_file_path.u8string()); + SPDLOG_DEBUG("verification data file path: {}", data_file_path.u8string()); + SPDLOG_DEBUG("verification signature file path: {}", + sign_file_path.u8string()); CommonUtils::WaitForOpera( this, _("Verifying"), [=](const OperaWaitingHd& op_hd) { diff --git a/src/ui/widgets/FilePage.cpp b/src/ui/widgets/FilePage.cpp index d5dd7e0b..8823eb96 100644 --- a/src/ui/widgets/FilePage.cpp +++ b/src/ui/widgets/FilePage.cpp @@ -53,8 +53,6 @@ FilePage::FilePage(QWidget* parent) connect(this->ui_->newDirButton, &QPushButton::clicked, file_tree_view_, &FileTreeView::SlotMkdir); - ui_->optionsButton->setMenu(option_popup_menu_); - ui_->pathEdit->setText( QString::fromStdString(file_tree_view_->GetCurrentPath().u8string())); @@ -67,7 +65,6 @@ FilePage::FilePage(QWidget* parent) ui_->pathEdit->setCompleter(path_edit_completer_); option_popup_menu_ = new QMenu(this); - auto* show_hidden_act = new QAction(_("Show Hidden File"), this); show_hidden_act->setCheckable(true); connect(show_hidden_act, &QAction::triggered, file_tree_view_, @@ -79,6 +76,7 @@ FilePage::FilePage(QWidget* parent) connect(show_system_act, &QAction::triggered, file_tree_view_, &FileTreeView::SlotShowSystemFile); option_popup_menu_->addAction(show_system_act); + ui_->optionsButton->setMenu(option_popup_menu_); connect(ui_->pathEdit, &QLineEdit::textChanged, [=]() { auto path = ui_->pathEdit->text(); diff --git a/src/ui/widgets/FileTreeView.cpp b/src/ui/widgets/FileTreeView.cpp index 7a321281..9fc8aec4 100644 --- a/src/ui/widgets/FileTreeView.cpp +++ b/src/ui/widgets/FileTreeView.cpp @@ -47,17 +47,10 @@ FileTreeView::FileTreeView(QWidget* parent) : QTreeView(parent) { this->setContextMenuPolicy(Qt::CustomContextMenu); connect(this, &QWidget::customContextMenuRequested, this, &FileTreeView::slot_show_custom_context_menu); - - connect(this, &QTreeView::clicked, this, - &FileTreeView::slot_file_tree_view_item_selected); connect(this, &QTreeView::doubleClicked, this, &FileTreeView::slot_file_tree_view_item_double_clicked); } -void FileTreeView::slot_file_tree_view_item_selected(const QModelIndex& index) { - -} - void FileTreeView::selectionChanged(const QItemSelection& selected, const QItemSelection& deselected) { QTreeView::selectionChanged(selected, deselected); diff --git a/src/ui/widgets/FileTreeView.h b/src/ui/widgets/FileTreeView.h index 3627a564..94fdb3de 100644 --- a/src/ui/widgets/FileTreeView.h +++ b/src/ui/widgets/FileTreeView.h @@ -185,13 +185,6 @@ class FileTreeView : public QTreeView { * * @param index */ - void slot_file_tree_view_item_selected(const QModelIndex& index); - - /** - * @brief - * - * @param index - */ void slot_file_tree_view_item_double_clicked(const QModelIndex& index); /** |