Commit 329e727d authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Format key ID and provide improved representation for screen readers

GnuPG-bug-id: 6103
parent ecd8293d
......@@ -407,6 +407,10 @@ void KeyListViewItem::setKey(const GpgME::Key &key)
const int numCols = lv ? lv->columnCount() : 0;
for (int i = 0; i < numCols; ++i) {
setText(i, cs->text(key, i));
const auto accessibleText = cs->accessibleText(key, i);
if (!accessibleText.isEmpty()) {
setData(i, Qt::AccessibleTextRole, accessibleText);
}
setToolTip(i, cs->toolTip(key, i));
const QIcon icon = cs->icon(key, i);
if (!icon.isNull()) {
......
......@@ -95,6 +95,7 @@ public:
}
virtual QString text(const GpgME::Key &key, int column) const = 0;
virtual QString accessibleText(const GpgME::Key &key, int column) const = 0;
virtual QString toolTip(const GpgME::Key &key, int column) const;
virtual QIcon icon(const GpgME::Key &, int) const
{
......
......@@ -19,6 +19,7 @@
#include "progressdialog.h"
#include <libkleo/dn.h>
#include <libkleo/formatting.h>
#include <kleo_ui_debug.h>
......@@ -164,6 +165,7 @@ public:
int width(int col, const QFontMetrics &fm) const override;
QString text(const GpgME::Key &key, int col) const override;
QString accessibleText(const GpgME::Key &key, int column) const override;
QString toolTip(const GpgME::Key &key, int col) const override;
QIcon icon(const GpgME::Key &key, int col) const override;
......@@ -220,7 +222,7 @@ QString ColumnStrategy::text(const GpgME::Key &key, int col) const
switch (col) {
case 0: {
if (key.shortKeyID()) {
return QString::fromUtf8(key.shortKeyID());
return Formatting::prettyID(key.shortKeyID());
} else {
return xi18n("<placeholder>unknown</placeholder>");
}
......@@ -238,6 +240,19 @@ QString ColumnStrategy::text(const GpgME::Key &key, int col) const
}
}
QString ColumnStrategy::accessibleText(const GpgME::Key &key, int col) const
{
switch (col) {
case 0: {
if (key.shortKeyID()) {
return Formatting::accessibleHexID(key.shortKeyID());
}
}
default:
return {};
}
}
QString ColumnStrategy::toolTip(const GpgME::Key &key, int) const
{
const char *uid = key.userID(0).id();
......
......@@ -41,6 +41,7 @@ public:
QString title(int col) const override;
QString toolTip(const GpgME::Key &key, int col) const override;
QString text(const GpgME::Key &key, int col) const override;
QString accessibleText(const GpgME::Key &key, int col) const override;
};
QString TestColumnStrategy::title(int col) const
......@@ -90,6 +91,11 @@ QString TestColumnStrategy::text(const GpgME::Key &key, int col) const
return QString();
}
}
QString TestColumnStrategy::accessibleText(const GpgME::Key &, int) const
{
return {};
}
}
CertListView::CertListView(QWidget *parent, Qt::WindowFlags f)
......
Supports Markdown
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