aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/dialog/settings/SettingsDialog.cpp30
-rw-r--r--src/ui/dialog/settings/SettingsDialog.h8
-rw-r--r--src/ui/dialog/settings/SettingsGeneral.cpp110
-rw-r--r--src/ui/dialog/settings/SettingsGeneral.h19
-rw-r--r--src/ui/main_window/MainWindow.cpp6
-rw-r--r--src/ui/main_window/MainWindow.h8
-rw-r--r--src/ui/main_window/MainWindowSlotUI.cpp10
7 files changed, 171 insertions, 20 deletions
diff --git a/src/ui/dialog/settings/SettingsDialog.cpp b/src/ui/dialog/settings/SettingsDialog.cpp
index e2677a0f..6737a512 100644
--- a/src/ui/dialog/settings/SettingsDialog.cpp
+++ b/src/ui/dialog/settings/SettingsDialog.cpp
@@ -33,6 +33,7 @@
#include "SettingsGeneral.h"
#include "SettingsKeyServer.h"
#include "SettingsNetwork.h"
+#include "core/GpgConstants.h"
#include "core/function/GlobalSettingStation.h"
#include "ui/main_window/MainWindow.h"
@@ -74,9 +75,24 @@ SettingsDialog::SettingsDialog(QWidget* parent)
setLayout(mainLayout);
// slots for handling the restart needed member
- this->slot_set_restart_needed(false);
+ this->slot_set_restart_needed(0);
+
+ // restart ui
connect(general_tab_, &GeneralTab::SignalRestartNeeded, this,
- &SettingsDialog::slot_set_restart_needed);
+ [=](bool needed) {
+ if (needed && restart_needed_ < RESTART_CODE) {
+ this->restart_needed_ = RESTART_CODE;
+ }
+ });
+
+ // restart core and ui
+ connect(general_tab_, &GeneralTab::SignalDeepRestartNeeded, this,
+ [=](bool needed) {
+ if (needed && restart_needed_ < DEEP_RESTART_CODE)
+ this->restart_needed_ = DEEP_RESTART_CODE;
+ });
+
+ // announce main window
connect(this, &SettingsDialog::SignalRestartNeeded,
qobject_cast<MainWindow*>(parent), &MainWindow::SlotSetRestartNeeded);
@@ -85,12 +101,10 @@ SettingsDialog::SettingsDialog(QWidget* parent)
this->show();
}
-bool SettingsDialog::get_restart_needed() const {
- return this->restart_needed_;
-}
+int SettingsDialog::get_restart_needed() const { return this->restart_needed_; }
-void SettingsDialog::slot_set_restart_needed(bool needed) {
- this->restart_needed_ = needed;
+void SettingsDialog::slot_set_restart_needed(int mode) {
+ this->restart_needed_ = mode;
}
void SettingsDialog::SlotAccept() {
@@ -108,7 +122,7 @@ void SettingsDialog::SlotAccept() {
LOG(INFO) << "restart needed" << get_restart_needed();
if (get_restart_needed()) {
- emit SignalRestartNeeded(true);
+ emit SignalRestartNeeded(get_restart_needed());
}
close();
}
diff --git a/src/ui/dialog/settings/SettingsDialog.h b/src/ui/dialog/settings/SettingsDialog.h
index 172370d0..d28013f4 100644
--- a/src/ui/dialog/settings/SettingsDialog.h
+++ b/src/ui/dialog/settings/SettingsDialog.h
@@ -82,12 +82,12 @@ class SettingsDialog : public GeneralDialog {
*
* @param needed
*/
- void SignalRestartNeeded(bool needed);
+ void SignalRestartNeeded(int);
private:
QTabWidget* tab_widget_; ///<
QDialogButtonBox* button_box_; ///<
- bool restart_needed_{}; ///<
+ int restart_needed_{0}; ///<
/**
* @brief Get the Restart Needed object
@@ -95,7 +95,7 @@ class SettingsDialog : public GeneralDialog {
* @return true
* @return false
*/
- bool get_restart_needed() const;
+ int get_restart_needed() const;
private slots:
@@ -104,7 +104,7 @@ class SettingsDialog : public GeneralDialog {
*
* @param needed
*/
- void slot_set_restart_needed(bool needed);
+ void slot_set_restart_needed(int);
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/dialog/settings/SettingsGeneral.cpp b/src/ui/dialog/settings/SettingsGeneral.cpp
index 3c7bca32..680ed014 100644
--- a/src/ui/dialog/settings/SettingsGeneral.cpp
+++ b/src/ui/dialog/settings/SettingsGeneral.cpp
@@ -28,6 +28,8 @@
#include "SettingsGeneral.h"
+#include "core/GpgContext.h"
+
#ifdef MULTI_LANG_SUPPORT
#include "SettingsDialog.h"
#endif
@@ -70,6 +72,51 @@ GeneralTab::GeneralTab(QWidget* parent)
this, &GeneralTab::slot_language_changed);
#endif
+ connect(ui_->keyDatabseUseCustomCheckBox, &QCheckBox::stateChanged, this,
+ [=](int state) {
+ ui_->customKeyDatabasePathSelectButton->setDisabled(
+ state != Qt::CheckState::Checked);
+ // announce the restart
+ this->slot_key_databse_path_changed();
+ });
+
+ connect(ui_->keyDatabseUseCustomCheckBox, &QCheckBox::stateChanged, this,
+ &GeneralTab::slot_update_custom_key_database_path_label);
+
+ connect(
+ ui_->customKeyDatabasePathSelectButton, &QPushButton::clicked, this,
+ [=]() {
+ QString selected_custom_key_database_path =
+ QFileDialog::getExistingDirectory(
+ this, _("Open Directory"), {},
+ QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
+
+ LOG(INFO) << "key databse path selected"
+ << selected_custom_key_database_path.toStdString();
+
+ if (!selected_custom_key_database_path.isEmpty()) {
+ auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
+ auto& general = settings["general"];
+
+ // update settings
+ if (!general.exists("custom_key_database_path"))
+ general.add("custom_key_database_path",
+ libconfig::Setting::TypeString) =
+ selected_custom_key_database_path.toStdString();
+ else {
+ general["custom_key_database_path"] =
+ selected_custom_key_database_path.toStdString();
+ }
+
+ // announce the restart
+ this->slot_key_databse_path_changed();
+
+ // update ui
+ this->slot_update_custom_key_database_path_label(
+ this->ui_->keyDatabseUseCustomCheckBox->checkState());
+ }
+ });
+
SetSettings();
}
@@ -132,6 +179,19 @@ void GeneralTab::SetSettings() {
} catch (...) {
LOG(ERROR) << _("Setting Operation Error") << _("non_ascii_when_export");
}
+
+ try {
+ bool use_custom_key_database_path =
+ settings.lookup("general.use_custom_key_database_path");
+ if (use_custom_key_database_path)
+ ui_->keyDatabseUseCustomCheckBox->setCheckState(Qt::Checked);
+ } catch (...) {
+ LOG(ERROR) << _("Setting Operation Error")
+ << _("use_custom_key_database_path");
+ }
+
+ this->slot_update_custom_key_database_path_label(
+ ui_->keyDatabseUseCustomCheckBox->checkState());
}
/***********************************
@@ -187,10 +247,60 @@ void GeneralTab::ApplySettings() {
general["confirm_import_keys"] =
ui_->importConfirmationCheckBox->isChecked();
}
+
+ if (!general.exists("use_custom_key_database_path"))
+ general.add("use_custom_key_database_path",
+ libconfig::Setting::TypeBoolean) =
+ ui_->keyDatabseUseCustomCheckBox->isChecked();
+ else {
+ general["use_custom_key_database_path"] =
+ ui_->keyDatabseUseCustomCheckBox->isChecked();
+ }
}
#ifdef MULTI_LANG_SUPPORT
void GeneralTab::slot_language_changed() { emit SignalRestartNeeded(true); }
#endif
+void GeneralTab::slot_update_custom_key_database_path_label(int state) {
+ if (state != Qt::CheckState::Checked) {
+ ui_->currentKeyDatabasePathLabel->setText(QString::fromStdString(
+ GpgContext::GetInstance().GetInfo().DatabasePath));
+
+ // hide label (not necessary to show the default path)
+ this->ui_->currentKeyDatabasePathLabel->setHidden(true);
+ } else {
+ // read from settings file
+ std::string custom_key_database_path;
+ try {
+ auto& settings =
+ GpgFrontend::GlobalSettingStation::GetInstance().GetUISettings();
+ custom_key_database_path = static_cast<std::string>(
+ settings.lookup("general.custom_key_database_path"));
+
+ } catch (...) {
+ LOG(ERROR) << _("Setting Operation Error")
+ << _("custom_key_database_path");
+ }
+
+ LOG(INFO) << "selected_custom_key_database_path from settings"
+ << custom_key_database_path;
+
+ // set label value
+ if (!custom_key_database_path.empty()) {
+ ui_->currentKeyDatabasePathLabel->setText(
+ QString::fromStdString(custom_key_database_path));
+ } else {
+ ui_->currentKeyDatabasePathLabel->setText(
+ _("None custom key database path."));
+ }
+
+ this->ui_->currentKeyDatabasePathLabel->setHidden(false);
+ }
+}
+
+void GeneralTab::slot_key_databse_path_changed() {
+ emit SignalDeepRestartNeeded(true);
+}
+
} // namespace GpgFrontend::UI
diff --git a/src/ui/dialog/settings/SettingsGeneral.h b/src/ui/dialog/settings/SettingsGeneral.h
index b3e7d904..4543df7d 100644
--- a/src/ui/dialog/settings/SettingsGeneral.h
+++ b/src/ui/dialog/settings/SettingsGeneral.h
@@ -72,6 +72,13 @@ class GeneralTab : public QWidget {
*/
void SignalRestartNeeded(bool needed);
+ /**
+ * @brief
+ *
+ * @param needed
+ */
+ void SignalDeepRestartNeeded(bool needed);
+
private:
std::shared_ptr<Ui_GeneralSettings> ui_; ///<
@@ -92,6 +99,18 @@ class GeneralTab : public QWidget {
*/
void slot_language_changed();
+ /**
+ * @brief
+ *
+ */
+ void slot_update_custom_key_database_path_label(int state);
+
+ /**
+ * @brief
+ *
+ */
+ void slot_key_databse_path_changed();
+
#endif
};
} // namespace GpgFrontend::UI
diff --git a/src/ui/main_window/MainWindow.cpp b/src/ui/main_window/MainWindow.cpp
index e3e4c0ab..b0273d86 100644
--- a/src/ui/main_window/MainWindow.cpp
+++ b/src/ui/main_window/MainWindow.cpp
@@ -62,12 +62,18 @@ void MainWindow::Init() noexcept {
/* Variable containing if restart is needed */
this->SlotSetRestartNeeded(false);
+ // init menu bar
+ this->setMenuBar(new QMenuBar());
+
create_actions();
create_menus();
create_tool_bars();
create_status_bar();
create_dock_windows();
+ // show menu bar
+ this->menuBar()->show();
+
connect(edit_->tab_widget_, &QTabWidget::currentChanged, this,
&MainWindow::slot_disable_tab_actions);
connect(SignalStation::GetInstance(),
diff --git a/src/ui/main_window/MainWindow.h b/src/ui/main_window/MainWindow.h
index b31e2fcb..2e24cecd 100644
--- a/src/ui/main_window/MainWindow.h
+++ b/src/ui/main_window/MainWindow.h
@@ -148,7 +148,7 @@ class MainWindow : public GeneralMainWindow {
* @details get value of member restartNeeded to needed.
* @param needed true, if application has to be restarted
*/
- void SlotSetRestartNeeded(bool needed);
+ void SlotSetRestartNeeded(int);
private slots:
@@ -322,7 +322,7 @@ class MainWindow : public GeneralMainWindow {
/**
* @brief return true, if restart is needed
*/
- [[nodiscard]] bool get_restart_needed() const;
+ [[nodiscard]] int get_restart_needed() const;
TextEdit* edit_{}; ///< Tabwidget holding the edit-windows
QMenu* file_menu_{}; ///< Submenu for file-operations
@@ -387,7 +387,7 @@ class MainWindow : public GeneralMainWindow {
QAction* about_act_{}; ///< Action to open about dialog
QAction* check_update_act_{}; ///< Action to open about dialog
QAction* translate_act_{}; ///< Action to open about dialog
- QAction* gnupg_act_{}; ///< Action to open about dialog
+ QAction* gnupg_act_{}; ///< Action to open about dialog
QAction* open_settings_act_{}; ///< Action to open settings dialog
QAction* show_key_details_act_{}; ///< Action to open key-details dialog
QAction* start_wizard_act_{}; ///< Action to open the wizard
@@ -403,7 +403,7 @@ class MainWindow : public GeneralMainWindow {
InfoBoardWidget* info_board_{}; ///<
bool attachment_dock_created_{}; ///<
- bool restart_needed_{}; ///<
+ int restart_needed_{0}; ///<
bool prohibit_update_checking_ = false; ///<
};
diff --git a/src/ui/main_window/MainWindowSlotUI.cpp b/src/ui/main_window/MainWindowSlotUI.cpp
index 9061349e..8961a33f 100644
--- a/src/ui/main_window/MainWindowSlotUI.cpp
+++ b/src/ui/main_window/MainWindowSlotUI.cpp
@@ -27,6 +27,7 @@
*/
#include "MainWindow.h"
+#include "core/GpgConstants.h"
#include "core/function/GlobalSettingStation.h"
#include "ui/UserInterfaceUtils.h"
#include "ui/struct/SettingsObject.h"
@@ -128,7 +129,7 @@ void MainWindow::slot_open_settings_dialog() {
if (get_restart_needed()) {
if (edit_->MaybeSaveAnyTab()) {
save_settings();
- qApp->exit(RESTART_CODE);
+ qApp->exit(get_restart_needed());
}
}
});
@@ -182,11 +183,12 @@ void MainWindow::slot_cut_pgp_header() {
edit_->SlotFillTextEditWithText(content.trimmed());
}
-void MainWindow::SlotSetRestartNeeded(bool needed) {
- this->restart_needed_ = needed;
+void MainWindow::SlotSetRestartNeeded(int mode) {
+ LOG(INFO) << "restart mode" << mode;
+ this->restart_needed_ = mode;
}
-bool MainWindow::get_restart_needed() const { return this->restart_needed_; }
+int MainWindow::get_restart_needed() const { return this->restart_needed_; }
void MainWindow::SetCryptoMenuStatus(
MainWindow::CryptoMenu::OperationType type) {