aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/dialog/settings/SettingsGeneral.cpp
diff options
context:
space:
mode:
authorSaturn&Eric <[email protected]>2023-07-13 16:51:19 +0000
committerGitHub <[email protected]>2023-07-13 16:51:19 +0000
commit40bcaec6c8c0c363bf793745131a2e6d0274fd6d (patch)
tree8dc11045bee7caf8a1b936ee2203dd39bec59e07 /src/ui/dialog/settings/SettingsGeneral.cpp
parentMerge pull request #102 from CDmking/main (diff)
parentMerge branch 'main' into dev/2.1.0/main (diff)
downloadGpgFrontend-40bcaec6c8c0c363bf793745131a2e6d0274fd6d.tar.gz
GpgFrontend-40bcaec6c8c0c363bf793745131a2e6d0274fd6d.zip
Merge pull request #106 from saturneric/dev/2.1.0/main
Develop 2.1.1.4
Diffstat (limited to 'src/ui/dialog/settings/SettingsGeneral.cpp')
-rw-r--r--src/ui/dialog/settings/SettingsGeneral.cpp55
1 files changed, 55 insertions, 0 deletions
diff --git a/src/ui/dialog/settings/SettingsGeneral.cpp b/src/ui/dialog/settings/SettingsGeneral.cpp
index c967b8fd..be5190dd 100644
--- a/src/ui/dialog/settings/SettingsGeneral.cpp
+++ b/src/ui/dialog/settings/SettingsGeneral.cpp
@@ -48,6 +48,9 @@ GeneralTab::GeneralTab(QWidget* parent)
_("Save checked private keys on exit and restore them on next start."));
ui_->clearGpgPasswordCacheCheckBox->setText(
_("Clear gpg password cache when closing GpgFrontend."));
+ ui_->restoreTextEditorPageCheckBox->setText(
+ _("Automatically restore unsaved Text Editor pages after an application "
+ "crash."));
ui_->importConfirmationBox->setTitle(_("Operation"));
ui_->longerKeyExpirationDateCheckBox->setText(
@@ -60,6 +63,16 @@ GeneralTab::GeneralTab(QWidget* parent)
"<b>" + QString(_("NOTE")) + _(": ") + "</b>" +
_("GpgFrontend will restart automatically if you change the language!"));
+ ui_->dataBox->setTitle(_("Data"));
+ ui_->clearAllLogFilesButton->setText(QString::fromStdString(
+ (boost::format(_("Clear All Log (Total Size: %s)")) %
+ GlobalSettingStation::GetInstance().GetLogFilesSize())
+ .str()));
+ ui_->clearAllDataObjectsButton->setText(QString::fromStdString(
+ (boost::format(_("Clear All Data Objects (Total Size: %s)")) %
+ GlobalSettingStation::GetInstance().GetDataObjectsFilesSize())
+ .str()));
+
#ifdef MULTI_LANG_SUPPORT
lang_ = SettingsDialog::ListLanguages();
for (const auto& l : lang_) {
@@ -69,6 +82,31 @@ GeneralTab::GeneralTab(QWidget* parent)
this, &GeneralTab::slot_language_changed);
#endif
+ connect(ui_->clearAllLogFilesButton, &QPushButton::clicked, this, [=]() {
+ GlobalSettingStation::GetInstance().ClearAllLogFiles();
+ ui_->clearAllLogFilesButton->setText(QString::fromStdString(
+ (boost::format(_("Clear All Log (Total Size: %s)")) %
+ GlobalSettingStation::GetInstance().GetLogFilesSize())
+ .str()));
+ });
+
+ connect(ui_->clearAllDataObjectsButton, &QPushButton::clicked, this, [=]() {
+ QMessageBox::StandardButton reply;
+ reply = QMessageBox::question(
+ this, _("Confirm"),
+ _("Are you sure you want to clear all data objects?\nThis will result "
+ "in "
+ "loss of all cached form positions, statuses, key servers, etc."),
+ QMessageBox::Yes | QMessageBox::No);
+ if (reply == QMessageBox::Yes) {
+ GlobalSettingStation::GetInstance().ClearAllDataObjects();
+ ui_->clearAllDataObjectsButton->setText(QString::fromStdString(
+ (boost::format(_("Clear All Data Objects (Total Size: %s)")) %
+ GlobalSettingStation::GetInstance().GetDataObjectsFilesSize())
+ .str()));
+ }
+ });
+
SetSettings();
}
@@ -98,6 +136,15 @@ void GeneralTab::SetSettings() {
}
try {
+ bool restore_text_editor_page =
+ settings.lookup("general.restore_text_editor_page");
+ if (restore_text_editor_page)
+ ui_->restoreTextEditorPageCheckBox->setCheckState(Qt::Checked);
+ } catch (...) {
+ SPDLOG_ERROR("setting operation error: restore_text_editor_page");
+ }
+
+ try {
bool longer_expiration_date =
settings.lookup("general.longer_expiration_date");
SPDLOG_DEBUG("longer_expiration_date: {}", longer_expiration_date);
@@ -170,6 +217,14 @@ void GeneralTab::ApplySettings() {
ui_->saveCheckedKeysCheckBox->isChecked();
}
+ if (!general.exists("restore_text_editor_page"))
+ general.add("restore_text_editor_page", libconfig::Setting::TypeBoolean) =
+ ui_->restoreTextEditorPageCheckBox->isChecked();
+ else {
+ general["restore_text_editor_page"] =
+ ui_->restoreTextEditorPageCheckBox->isChecked();
+ }
+
#ifdef MULTI_LANG_SUPPORT
if (!general.exists("lang"))
general.add("lang", libconfig::Setting::TypeBoolean) =