summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndre Heinecke <aheinecke@intevation.de>2016-05-12 11:02:52 (GMT)
committerAndre Heinecke <aheinecke@intevation.de>2016-08-02 09:57:15 (GMT)
commite001135eab16bdd2f5393a795d869a50e37d9933 (patch)
tree669fe0037f2ef8951098f496ec957362d664d0a7
parent7e19bcc30084028fd2d344b6299ed09899dcbc12 (diff)
Add Icon for UID helper to formatting
This should return a general Icon to show for a specific UID to indicate its validity status.
-rw-r--r--src/utils/formatting.cpp20
-rw-r--r--src/utils/formatting.h3
2 files changed, 23 insertions, 0 deletions
diff --git a/src/utils/formatting.cpp b/src/utils/formatting.cpp
index 6833750..faa5142 100644
--- a/src/utils/formatting.cpp
+++ b/src/utils/formatting.cpp
@@ -50,6 +50,7 @@
#include <QDateTime>
#include <QTextDocument> // for Qt::escape
#include <QLocale>
+#include <QIcon>
using namespace GpgME;
using namespace Kleo;
@@ -757,3 +758,22 @@ QString Formatting::summaryLine(const Key &key)
{
return keyToString(key) + QStringLiteral(" (%1 - %2)").arg(key.shortKeyID()).arg(displayName(key.protocol()));
}
+
+// Icon for certificate selection indication
+QIcon Formatting::iconForUid(const UserID &uid)
+{
+ switch (uid.validity()) {
+ case UserID::Ultimate:
+ return QIcon::fromTheme(QStringLiteral("emblem-favorite"));
+ case UserID::Full:
+ return QIcon::fromTheme(QStringLiteral("emblem-success"));
+ case UserID::Marginal:
+ return QIcon::fromTheme(QStringLiteral("emblem-information"));
+ case UserID::Never:
+ return QIcon::fromTheme(QStringLiteral("emblem-error"));
+ case UserID::Undefined:
+ case UserID::Unknown:
+ default:
+ return QIcon::fromTheme(QStringLiteral("emblem-warning"));
+ }
+}
diff --git a/src/utils/formatting.h b/src/utils/formatting.h
index cc1ba23..c345069 100644
--- a/src/utils/formatting.h
+++ b/src/utils/formatting.h
@@ -38,6 +38,7 @@
class QString;
class QStringList;
class QDate;
+class QIcon;
namespace GpgME
{
@@ -125,6 +126,8 @@ QString importMetaData(const GpgME::Import &import, const QStringList &sources);
QString formatOverview(const GpgME::Key &key);
QString usageString(const GpgME::Subkey &subkey);
QString summaryLine(const GpgME::Key &key);
+
+QIcon iconForUid(const GpgME::UserID &uid);
}
}