Commit 9ebc447e authored by Rolf Eike Beer's avatar Rolf Eike Beer Committed by Rolf Eike Beer

several code cleanups

parent b87aefca
......@@ -239,20 +239,21 @@ KGpgFirstAssistant::KGpgFirstAssistant(QWidget *parent)
}
void
KGpgFirstAssistant::findConfigPath()
KGpgFirstAssistant::findConfigPath(const QString &gpgBinary)
{
const QString gpgHome = GPGProc::getGpgHome(binURL->url().path());
const QString gpgHome = GPGProc::getGpgHome(gpgBinary);
QString confPath = gpgHome + QLatin1String( "gpg.conf" );
if (!QFile(confPath).exists()) {
confPath = gpgHome + QLatin1String( "options" );
if (!QFile(confPath).exists()) {
const QString confPathOpt = gpgHome + QLatin1String("options");
if (QFile(confPathOpt).exists()) {
confPath = confPathOpt;
} else {
if (KMessageBox::questionYesNo(0, i18n("<qt><b>The GnuPG configuration file was not found</b>. Should KGpg try to create a config file ?</qt>"), QString(), KGuiItem(i18n("Create Config")), KGuiItem(i18n("Do Not Create"))) == KMessageBox::Yes) {
confPath = gpgHome + QLatin1String( "gpg.conf" );
QFile file(confPath);
if (file.open(QIODevice::WriteOnly)) {
QTextStream stream(&file);
stream << "# GnuPG config file created by KGpg" << "\n";
stream << "# GnuPG config file created by KGpg\n";
file.close();
}
} else {
......@@ -264,19 +265,19 @@ KGpgFirstAssistant::findConfigPath()
pathURL->setUrl(QUrl::fromLocalFile(confPath));
QStringList secids = KgpgInterface::readSecretKeys();
if (secids.isEmpty()) {
setAppropriate(page_defaultkey, false);
generateCB->setChecked(true);
const QStringList secids = KgpgInterface::readSecretKeys();
bool noSecKeys = secids.isEmpty();
generateCB->setChecked(noSecKeys);
setAppropriate(page_defaultkey, !noSecKeys);
if (noSecKeys) {
defaultkeylabel->setVisible(false);
return;
}
const KgpgKeyList publiclist = KgpgInterface::readPublicKeys(secids);
generateCB->setChecked(false);
setAppropriate(page_defaultkey, true);
CBdefault->clear();
for (const KgpgKey &k : publiclist) {
......@@ -297,8 +298,9 @@ void
KGpgFirstAssistant::next()
{
if (currentPage() == page_binary) {
binlabel->setText(i18n("Your GnuPG binary is: %1", binURL->url().path()));
findConfigPath();
const QString &gpgbin = binURL->url().path();
binlabel->setText(i18n("Your GnuPG binary is: %1", gpgbin));
findConfigPath(gpgbin);
} else if (currentPage() == page_config) {
QString tst, name;
m_confPath = pathURL->url().path();
......
......@@ -55,7 +55,7 @@ private:
QString m_gpgVersion;
QString m_confPath;
void findConfigPath();
void findConfigPath(const QString &gpgBinary);
public:
/**
......
......@@ -413,7 +413,5 @@ KgpgKeyList KgpgInterface::readSecretKeys(const QStringList &ids)
process.start();
process.waitForFinished(-1);
KgpgCore::KgpgKeyList result = readSecretKeysProcess(process);
return result;
return readSecretKeysProcess(process);
}
......@@ -23,7 +23,6 @@ KLineBufferedProcess::KLineBufferedProcess(QObject *parent)
KLineBufferedProcess::~KLineBufferedProcess()
{
delete d;
}
bool KLineBufferedProcess::readLineStandardOutput(QByteArray *line)
......
......@@ -15,7 +15,8 @@
#include "klinebufferedprocess.h"
KLineBufferedProcessPrivate::KLineBufferedProcessPrivate(KLineBufferedProcess *parent)
: m_newlineInStdout(-1),
: QObject(parent),
m_newlineInStdout(-1),
m_newlineInStderr(-1),
m_parent(parent),
#ifdef Q_OS_WIN //krazy:exclude=cpp
......
......@@ -19,8 +19,7 @@
#include "core/kgpgkey.h"
#include <QObject>
class QString;
#include <QString>
/**
* @brief generate a new key pair
......
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