Move default keyjob from NewKey to the keyjob class

another step to separate widgets from the core
This commit is contained in:
Christian Hohnstaedt 2021-05-19 17:11:10 +02:00 committed by Christian Hohnstädt
parent d319a68b61
commit 4e2a4b7d1a
5 changed files with 10 additions and 10 deletions

View File

@ -17,6 +17,7 @@
#include <openssl/pem.h>
builtin_curves builtinCurves;
keyjob keyjob::defaultjob;
pki_key::pki_key(const QString &name)
:pki_base(name)

View File

@ -94,6 +94,7 @@ class keytype
class keyjob
{
public:
static keyjob defaultjob;
keytype ktype;
int size;
int ec_nid;

View File

@ -1,8 +1,8 @@
#include "settings.h"
#include "func.h"
#include "sql.h"
#include "pki_key.h"
#include "widgets/hashBox.h"
#include "widgets/NewKey.h"
#include <QDir>
#include <QFile>
#include <openssl/asn1.h>
@ -57,7 +57,7 @@ void settings::setAction(const QString &key, const QString &value)
else if (key == "default_hash")
hashBox::setDefault(value);
else if (key == "defaultkey")
NewKey::defaultjob = keyjob(value);
keyjob::defaultjob = keyjob(value);
else if (key == "optionflags") {
XSqlQuery q;
Transaction;

View File

@ -19,8 +19,6 @@
#include <QLineEdit>
#include <QStringList>
keyjob NewKey::defaultjob;
class keyListItem
{
public:
@ -108,7 +106,7 @@ NewKey::NewKey(QWidget *parent, const QString &name)
keytypes << keyListItem(t);
updateCurves();
keyLength->setEditText(QString("%1 bit").arg(defaultjob.size));
keyLength->setEditText(QString("%1 bit").arg(keyjob::defaultjob.size));
keyDesc->setFocus();
if (pkcs11::libraries.loaded()) try {
pkcs11 p11;
@ -129,7 +127,7 @@ NewKey::NewKey(QWidget *parent, const QString &name)
q.setValue(keytypes[i]);
keyType->addItem(keytypes[i].printname, q);
if (!keytypes[i].card &&
keytypes[i].type() == defaultjob.ktype.type)
keytypes[i].type() == keyjob::defaultjob.ktype.type)
{
keyType->setCurrentIndex(i);
}
@ -175,7 +173,8 @@ void NewKey::updateCurves(unsigned min, unsigned max, unsigned long ec_flags)
curveBox->insertSeparator(curveBox->count());
addCurveBoxCurves(curve_other);
int default_index = curveBox->findData(QVariant(defaultjob.ec_nid));
int default_index = curveBox->findData(
QVariant(keyjob::defaultjob.ec_nid));
curveBox->setCurrentIndex(default_index == -1 ? 0 : default_index);
#else
(void)min; (void)max; (void)ec_flags;
@ -218,8 +217,8 @@ keyjob NewKey::getKeyJob() const
void NewKey::accept()
{
if (rememberDefault->isChecked()) {
defaultjob = getKeyJob();
Settings["defaultkey"] = defaultjob.toString();
keyjob::defaultjob = getKeyJob();
Settings["defaultkey"] = keyjob::defaultjob.toString();
}
QDialog::accept();
}

View File

@ -22,7 +22,6 @@ class NewKey: public QDialog, public Ui::NewKey
unsigned long ec_flags=0);
void addCurveBoxCurves(const QList<builtin_curve> &curves);
public:
static keyjob defaultjob;
NewKey(QWidget *parent, const QString &name);
keyjob getKeyJob() const;