From 7cc3d911ba43f540a12e016efc25caec31c2bb78 Mon Sep 17 00:00:00 2001 From: Janek Bevendorff Date: Sun, 4 Feb 2018 13:45:41 +0100 Subject: [PATCH] Fix plural handling in KDF settings --- src/gui/DatabaseSettingsWidget.cpp | 23 ++++++++++++++++++++- src/gui/DatabaseSettingsWidget.h | 2 ++ src/gui/DatabaseSettingsWidgetEncryption.ui | 9 -------- 3 files changed, 24 insertions(+), 10 deletions(-) diff --git a/src/gui/DatabaseSettingsWidget.cpp b/src/gui/DatabaseSettingsWidget.cpp index baea2558a..cad04b297 100644 --- a/src/gui/DatabaseSettingsWidget.cpp +++ b/src/gui/DatabaseSettingsWidget.cpp @@ -57,6 +57,9 @@ DatabaseSettingsWidget::DatabaseSettingsWidget(QWidget* parent) connect(m_uiEncryption->transformBenchmarkButton, SIGNAL(clicked()), SLOT(transformRoundsBenchmark())); connect(m_uiEncryption->kdfComboBox, SIGNAL(currentIndexChanged(int)), SLOT(kdfChanged(int))); + connect(m_uiEncryption->memorySpinBox, SIGNAL(valueChanged(int)), this, SLOT(memoryChanged(int))); + connect(m_uiEncryption->parallelismSpinBox, SIGNAL(valueChanged(int)), this, SLOT(parallelismChanged(int))); + m_ui->categoryList->addCategory(tr("General"), FilePath::instance()->icon("categories", "preferences-other")); m_ui->categoryList->addCategory(tr("Encryption"), FilePath::instance()->icon("actions", "document-encrypt")); m_ui->stackedWidget->addWidget(m_uiGeneralPage); @@ -121,7 +124,7 @@ void DatabaseSettingsWidget::load(Database* db) kdfChanged(kdfIndex); } - // properly initialize parallelism spin box (may be overwritten by actual KDF values) + m_uiEncryption->memorySpinBox->setValue(64); m_uiEncryption->parallelismSpinBox->setValue(QThread::idealThreadCount()); // Setup kdf parameters @@ -289,3 +292,21 @@ void DatabaseSettingsWidget::kdfChanged(int index) transformRoundsBenchmark(); } + +/** + * Update memory spin box suffix on value change. + */ +void DatabaseSettingsWidget::memoryChanged(int value) +{ + m_uiEncryption->memorySpinBox->setSuffix( + tr(" MiB", "Abbreviation for Mebibytes (KDF settings)", value)); +} + +/** + * Update parallelism spin box suffix on value change. + */ +void DatabaseSettingsWidget::parallelismChanged(int value) +{ + m_uiEncryption->parallelismSpinBox->setSuffix( + tr(" thread(s)", "Threads for parallel execution (KDF settings)", value)); +} diff --git a/src/gui/DatabaseSettingsWidget.h b/src/gui/DatabaseSettingsWidget.h index 8410af37e..b0cae5dbc 100644 --- a/src/gui/DatabaseSettingsWidget.h +++ b/src/gui/DatabaseSettingsWidget.h @@ -54,6 +54,8 @@ private slots: void reject(); void transformRoundsBenchmark(); void kdfChanged(int index); + void memoryChanged(int value); + void parallelismChanged(int value); private: void truncateHistories(); diff --git a/src/gui/DatabaseSettingsWidgetEncryption.ui b/src/gui/DatabaseSettingsWidgetEncryption.ui index 4c4d2aed2..502bc012c 100644 --- a/src/gui/DatabaseSettingsWidgetEncryption.ui +++ b/src/gui/DatabaseSettingsWidgetEncryption.ui @@ -139,18 +139,12 @@ 16777215 - - MB - 1 1048576 - - 64 - @@ -174,9 +168,6 @@ 16777215 - - thread - 1