Unverified Commit abe521db authored by Andrey Legayev's avatar Andrey Legayev
Browse files

Fix gpg configuration dialog tabs order

Fixes T6446

Differential Revision: https://phabricator.kde.org/D28761
parent 5bd6bae9
...@@ -65,6 +65,7 @@ ...@@ -65,6 +65,7 @@
#include <memory> #include <memory>
#include <limits> #include <limits>
#include <array>
using namespace Kleo; using namespace Kleo;
...@@ -161,7 +162,7 @@ void Kleo::CryptoConfigModule::init(Layout layout) ...@@ -161,7 +162,7 @@ void Kleo::CryptoConfigModule::init(Layout layout)
addPage(w, configOK ? QString() : i18n("GpgConf Error")); addPage(w, configOK ? QString() : i18n("GpgConf Error"));
} }
const QStringList components = config->componentList(); const QStringList components = sortComponentList(config->componentList());
for (QStringList::const_iterator it = components.begin(); it != components.end(); ++it) { for (QStringList::const_iterator it = components.begin(); it != components.end(); ++it) {
//qCDebug(KLEO_UI_LOG) <<"Component" << (*it).toLocal8Bit() <<":"; //qCDebug(KLEO_UI_LOG) <<"Component" << (*it).toLocal8Bit() <<":";
QGpgME::CryptoConfigComponent *comp = config->component(*it); QGpgME::CryptoConfigComponent *comp = config->component(*it);
...@@ -227,6 +228,36 @@ void Kleo::CryptoConfigModule::init(Layout layout) ...@@ -227,6 +228,36 @@ void Kleo::CryptoConfigModule::init(Layout layout)
} }
} }
QStringList Kleo::CryptoConfigModule::sortComponentList(const QStringList &components)
{
// components sorting algorithm:
// 1. components with hardcoded order - see below
// 2. other components sorted alphabetically
static const std::array<QString, 6> order = {
QStringLiteral("gpg"),
QStringLiteral("gpgsm"),
QStringLiteral("gpg-agent"),
QStringLiteral("dirmngr"),
QStringLiteral("pinentry"),
QStringLiteral("scdaemon")
};
QStringList result, others;
for (const auto &item : order) {
if (components.contains(item)) {
result.append(item);
}
}
for (const auto &item : components) {
if (!result.contains(item)) {
others.append(item);
}
}
others.sort();
result.append(others);
return result;
}
bool Kleo::CryptoConfigModule::hasError() const bool Kleo::CryptoConfigModule::hasError() const
{ {
return mComponentGUIs.empty(); return mComponentGUIs.empty();
......
...@@ -77,6 +77,7 @@ Q_SIGNALS: ...@@ -77,6 +77,7 @@ Q_SIGNALS:
private: private:
void init(Layout layout); void init(Layout layout);
QStringList sortComponentList(const QStringList &components);
private: private:
QGpgME::CryptoConfig *mConfig = nullptr; QGpgME::CryptoConfig *mConfig = nullptr;
......
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