Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Improve "Status" display of userid signatures

Just printing the decimal number of the class is
way too technical. Now we have an icon and a simple word
and only show the class in the tooltip.

BUG: 355086
parent 1d1ea2f7
......@@ -39,6 +39,7 @@
#include <KLocalizedString>
#include <QVariant>
#include <QIcon>
using namespace GpgME;
using namespace Kleo;
......@@ -121,6 +122,22 @@ public:
return mItemData.value(column);
}
QVariant toolTip(int column) const
{
if (column == 5 /*Status*/) {
return i18n("class %1", mSig.certClass());
}
return mItemData.value(column);
}
QVariant icon(int column) const
{
if (!mSig.isNull() && column == 5 /*Status*/) {
return Formatting::validityIcon(mSig);
}
return QVariant();
}
int row() const
{
if (mParentItem) {
......@@ -270,12 +287,21 @@ QVariant UserIDListModel::data(const QModelIndex &index, int role) const
return QVariant();
}
if (role != Qt::DisplayRole && role != Qt::EditRole && role != Qt::ToolTipRole) {
if (role != Qt::DisplayRole && role != Qt::EditRole && role != Qt::ToolTipRole &&
role != Qt::DecorationRole) {
return QVariant();
}
UIDModelItem *item = static_cast<UIDModelItem*>(index.internalPointer());
if (role == Qt::ToolTipRole) {
return item->toolTip(index.column());
}
if (role == Qt::DecorationRole) {
return item->icon(index.column());
}
return item->data(index.column());
}
......
......@@ -49,6 +49,7 @@
#include <QTextDocument> // for Qt::escape
#include <QLocale>
#include <QIcon>
#include <QColor>
#include <gpgme++/gpgmepp_version.h>
#if GPGMEPP_VERSION > 0x10900
......@@ -587,10 +588,17 @@ QString Formatting::validityShort(const UserID::Signature &sig)
switch (sig.status()) {
case UserID::Signature::NoError:
if (!sig.isInvalid()) {
if (sig.certClass() > 0) {
/* See RFC 4880 Section 5.2.1 */
switch (sig.certClass()) {
case 0x10: /* Generic */
case 0x11: /* Persona */
case 0x12: /* Casual */
case 0x13: /* Positive */
return i18n("valid");
case 0x30:
return i18n("revoked");
default:
return i18n("class %1", sig.certClass());
} else {
return i18nc("good/valid signature", "good");
}
}
Q_FALLTHROUGH();
......@@ -600,11 +608,45 @@ QString Formatting::validityShort(const UserID::Signature &sig)
case UserID::Signature::SigExpired: return i18n("expired");
case UserID::Signature::KeyExpired: return i18n("certificate expired");
case UserID::Signature::BadSignature: return i18nc("fake/invalid signature", "bad");
case UserID::Signature::NoPublicKey: return QString();
case UserID::Signature::NoPublicKey: return i18n("no public key");
}
return QString();
}
QIcon Formatting::validityIcon(const UserID::Signature &sig)
{
switch (sig.status()) {
case UserID::Signature::NoError:
if (!sig.isInvalid()) {
/* See RFC 4880 Section 5.2.1 */
switch (sig.certClass()) {
case 0x10: /* Generic */
case 0x11: /* Persona */
case 0x12: /* Casual */
case 0x13: /* Positive */
return QIcon::fromTheme(QStringLiteral("emblem-success"));
case 0x30:
return QIcon::fromTheme(QStringLiteral("emblem-error"));
default:
return QIcon();
}
}
Q_FALLTHROUGH();
// fall through:
case UserID::Signature::BadSignature:
case UserID::Signature::GeneralError:
return QIcon::fromTheme(QStringLiteral("emblem-error"));
case UserID::Signature::SigExpired:
case UserID::Signature::KeyExpired:
return QIcon::fromTheme(QStringLiteral("emblem-information"));
case UserID::Signature::NoPublicKey:
return QIcon::fromTheme(QStringLiteral("emblem-question"));
default:
// should not happen
return QIcon();
}
}
QString Formatting::formatKeyLink(const Key &key)
{
if (key.isNull()) {
......
......@@ -113,6 +113,7 @@ KLEO_EXPORT QString ownerTrustShort(GpgME::Key::OwnerTrust trust);
KLEO_EXPORT QString validityShort(const GpgME::Subkey &subkey);
KLEO_EXPORT QString validityShort(const GpgME::UserID &uid);
KLEO_EXPORT QString validityShort(const GpgME::UserID::Signature &sig);
KLEO_EXPORT QIcon validityIcon(const GpgME::UserID::Signature &sig);
/* A sentence about the validity of the UserID */
KLEO_EXPORT QString validity(const GpgME::UserID &uid);
......
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