Commit 2d281d8e authored by Ingo Klöcker's avatar Ingo Klöcker
Browse files

Add helpers for accessible creation date and expiration date of subkeys

GnuPG-bug-id: 6104
parent 1be06ea6
......@@ -611,10 +611,15 @@ QDate Formatting::expirationDate(const UserID::Signature &sig)
QString Formatting::accessibleExpirationDate(const Key &key, const QString &noExpiration)
{
if (key.subkey(0).neverExpires()) {
return accessibleExpirationDate(key.subkey(0), noExpiration);
}
QString Formatting::accessibleExpirationDate(const Subkey &subkey, const QString &noExpiration)
{
if (subkey.neverExpires()) {
return noExpiration.isEmpty() ? i18n("no expiration") : noExpiration;
} else {
return accessibleDate(expirationDate(key));
return accessibleDate(expirationDate(subkey));
}
}
......@@ -653,6 +658,11 @@ QString Formatting::accessibleCreationDate(const Key &key)
return accessibleDate(creationDate(key));
}
QString Formatting::accessibleCreationDate(const Subkey &subkey)
{
return accessibleDate(creationDate(subkey));
}
//
// Types
//
......
......@@ -93,6 +93,12 @@ KLEO_EXPORT QDate expirationDate(const GpgME::UserID::Signature &sig);
* returns the localization of "no expiration".
*/
KLEO_EXPORT QString accessibleExpirationDate(const GpgME::Key &key, const QString &noExpiration = {});
/**
* Returns expiration date of @p subkey as string suitable for screen readers.
* If the subkey doesn't expire, then it returns @p noExpiration if @p noExpiration is not empty. Otherwise,
* returns the localization of "no expiration".
*/
KLEO_EXPORT QString accessibleExpirationDate(const GpgME::Subkey &subkey, const QString &noExpiration = {});
KLEO_EXPORT QString creationDateString(const GpgME::Key &key);
KLEO_EXPORT QString creationDateString(const GpgME::Subkey &subkey);
......@@ -101,6 +107,7 @@ KLEO_EXPORT QDate creationDate(const GpgME::Key &key);
KLEO_EXPORT QDate creationDate(const GpgME::Subkey &subkey);
KLEO_EXPORT QDate creationDate(const GpgME::UserID::Signature &sig);
KLEO_EXPORT QString accessibleCreationDate(const GpgME::Key &key);
KLEO_EXPORT QString accessibleCreationDate(const GpgME::Subkey &subkey);
/* Convert a GPGME style time or a QDate to a localized string */
KLEO_EXPORT QString dateString(time_t t);
......
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