aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CMakeLists.txt20
-rw-r--r--src/CMakeLists.txt13
-rw-r--r--src/main.cpp17
-rw-r--r--src/ui/KeyServerImportDialog.cpp4
-rw-r--r--src/ui/KeyUploadDialog.cpp6
-rw-r--r--src/ui/Wizard.cpp79
-rw-r--r--src/ui/Wizard.h5
-rw-r--r--src/ui/help/VersionCheckThread.cpp12
-rw-r--r--src/ui/settings/GlobalSettingStation.cpp10
-rw-r--r--src/ui/settings/GlobalSettingStation.h3
-rw-r--r--src/ui/settings/SettingsDialog.cpp25
-rw-r--r--src/ui/settings/SettingsGeneral.cpp95
-rw-r--r--src/ui/settings/SettingsGeneral.h16
-rw-r--r--src/ui/widgets/KeyList.cpp13
14 files changed, 215 insertions, 103 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index b095d5c8..914b447a 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -254,8 +254,26 @@ if (QT5_ENV_SUPPORT)
set(CMAKE_AUTOUIC ON)
endif ()
-add_subdirectory(third_party)
+if (SMTP_SUPPORT)
+ add_compile_definitions(SMTP_SUPPORT)
+endif ()
+
+if (SERVER_SUPPORT)
+ add_compile_definitions(SERVER_SUPPORT)
+endif ()
+
+if (ADVANCE_SUPPORT)
+ add_compile_definitions(ADVANCE_SUPPORT)
+endif ()
+
+
+if (MULTI_LANG_SUPPORT)
+ add_compile_definitions(MULTI_LANG_SUPPORT)
+endif ()
+
+
+add_subdirectory(third_party)
add_subdirectory(src)
if (TEST_BUILD)
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 4e9428fa..47cd8a50 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -10,16 +10,19 @@ endif ()
if (SMTP_SUPPORT)
message(STATUS "Build SMTP Support")
+ add_compile_definitions(SMTP_SUPPORT)
add_subdirectory(smtp)
endif ()
if (SERVER_SUPPORT)
message(STATUS "Build Server Support")
+ add_compile_definitions(SERVER_SUPPORT)
add_subdirectory(server)
endif ()
if (ADVANCE_SUPPORT)
message(STATUS "Build Advance Support")
+ add_compile_definitions(ADVANCE_SUPPORT)
add_subdirectory(advance)
endif ()
@@ -56,6 +59,7 @@ file(GLOB_RECURSE ALL_SOURCE_FILES RELACTIVE ${CMAKE_SOURCE_DIR}/src/*.cpp)
# i18n
if (MULTI_LANG_SUPPORT)
+ message(STATUS "Build Multiply Languages Support")
# Set Translation Files
find_package(Gettext REQUIRED)
FIND_PROGRAM(GETTEXT_MSGFMT_EXECUTABLE msgfmt)
@@ -82,11 +86,14 @@ if (MULTI_LANG_SUPPORT)
make_directory(${CMAKE_SOURCE_DIR}/resource/locale/out/${_langName}/LC_MESSAGES)
add_custom_command(
TARGET translations
+ COMMAND echo Processing po LANG ${_langName}
+ )
+ add_custom_command(
+ TARGET translations
COMMAND msgfmt --check --verbose --output-file ${CMAKE_SOURCE_DIR}/resource/locale/out/${_langName}/LC_MESSAGES/GpgFrontend.mo ${_poFile}
)
endforeach ()
-
endif ()
endif ()
@@ -180,6 +187,10 @@ if (APPLICATION_BUILD)
else ()
add_executable(${AppName} ${BASE_SOURCE} ${RESOURCE_FILES} ${QT5_MOCS})
endif ()
+
+ # Make app build with resources
+ add_dependencies(${AppName} resources)
+
endif ()
if (APPLICATION_BUILD)
diff --git a/src/main.cpp b/src/main.cpp
index 751fd46b..7014ae05 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -40,7 +40,8 @@ int main(int argc, char* argv[]) {
QApplication app(argc, argv);
// get application path
- auto app_path = GlobalSettingStation::GetInstance().GetAppDir();
+ auto app_path =
+ GpgFrontend::UI::GlobalSettingStation::GetInstance().GetAppDir();
// logging system
init_logging();
@@ -113,7 +114,8 @@ void init_logging() {
"%datetime %level %func %msg");
auto logfile_path =
- (GlobalSettingStation::GetInstance().GetLogDir() / to_iso_string(now));
+ (GpgFrontend::UI::GlobalSettingStation::GetInstance().GetLogDir() /
+ to_iso_string(now));
logfile_path.replace_extension(".log");
defaultConf.setGlobally(el::ConfigurationType::Filename,
logfile_path.string());
@@ -124,7 +126,8 @@ void init_logging() {
}
void init_locale() {
- auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
+ auto& settings =
+ GpgFrontend::UI::GlobalSettingStation::GetInstance().GetUISettings();
if (!settings.exists("general") ||
settings.lookup("general").getType() != libconfig::Setting::TypeGroup)
@@ -135,18 +138,20 @@ void init_locale() {
general.add("lang", libconfig::Setting::TypeString) =
QLocale::system().name().toStdString();
- GlobalSettingStation::GetInstance().Sync();
+ GpgFrontend::UI::GlobalSettingStation::GetInstance().Sync();
std::string lang;
if (!general.lookupValue("lang", lang)) {
LOG(ERROR) << _("Could not read properly from configure file");
};
-
+
LOG(INFO) << "lang" << lang;
// GNU gettext settings
setlocale(LC_ALL, lang.c_str());
bindtextdomain(PROJECT_NAME,
- GlobalSettingStation::GetInstance().GetLocaleDir().c_str());
+ GpgFrontend::UI::GlobalSettingStation::GetInstance()
+ .GetLocaleDir()
+ .c_str());
textdomain(PROJECT_NAME);
}
diff --git a/src/ui/KeyServerImportDialog.cpp b/src/ui/KeyServerImportDialog.cpp
index b529637f..4f2c2d59 100644
--- a/src/ui/KeyServerImportDialog.cpp
+++ b/src/ui/KeyServerImportDialog.cpp
@@ -492,10 +492,10 @@ void KeyServerImportDialog::setLoading(bool status) {
KeyServerImportDialog::KeyServerImportDialog(QWidget* parent)
: QDialog(parent),
+ mAutomatic(true),
appPath(qApp->applicationDirPath()),
settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini",
- QSettings::IniFormat),
- mAutomatic(true) {
+ QSettings::IniFormat) {
setWindowFlags(Qt::Window | Qt::WindowTitleHint | Qt::CustomizeWindowHint);
message = new QLabel;
diff --git a/src/ui/KeyUploadDialog.cpp b/src/ui/KeyUploadDialog.cpp
index e8c37c5b..b2bfff6d 100644
--- a/src/ui/KeyUploadDialog.cpp
+++ b/src/ui/KeyUploadDialog.cpp
@@ -33,11 +33,11 @@ namespace GpgFrontend::UI {
KeyUploadDialog::KeyUploadDialog(const KeyIdArgsListPtr& keys_ids,
QWidget* parent)
- : appPath(qApp->applicationDirPath()),
+ : QDialog(parent),
+ appPath(qApp->applicationDirPath()),
settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini",
QSettings::IniFormat),
- mKeys(GpgKeyGetter::GetInstance().GetKeys(keys_ids)),
- QDialog(parent) {
+ mKeys(GpgKeyGetter::GetInstance().GetKeys(keys_ids)) {
auto* pb = new QProgressBar();
pb->setRange(0, 0);
pb->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
diff --git a/src/ui/Wizard.cpp b/src/ui/Wizard.cpp
index c2733f0c..996efa7e 100644
--- a/src/ui/Wizard.cpp
+++ b/src/ui/Wizard.cpp
@@ -24,13 +24,11 @@
#include "ui/Wizard.h"
+#include "ui/settings/GlobalSettingStation.h"
+
namespace GpgFrontend::UI {
-Wizard::Wizard(KeyMgmt* keyMgmt, QWidget* parent)
- : QWizard(parent),
- appPath(qApp->applicationDirPath()),
- settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini",
- QSettings::IniFormat) {
+Wizard::Wizard(KeyMgmt* keyMgmt, QWidget* parent) : QWizard(parent) {
mKeyMgmt = keyMgmt;
setPage(Page_Intro, new IntroPage(this));
@@ -47,26 +45,42 @@ Wizard::Wizard(KeyMgmt* keyMgmt, QWidget* parent)
setPixmap(QWizard::LogoPixmap, QPixmap(":/logo_small.png"));
setPixmap(QWizard::BannerPixmap, QPixmap(":/banner.png"));
- setStartId(settings.value("wizard/nextPage", -1).toInt());
- settings.remove("wizard/nextPage");
+ auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
+ int next_page_id = -1;
+ try {
+ next_page_id = settings.lookup("wizard.next_page");
+ } catch (...) {
+ LOG(ERROR) << _("Setting Operation Error");
+ }
+ setStartId(next_page_id);
connect(this, SIGNAL(accepted()), this, SLOT(slotWizardAccepted()));
}
void Wizard::slotWizardAccepted() {
+ LOG(INFO) << _("Called");
// Don't show is mapped to show -> negation
- settings.setValue("wizard/showWizard", !field("showWizard").toBool());
-
+ try {
+ auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
+ if (!settings.exists("wizard")) {
+ settings.add("wizard", libconfig::Setting::TypeGroup);
+ }
+ auto& wizard = settings["wizard"];
+ if (!wizard.exists("show_wizard")) {
+ wizard.add("show_wizard", libconfig::Setting::TypeBoolean) = false;
+ } else {
+ wizard["show_wizard"] = false;
+ }
+ GlobalSettingStation::GetInstance().Sync();
+ } catch (...) {
+ LOG(ERROR) << _("Setting Operation Error");
+ }
if (field("openHelp").toBool()) {
emit signalOpenHelp("docu.html#content");
}
}
-IntroPage::IntroPage(QWidget* parent)
- : QWizardPage(parent),
- appPath(qApp->applicationDirPath()),
- settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini",
- QSettings::IniFormat) {
+IntroPage::IntroPage(QWidget* parent) : QWizardPage(parent) {
setTitle(_("Getting Started..."));
setSubTitle(_("... with GpgFrontend"));
@@ -97,7 +111,16 @@ IntroPage::IntroPage(QWidget* parent)
langSelectBox->addItem(l);
}
// selected entry from config
- QString langKey = settings.value("int/lang").toString();
+
+ auto lang = "en_US";
+ auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
+ try {
+ lang = settings.lookup("general.lang");
+ } catch (...) {
+ LOG(INFO) << "Read for general.lang failed";
+ }
+
+ QString langKey = lang;
QString langValue = languages.value(langKey);
if (!langKey.isEmpty()) {
langSelectBox->setCurrentIndex(langSelectBox->findText(langValue));
@@ -115,8 +138,28 @@ IntroPage::IntroPage(QWidget* parent)
}
void IntroPage::slotLangChange(const QString& lang) {
- settings.setValue("int/lang", languages.key(lang));
- settings.setValue("wizard/nextPage", this->wizard()->currentId());
+ 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"];
+ if (!general.exists("lang"))
+ general.add("lang", libconfig::Setting::TypeString) =
+ languages.key(lang).toStdString();
+
+ if (!settings.exists("wizard") ||
+ settings.lookup("wizard").getType() != libconfig::Setting::TypeGroup)
+ settings.add("wizard", libconfig::Setting::TypeGroup);
+
+ auto& wizard = settings["wizard"];
+ if (!wizard.exists("next_page"))
+ wizard.add("next_page", libconfig::Setting::TypeInt) =
+ this->wizard()->currentId();
+
+ GlobalSettingStation::GetInstance().Sync();
+
qApp->exit(RESTART_CODE);
}
@@ -228,7 +271,7 @@ KeyGenPage::KeyGenPage(QWidget* parent) : QWizardPage(parent) {
int KeyGenPage::nextId() const { return Wizard::Page_Conclusion; }
void KeyGenPage::slotGenerateKeyDialog() {
- qDebug() << "Try Opening KeyGenDialog";
+ LOG(INFO) << "Try Opening KeyGenDialog";
(new KeyGenDialog(this))->show();
wizard()->next();
}
diff --git a/src/ui/Wizard.h b/src/ui/Wizard.h
index e1e9092d..62fc1a41 100644
--- a/src/ui/Wizard.h
+++ b/src/ui/Wizard.h
@@ -51,8 +51,6 @@ class Wizard : public QWizard {
private:
KeyMgmt* mKeyMgmt;
- QString appPath;
- QSettings settings;
private slots:
@@ -74,9 +72,6 @@ class IntroPage : public QWizardPage {
[[nodiscard]] int nextId() const override;
private:
- QString appPath;
- QSettings settings;
-
private slots:
void slotLangChange(const QString& lang);
diff --git a/src/ui/help/VersionCheckThread.cpp b/src/ui/help/VersionCheckThread.cpp
index a35583f4..44ef0bd1 100644
--- a/src/ui/help/VersionCheckThread.cpp
+++ b/src/ui/help/VersionCheckThread.cpp
@@ -32,7 +32,7 @@ using namespace rapidjson;
namespace GpgFrontend::UI {
void VersionCheckThread::run() {
- qDebug() << "Start Version Thread to get latest version from Github";
+ LOG(INFO) << "Start Version Thread to get latest version from Github";
auto currentVersion = "v" + QString::number(VERSION_MAJOR) + "." +
QString::number(VERSION_MINOR) + "." +
@@ -43,7 +43,7 @@ void VersionCheckThread::run() {
}
if (mNetworkReply->error() != QNetworkReply::NoError) {
- qDebug() << "VersionCheckThread Found Network Error";
+ LOG(ERROR) << "VersionCheckThread Found Network Error";
return;
}
@@ -54,16 +54,16 @@ void VersionCheckThread::run() {
QString latestVersion = d["tag_name"].GetString();
- qDebug() << "Latest Version From Github" << latestVersion;
+ LOG(INFO) << "Latest Version From Github" << latestVersion.toStdString();
- QRegularExpression re("^[vV](\\d+\\.)?(\\d+\\.)?(\\*|\\d+)");
+ QRegularExpression re(R"(^[vV](\d+\.)?(\d+\.)?(\*|\d+))");
QRegularExpressionMatch match = re.match(latestVersion);
if (match.hasMatch()) {
latestVersion = match.captured(0); // matched == "23 def"
- qDebug() << "Latest Version Matched" << latestVersion;
+ LOG(INFO) << "Latest Version Matched" << latestVersion.toStdString();
} else {
latestVersion = currentVersion;
- qDebug() << "Latest Version Unknown" << latestVersion;
+ LOG(WARNING) << "Latest Version Unknown" << latestVersion.toStdString();
}
if (latestVersion != currentVersion) {
diff --git a/src/ui/settings/GlobalSettingStation.cpp b/src/ui/settings/GlobalSettingStation.cpp
index 3e229091..8946d267 100644
--- a/src/ui/settings/GlobalSettingStation.cpp
+++ b/src/ui/settings/GlobalSettingStation.cpp
@@ -24,16 +24,18 @@
#include "GlobalSettingStation.h"
-std::unique_ptr<GlobalSettingStation> GlobalSettingStation::_instance = nullptr;
+std::unique_ptr<GpgFrontend::UI::GlobalSettingStation>
+ GpgFrontend::UI::GlobalSettingStation::_instance = nullptr;
-GlobalSettingStation& GlobalSettingStation::GetInstance() {
+GpgFrontend::UI::GlobalSettingStation&
+GpgFrontend::UI::GlobalSettingStation::GetInstance() {
if (_instance == nullptr) {
_instance = std::make_unique<GlobalSettingStation>();
}
return *_instance;
}
-void GlobalSettingStation::Sync() noexcept {
+void GpgFrontend::UI::GlobalSettingStation::Sync() noexcept {
using namespace libconfig;
try {
ui_cfg.writeFile(ui_config_path.c_str());
@@ -46,7 +48,7 @@ void GlobalSettingStation::Sync() noexcept {
}
}
-GlobalSettingStation::GlobalSettingStation() noexcept {
+GpgFrontend::UI::GlobalSettingStation::GlobalSettingStation() noexcept {
using namespace boost::filesystem;
using namespace libconfig;
diff --git a/src/ui/settings/GlobalSettingStation.h b/src/ui/settings/GlobalSettingStation.h
index b5a86865..22713626 100644
--- a/src/ui/settings/GlobalSettingStation.h
+++ b/src/ui/settings/GlobalSettingStation.h
@@ -31,6 +31,8 @@
#include "ui/GpgFrontendUI.h"
+namespace GpgFrontend::UI {
+
class GlobalSettingStation : public QObject {
Q_OBJECT
public:
@@ -84,5 +86,6 @@ class GlobalSettingStation : public QObject {
static std::unique_ptr<GlobalSettingStation> _instance;
};
+} // namespace GpgFrontend::UI
#endif // GPGFRONTEND_GLOBALSETTINGSTATION_H
diff --git a/src/ui/settings/SettingsDialog.cpp b/src/ui/settings/SettingsDialog.cpp
index 4f959b68..f917a9b0 100644
--- a/src/ui/settings/SettingsDialog.cpp
+++ b/src/ui/settings/SettingsDialog.cpp
@@ -24,6 +24,7 @@
#include "SettingsDialog.h"
+#include "GlobalSettingStation.h"
#include "SettingsAdvanced.h"
#include "SettingsAppearance.h"
#include "SettingsGeneral.h"
@@ -120,23 +121,25 @@ QHash<QString, QString> SettingsDialog::listLanguages() {
languages.insert(QString(), _("System Default"));
- QString appPath = qApp->applicationDirPath();
- QDir qmDir = QDir(RESOURCE_DIR(appPath) + "/ts/");
- QStringList fileNames = qmDir.entryList(QStringList("gpgfrontend_*.qm"));
+ auto locale_path = GlobalSettingStation::GetInstance().GetLocaleDir();
- for (int i = 0; i < fileNames.size(); ++i) {
- QString locale = fileNames[i];
- locale.truncate(locale.lastIndexOf('.'));
- locale.remove(0, locale.indexOf('_') + 1);
+ auto locale_dir = QDir(locale_path.c_str());
+ QStringList file_names = locale_dir.entryList(QStringList("*"));
+
+ for (int i = 0; i < file_names.size(); ++i) {
+ QString locale = file_names[i];
+ LOG(INFO) << "locale" << locale.toStdString();
+ if (locale == "." || locale == "..") continue;
// this works in qt 4.8
- QLocale qloc(locale);
+ QLocale q_locale(locale);
+ if (q_locale.nativeCountryName().isEmpty()) continue;
#if QT_VERSION < 0x040800
QString language =
- QLocale::languageToString(qloc.language()) + " (" + locale +
- ")"; //+ " (" + QLocale::languageToString(qloc.language()) + ")";
+ QLocale::languageToString(q_locale.language()) + " (" + locale +
+ ")"; //+ " (" + QLocale::languageToString(q_locale.language()) + ")";
#else
- QString language = qloc.nativeLanguageName() + " (" + locale + ")";
+ auto language = q_locale.nativeLanguageName() + " (" + locale + ")";
#endif
languages.insert(locale, language);
}
diff --git a/src/ui/settings/SettingsGeneral.cpp b/src/ui/settings/SettingsGeneral.cpp
index 51e0649c..a5ae124e 100644
--- a/src/ui/settings/SettingsGeneral.cpp
+++ b/src/ui/settings/SettingsGeneral.cpp
@@ -28,20 +28,19 @@
#include "server/ComUtils.h"
#endif
+#ifdef MULTI_LANG_SUPPORT
#include "SettingsDialog.h"
+#endif
+
+#include "GlobalSettingStation.h"
#include "gpg/function/GpgKeyGetter.h"
#include "rapidjson/prettywriter.h"
#include "ui/widgets/KeyList.h"
namespace GpgFrontend::UI {
-GeneralTab::GeneralTab(QWidget* parent)
- : QWidget(parent),
- appPath(qApp->applicationDirPath()),
- settings(RESOURCE_DIR(appPath) + "/conf/gpgfrontend.ini",
- QSettings::IniFormat) {
+GeneralTab::GeneralTab(QWidget* parent) : QWidget(parent) {
#ifdef SERVER_SUPPORT
-
/*****************************************
* GpgFrontend Server
*****************************************/
@@ -77,7 +76,7 @@ GeneralTab::GeneralTab(QWidget* parent)
importConfirmationBoxLayout->addWidget(importConfirmationCheckBox);
importConfirmationBox->setLayout(importConfirmationBoxLayout);
-#ifdef MULT_LANGUAGE_SUPPORT
+#ifdef MULTI_LANG_SUPPORT
/*****************************************
* Language Select Box
*****************************************/
@@ -141,7 +140,6 @@ GeneralTab::GeneralTab(QWidget* parent)
ownKeyServiceTokenLayout->addWidget(getServiceTokenButton);
ownKeyServiceTokenLayout->addWidget(serviceTokenLabel);
ownKeyServiceTokenLayout->stretch(0);
-
#endif
/*****************************************
@@ -153,7 +151,7 @@ GeneralTab::GeneralTab(QWidget* parent)
#endif
mainLayout->addWidget(saveCheckedKeysBox);
mainLayout->addWidget(importConfirmationBox);
-#ifdef MULT_LANGUAGE_SUPPORT
+#ifdef MULTI_LANG_SUPPORT
mainLayout->addWidget(langBox);
#endif
#ifdef SERVER_SUPPORT
@@ -171,9 +169,12 @@ GeneralTab::GeneralTab(QWidget* parent)
* appropriately
**********************************/
void GeneralTab::setSettings() {
- // Keysaving
- if (settings.value("keys/saveKeyChecked").toBool()) {
- saveCheckedKeysCheckBox->setCheckState(Qt::Checked);
+ auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
+ try {
+ bool save_key_checked = settings.lookup("general.save_key_checked");
+ if (save_key_checked) saveCheckedKeysCheckBox->setCheckState(Qt::Checked);
+ } catch (...) {
+ LOG(ERROR) << _("Setting Operation Error") << _("save_key_checked");
}
#ifdef SERVER_SUPPORT
@@ -199,19 +200,19 @@ void GeneralTab::setSettings() {
});
#endif
-#ifdef MULT_LANGUAGE_SUPPORT
-
- // Language setting
- QString langKey = settings.value("int/lang").toString();
- QString langValue = lang.value(langKey);
- if (!langKey.isEmpty()) {
- langSelectBox->setCurrentIndex(langSelectBox->findText(langValue));
+#ifdef MULTI_LANG_SUPPORT
+ try {
+ std::string lang_key = settings.lookup("general.lang");
+ QString lang_value = lang.value(lang_key.c_str());
+ if (!lang.empty()) {
+ langSelectBox->setCurrentIndex(langSelectBox->findText(lang_value));
+ }
+ } catch (...) {
+ LOG(ERROR) << _("Setting Operation Error") << _("lang");
}
-
#endif
#ifdef SERVER_SUPPORT
-
auto own_key_id = settings.value("general/ownKeyId").toString().toStdString();
if (own_key_id.empty()) {
ownKeySelectBox->setCurrentText("<none>");
@@ -225,12 +226,15 @@ void GeneralTab::setSettings() {
if (!serviceToken.empty()) {
serviceTokenLabel->setText(QString::fromStdString(serviceToken));
}
-
#endif
- // Get own key information from keydb/gpg.conf (if contained)
- if (settings.value("general/confirmImportKeys", Qt::Checked).toBool()) {
- importConfirmationCheckBox->setCheckState(Qt::Checked);
+ try {
+ bool confirm_import_keys = settings.lookup("general.confirm_import_keys");
+ LOG(INFO) << "confirm_import_keys" << confirm_import_keys;
+ if (confirm_import_keys)
+ importConfirmationCheckBox->setCheckState(Qt::Checked);
+ } catch (...) {
+ LOG(ERROR) << _("Setting Operation Error") << _("confirm_import_keys");
}
}
@@ -239,8 +243,22 @@ void GeneralTab::setSettings() {
* write them to settings-file
*************************************/
void GeneralTab::applySettings() {
- settings.setValue("keys/saveKeyChecked",
- saveCheckedKeysCheckBox->isChecked());
+ auto& settings =
+ GpgFrontend::UI::GlobalSettingStation::GetInstance().GetUISettings();
+
+ if (!settings.exists("general") ||
+ settings.lookup("general").getType() != libconfig::Setting::TypeGroup)
+ settings.add("general", libconfig::Setting::TypeGroup);
+
+ auto& general = settings["general"];
+
+ if (!general.exists("save_key_checked"))
+ general.add("save_key_checked", libconfig::Setting::TypeBoolean) =
+ saveCheckedKeysCheckBox->isChecked();
+ else {
+ general["save_key_checked"] = saveCheckedKeysCheckBox->isChecked();
+ }
+
#ifdef SERVER_SUPPORT
qDebug() << "serverSelectBox currentText" << serverSelectBox->currentText();
settings.setValue("general/currentGpgfrontendServer",
@@ -253,8 +271,15 @@ void GeneralTab::applySettings() {
delete serverList;
#endif
-#ifdef MULT_LANGUAGE_SUPPORT
- settings.setValue("int/lang", lang.key(langSelectBox->currentText()));
+#ifdef MULTI_LANG_SUPPORT
+
+ if (!general.exists("lang"))
+ general.add("lang", libconfig::Setting::TypeBoolean) =
+ langSelectBox->currentText().toStdString();
+ else {
+ general["lang"] = langSelectBox->currentText().toStdString();
+ }
+
#endif
#ifdef SERVER_SUPPORT
@@ -266,11 +291,17 @@ void GeneralTab::applySettings() {
QString::fromStdString(serviceToken));
#endif
- settings.setValue("general/confirmImportKeys",
- importConfirmationCheckBox->isChecked());
+ if (!general.exists("confirm_import_keys"))
+ general.add("confirm_import_keys", libconfig::Setting::TypeBoolean) =
+ importConfirmationCheckBox->isChecked();
+ else {
+ general["confirm_import_keys"] = importConfirmationCheckBox->isChecked();
+ }
+
+ GlobalSettingStation::GetInstance().Sync();
}
-#ifdef MULT_LANGUAGE_SUPPORT
+#ifdef MULTI_LANG_SUPPORT
void GeneralTab::slotLanguageChanged() { emit signalRestartNeeded(true); }
#endif
diff --git a/src/ui/settings/SettingsGeneral.h b/src/ui/settings/SettingsGeneral.h
index 5816af9d..7e118f98 100644
--- a/src/ui/settings/SettingsGeneral.h
+++ b/src/ui/settings/SettingsGeneral.h
@@ -41,13 +41,10 @@ class GeneralTab : public QWidget {
void applySettings();
private:
- QString appPath;
- QSettings settings;
-
QCheckBox* saveCheckedKeysCheckBox;
QCheckBox* importConfirmationCheckBox;
-#ifdef MULT_LANGUAGE_SUPPORT
+#ifdef MULTI_LANG_SUPPORT
QComboBox* langSelectBox;
QHash<QString, QString> lang;
#endif
@@ -66,12 +63,17 @@ class GeneralTab : public QWidget {
KeyList* mKeyList{};
private slots:
-#ifdef MULT_LANGUAGE_SUPPORT
- void slotOwnKeyIdChanged();
+
+#ifdef MULTI_LANG_SUPPORT
+
+ void slotLanguageChanged();
+
#endif
#ifdef SERVER_SUPPORT
- void slotLanguageChanged();
+
+ void slotOwnKeyIdChanged();
+
#endif
signals:
diff --git a/src/ui/widgets/KeyList.cpp b/src/ui/widgets/KeyList.cpp
index b3391c68..f9f33d78 100644
--- a/src/ui/widgets/KeyList.cpp
+++ b/src/ui/widgets/KeyList.cpp
@@ -153,8 +153,7 @@ void KeyList::slotRefresh() {
buffered_keys.clear();
while (it != keys->end()) {
- buffered_keys.push_back(
- std::move(GpgKeyGetter::GetInstance().GetKey(it->id())));
+ buffered_keys.push_back(GpgKeyGetter::GetInstance().GetKey(it->id()));
auto* tmp0 = new QTableWidgetItem(QString::number(row_index));
tmp0->setFlags(Qt::ItemIsUserCheckable | Qt::ItemIsEnabled |
@@ -219,7 +218,7 @@ void KeyList::slotRefresh() {
++row_index;
}
- setChecked(std::move(keyList));
+ setChecked(keyList);
}
KeyIdArgsListPtr KeyList::getChecked() {
@@ -229,7 +228,7 @@ KeyIdArgsListPtr KeyList::getChecked() {
ret->push_back(buffered_keys[i].id());
}
}
- return std::move(ret);
+ return ret;
}
KeyIdArgsListPtr KeyList::getAllPrivateKeys() {
@@ -239,7 +238,7 @@ KeyIdArgsListPtr KeyList::getAllPrivateKeys() {
ret->push_back(buffered_keys[i].id());
}
}
- return std::move(ret);
+ return ret;
}
KeyIdArgsListPtr KeyList::getPrivateChecked() {
@@ -250,7 +249,7 @@ KeyIdArgsListPtr KeyList::getPrivateChecked() {
ret->push_back(buffered_keys[i].id());
}
}
- return std::move(ret);
+ return ret;
}
void KeyList::setChecked(const KeyIdArgsListPtr& keyIds) {
@@ -272,7 +271,7 @@ KeyIdArgsListPtr KeyList::getSelected() {
ret->push_back(buffered_keys[i].id());
}
}
- return std::move(ret);
+ return ret;
}
[[maybe_unused]] bool KeyList::containsPrivateKeys() {