Fix plural handling in KDF settings

This commit is contained in:
Janek Bevendorff 2018-02-04 13:45:41 +01:00
parent 527868a6b3
commit 7cc3d911ba
No known key found for this signature in database
GPG Key ID: 2FDEB0D40BCA5E11
3 changed files with 24 additions and 10 deletions

View File

@ -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));
}

View File

@ -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();

View File

@ -139,18 +139,12 @@
<height>16777215</height>
</size>
</property>
<property name="suffix">
<string> MB</string>
</property>
<property name="minimum">
<number>1</number>
</property>
<property name="maximum">
<number>1048576</number>
</property>
<property name="value">
<number>64</number>
</property>
</widget>
</item>
<item row="4" column="0">
@ -174,9 +168,6 @@
<height>16777215</height>
</size>
</property>
<property name="suffix">
<string> thread</string>
</property>
<property name="minimum">
<number>1</number>
</property>