diff options
author | Saturneric <[email protected]> | 2022-03-12 10:00:36 +0000 |
---|---|---|
committer | Saturneric <[email protected]> | 2022-03-12 10:00:36 +0000 |
commit | 1755ba16fe9d5d475094fa0cde873f6d8b642549 (patch) | |
tree | d8ff7763fee7f6db013d19acc1160e9d59407b77 | |
parent | <feat>(core, ui): Provides the ability to handle folders (diff) | |
download | GpgFrontend-1755ba16fe9d5d475094fa0cde873f6d8b642549.tar.gz GpgFrontend-1755ba16fe9d5d475094fa0cde873f6d8b642549.zip |
<refactor, fix>(core, ui): Some tweaks and fixes
-rwxr-xr-x | src/ui/KeyMgmt.cpp | 5 | ||||
-rw-r--r-- | src/ui/main_window/MainWindow.cpp | 35 | ||||
-rw-r--r-- | src/ui/main_window/MainWindowUI.cpp | 5 |
3 files changed, 31 insertions, 14 deletions
diff --git a/src/ui/KeyMgmt.cpp b/src/ui/KeyMgmt.cpp index 56097355..57d8ba1f 100755 --- a/src/ui/KeyMgmt.cpp +++ b/src/ui/KeyMgmt.cpp @@ -526,6 +526,9 @@ void KeyMgmt::SlotExportAsOpenSSHFormat() { } void KeyMgmt::SlotImportKeyPackage() { + + LOG(INFO) << "Importing key package..."; + auto key_package_file_name = QFileDialog::getOpenFileName( this, _("Import Key Package"), {}, QString(_("Key Package")) + " (*.gfepack);;All Files (*)"); @@ -539,6 +542,8 @@ void KeyMgmt::SlotImportKeyPackage() { GpgImportInformation info; + LOG(INFO) << "Importing key package: " << key_package_file_name.toStdString(); + if (KeyPackageOperator::ImportKeyPackage(key_package_file_name.toStdString(), key_file_name.toStdString(), info)) { emit SignalStatusBarChanged(QString(_("key(s) imported"))); diff --git a/src/ui/main_window/MainWindow.cpp b/src/ui/main_window/MainWindow.cpp index 53fce2ca..368c5630 100644 --- a/src/ui/main_window/MainWindow.cpp +++ b/src/ui/main_window/MainWindow.cpp @@ -32,8 +32,8 @@ #ifdef RELEASE #include "ui/thread/VersionCheckThread.h" #endif -#include "ui/SignalStation.h" #include "core/function/GlobalSettingStation.h" +#include "ui/SignalStation.h" #include "ui/struct/SettingsObject.h" namespace GpgFrontend::UI { @@ -74,7 +74,7 @@ void MainWindow::Init() noexcept { &MainWindow::slot_disable_tab_actions); connect(SignalStation::GetInstance(), &SignalStation::SignalRefreshStatusBar, this, - [=](const QString& message, int timeout) { + [=](const QString &message, int timeout) { statusBar()->showMessage(message, timeout); }); @@ -89,18 +89,19 @@ void MainWindow::Init() noexcept { QStringList args = qApp->arguments(); if (args.size() > 1) { if (!args[1].startsWith("-")) { - if (QFile::exists(args[1])) edit_->LoadFile(args[1]); + if (QFile::exists(args[1])) + edit_->LoadFile(args[1]); } } edit_->CurTextPage()->setFocus(); - auto& settings = GlobalSettingStation::GetInstance().GetUISettings(); + auto &settings = GlobalSettingStation::GetInstance().GetUISettings(); if (!settings.exists("wizard") || settings.lookup("wizard").getType() != libconfig::Setting::TypeGroup) settings.add("wizard", libconfig::Setting::TypeGroup); - auto& wizard = settings["wizard"]; + auto &wizard = settings["wizard"]; // Show wizard, if the don't show wizard message box wasn't checked // and keylist doesn't contain a private key @@ -146,6 +147,9 @@ void MainWindow::restore_settings() { LOG(INFO) << _("Called"); try { + + LOG(INFO) << "restore settings main_windows_state"; + SettingsObject main_windows_state("main_windows_state"); std::string window_state = main_windows_state.Check( @@ -191,6 +195,8 @@ void MainWindow::restore_settings() { this->setIconSize(QSize(width, height)); import_button_->setIconSize(QSize(width, height)); + LOG(INFO) << "restore settings key_server"; + SettingsObject key_server_json("key_server"); if (!key_server_json.contains("server_list")) { @@ -203,13 +209,13 @@ void MainWindow::restore_settings() { key_server_json["default_server"] = 0; } - auto& settings = GlobalSettingStation::GetInstance().GetUISettings(); + auto &settings = GlobalSettingStation::GetInstance().GetUISettings(); if (!settings.exists("general") || settings.lookup("general").getType() != libconfig::Setting::TypeGroup) settings.add("general", libconfig::Setting::TypeGroup); - auto& general = settings["general"]; + auto &general = settings["general"]; if (!general.exists("save_key_checked")) { general.add("save_key_checked", libconfig::Setting::TypeBoolean) = true; @@ -224,11 +230,14 @@ void MainWindow::restore_settings() { general.lookupValue("save_key_checked", save_key_checked); try { + + LOG(INFO) << "restore settings default_key_checked"; + // Checked Keys SettingsObject default_key_checked("default_key_checked"); if (save_key_checked) { auto key_ids_ptr = std::make_unique<KeyIdArgsList>(); - for (auto& it : default_key_checked) { + for (auto &it : default_key_checked) { std::string key_id = it; LOG(INFO) << "get checked key id" << key_id; key_ids_ptr->push_back(key_id); @@ -239,6 +248,8 @@ void MainWindow::restore_settings() { LOG(ERROR) << "restore default_key_checked failed"; } + LOG(INFO) << "restore settings smtp_passport"; + SettingsObject smtp_passport("smtp_passport"); smtp_passport.Check("enable", false); @@ -259,7 +270,7 @@ void MainWindow::restore_settings() { } void MainWindow::save_settings() { - auto& settings = GlobalSettingStation::GetInstance().GetUISettings(); + auto &settings = GlobalSettingStation::GetInstance().GetUISettings(); try { SettingsObject main_windows_state("main_windows_state"); @@ -281,7 +292,7 @@ void MainWindow::save_settings() { SettingsObject default_key_checked("default_key_checked"); default_key_checked.clear(); - for (const auto& key_id : *key_ids_need_to_store) + for (const auto &key_id : *key_ids_need_to_store) default_key_checked.push_back(key_id); } else { settings["general"].remove("save_key_checked"); @@ -302,7 +313,7 @@ void MainWindow::close_attachment_dock() { attachment_dock_created_ = false; } -void MainWindow::closeEvent(QCloseEvent* event) { +void MainWindow::closeEvent(QCloseEvent *event) { /* * ask to save changes, if there are * modified documents in any tab @@ -318,4 +329,4 @@ void MainWindow::closeEvent(QCloseEvent* event) { // GpgContext::GetInstance().clearPasswordCache(); } -} // namespace GpgFrontend::UI +} // namespace GpgFrontend::UI diff --git a/src/ui/main_window/MainWindowUI.cpp b/src/ui/main_window/MainWindowUI.cpp index cdc1a39a..01c4bbc9 100644 --- a/src/ui/main_window/MainWindowUI.cpp +++ b/src/ui/main_window/MainWindowUI.cpp @@ -274,9 +274,9 @@ void MainWindow::create_actions() { /* Popup-Menu-Action for KeyList */ append_selected_keys_act_ = - new QAction(_("Append Public Key To Text Editor"), this); + new QAction(_("Append To Text Editor"), this); append_selected_keys_act_->setToolTip( - _("Append The Selected Keys To Text in Editor")); + _("Append The Selected Public Key To Text in Editor")); connect(append_selected_keys_act_, &QAction::triggered, this, &MainWindow::slot_append_selected_keys); @@ -324,6 +324,7 @@ void MainWindow::create_actions() { }); receive_mail_act_ = new QAction(_("Message Inbox"), this); + receive_mail_act_->setVisible(false); receive_mail_act_->setIcon(QIcon(":receive_email.png")); connect(receive_mail_act_, &QAction::triggered, this, [=]() { auto* dialog = new ReceiveMailDialog(this); |