Commit 4c026aea authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Use KConfigXT for getting/setting the default checksum definition

GnuPG-bug-id: 5791
parent 9b0d60eb
......@@ -17,6 +17,7 @@
#include "emailoperationspreferences.h"
#include "fileoperationspreferences.h"
#include "settings.h"
#include <Libkleo/ChecksumDefinition>
#include <Libkleo/KeyFilterManager>
......@@ -313,8 +314,6 @@ void CryptoOperationsConfigWidget::defaults()
}
}
Q_DECLARE_METATYPE(std::shared_ptr<Kleo::ChecksumDefinition>)
void CryptoOperationsConfigWidget::load()
{
......@@ -329,15 +328,16 @@ void CryptoOperationsConfigWidget::load()
mTmpDirCB->setChecked(filePrefs.dontUseTmpDir());
mSymmetricOnlyCB->setChecked(filePrefs.symmetricEncryptionOnly());
const std::vector< std::shared_ptr<ChecksumDefinition> > cds = ChecksumDefinition::getChecksumDefinitions();
const std::shared_ptr<ChecksumDefinition> default_cd = ChecksumDefinition::getDefaultChecksumDefinition(cds);
const Settings settings;
const auto cds = ChecksumDefinition::getChecksumDefinitions();
const auto defaultChecksumDefinitionId = settings.checksumDefinitionId();
mChecksumDefinitionCB->clear();
mArchiveDefinitionCB->clear();
for (const std::shared_ptr<ChecksumDefinition> &cd : cds) {
mChecksumDefinitionCB->addItem(cd->label(), QVariant::fromValue(cd));
if (cd == default_cd) {
mChecksumDefinitionCB->addItem(cd->label(), QVariant{cd->id()});
if (cd->id() == defaultChecksumDefinitionId) {
mChecksumDefinitionCB->setCurrentIndex(mChecksumDefinitionCB->count() - 1);
}
}
......@@ -377,11 +377,13 @@ void CryptoOperationsConfigWidget::save()
filePrefs.setDontUseTmpDir(mTmpDirCB->isChecked());
filePrefs.setSymmetricEncryptionOnly(mSymmetricOnlyCB->isChecked());
Settings settings;
const int idx = mChecksumDefinitionCB->currentIndex();
if (idx >= 0) {
const auto cd = qvariant_cast< std::shared_ptr<ChecksumDefinition> >(mChecksumDefinitionCB->itemData(idx));
ChecksumDefinition::setDefaultChecksumDefinition(cd);
const auto id = mChecksumDefinitionCB->itemData(idx).toString();
settings.setChecksumDefinitionId(id);
}
settings.save();
const int aidx = mArchiveDefinitionCB->currentIndex();
if (aidx >= 0) {
......
......@@ -50,6 +50,12 @@
<default>false</default>
</entry>
</group>
<group name="ChecksumOperations">
<entry key="checksum-definition-id" name="ChecksumDefinitionId" type="String">
<label>Checksum program to use when creating checksum files</label>
<default>sha256sum</default>
</entry>
</group>
<group name="CMS">
<entry key="Enabled" name="cmsEnabled" type="Bool">
<label>Enable S/MIME</label>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment