aboutsummaryrefslogtreecommitdiffstats
path: root/src/ui/widgets/KeyList.cpp
diff options
context:
space:
mode:
authorSaturneric <[email protected]>2023-04-05 05:16:26 +0000
committerSaturneric <[email protected]>2023-04-05 05:16:26 +0000
commit25dc98b395cbd4e60c468d82de7e2c7579350e58 (patch)
tree029683a56ad773aa915c32c93a1bf848def4a7a2 /src/ui/widgets/KeyList.cpp
parentfix: remove 'cached' in codeql ci (diff)
downloadGpgFrontend-25dc98b395cbd4e60c468d82de7e2c7579350e58.tar.gz
GpgFrontend-25dc98b395cbd4e60c468d82de7e2c7579350e58.zip
feat: simplify settings lookup
Diffstat (limited to 'src/ui/widgets/KeyList.cpp')
-rw-r--r--src/ui/widgets/KeyList.cpp25
1 files changed, 15 insertions, 10 deletions
diff --git a/src/ui/widgets/KeyList.cpp b/src/ui/widgets/KeyList.cpp
index e426ed48..2d4c925a 100644
--- a/src/ui/widgets/KeyList.cpp
+++ b/src/ui/widgets/KeyList.cpp
@@ -60,6 +60,13 @@ void KeyList::init() {
ui_->keyGroupTab->clear();
popup_menu_ = new QMenu(this);
+ bool forbid_all_gnupg_connection =
+ GlobalSettingStation::GetInstance().LookupSettings(
+ "network.forbid_all_gnupg_connection", false);
+
+ // forbidden networks connections
+ if (forbid_all_gnupg_connection) ui_->syncButton->setDisabled(true);
+
// register key database refresh signal
connect(this, &KeyList::SignalRefreshDatabase, SignalStation::GetInstance(),
&SignalStation::SignalKeyDatabaseRefresh);
@@ -313,15 +320,9 @@ void KeyList::dropEvent(QDropEvent* event) {
// "always import keys"-CheckBox
auto* checkBox = new QCheckBox(_("Always import without bothering."));
- auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
- bool confirm_import_keys = true;
- try {
- confirm_import_keys = settings.lookup("general.confirm_import_keys");
- SPDLOG_DEBUG("confirm_import_keys: {}", confirm_import_keys);
- if (confirm_import_keys) checkBox->setCheckState(Qt::Checked);
- } catch (...) {
- SPDLOG_ERROR("setting operation error: confirm_import_keys");
- }
+ bool confirm_import_keys = GlobalSettingStation::GetInstance().LookupSettings(
+ "general.confirm_import_keys", true);
+ if (confirm_import_keys) checkBox->setCheckState(Qt::Checked);
// Buttons for ok and cancel
auto* buttonBox =
@@ -340,6 +341,8 @@ void KeyList::dropEvent(QDropEvent* event) {
dialog->exec();
if (dialog->result() == QDialog::Rejected) return;
+ auto& settings = GlobalSettingStation::GetInstance().GetUISettings();
+
if (!settings.exists("general") ||
settings.lookup("general").getType() != libconfig::Setting::TypeGroup)
settings.add("general", libconfig::Setting::TypeGroup);
@@ -378,7 +381,9 @@ void KeyList::dragEnterEvent(QDragEnterEvent* event) {
*
*/
[[maybe_unused]] void KeyList::MarkKeys(QStringList* keyIds) {
- foreach (QString id, *keyIds) { spdlog::debug("marked: ", id.toStdString()); }
+ foreach (QString id, *keyIds) {
+ spdlog::debug("marked: ", id.toStdString());
+ }
}
void KeyList::import_keys(const QByteArray& inBuffer) {