summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRolf Eike Beer <[email protected]>2017-06-28 12:57:06 +0200
committerRolf Eike Beer <[email protected]>2017-06-28 18:53:45 +0200
commit9ebc447e02da80df7fbfde19a2e52d47f43da6c9 (patch)
treedd4a21bc81aa5238c0bc62cad9eef043abd14c7e
parentb87aefca733a27f687e1196e78fe7713d91ee271 (diff)
several code cleanups
-rw-r--r--kgpgfirstassistant.cpp32
-rw-r--r--kgpgfirstassistant.h2
-rw-r--r--kgpginterface.cpp4
-rw-r--r--klinebufferedprocess.cpp1
-rw-r--r--klinebufferedprocessprivate.cpp3
-rw-r--r--transactions/kgpggeneratekey.h3
6 files changed, 22 insertions, 23 deletions
diff --git a/kgpgfirstassistant.cpp b/kgpgfirstassistant.cpp
index 06468e2..d201822 100644
--- a/kgpgfirstassistant.cpp
+++ b/kgpgfirstassistant.cpp
@@ -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();
diff --git a/kgpgfirstassistant.h b/kgpgfirstassistant.h
index c3f980d..41be127 100644
--- a/kgpgfirstassistant.h
+++ b/kgpgfirstassistant.h
@@ -55,7 +55,7 @@ private:
QString m_gpgVersion;
QString m_confPath;
- void findConfigPath();
+ void findConfigPath(const QString &gpgBinary);
public:
/**
diff --git a/kgpginterface.cpp b/kgpginterface.cpp
index 7c760c0..2b67ea6 100644
--- a/kgpginterface.cpp
+++ b/kgpginterface.cpp
@@ -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);
}
diff --git a/klinebufferedprocess.cpp b/klinebufferedprocess.cpp
index 159cbc4..3f10afa 100644
--- a/klinebufferedprocess.cpp
+++ b/klinebufferedprocess.cpp
@@ -23,7 +23,6 @@ KLineBufferedProcess::KLineBufferedProcess(QObject *parent)
KLineBufferedProcess::~KLineBufferedProcess()
{
- delete d;
}
bool KLineBufferedProcess::readLineStandardOutput(QByteArray *line)
diff --git a/klinebufferedprocessprivate.cpp b/klinebufferedprocessprivate.cpp
index e262f05..5c8e1e4 100644
--- a/klinebufferedprocessprivate.cpp
+++ b/klinebufferedprocessprivate.cpp
@@ -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
diff --git a/transactions/kgpggeneratekey.h b/transactions/kgpggeneratekey.h
index 8768688..60a0dba 100644
--- a/transactions/kgpggeneratekey.h
+++ b/transactions/kgpggeneratekey.h
@@ -19,8 +19,7 @@
#include "core/kgpgkey.h"
#include <QObject>
-
-class QString;
+#include <QString>
/**
* @brief generate a new key pair