1
0
mirror of https://github.com/QRouland/UTPass.git synced 2025-01-24 07:36:39 +00:00

Improve gpg key infos

This commit is contained in:
Quentin Rouland 2025-01-14 12:20:55 +01:00
parent 0e5df76787
commit 200964246e
5 changed files with 126 additions and 67 deletions

View File

@ -58,7 +58,7 @@ bool Pass::importGPGKey(QUrl url)
QVariant Pass::getAllGPGKeys() QVariant Pass::getAllGPGKeys()
{ {
qInfo() << "Getting all key form gpg "; qInfo() << "Getting all key form gpg ";
return QVariant::fromValue(PassKeyModel::keysToPassKeyQObjectList( return QVariant::fromValue(PassKeyModel::keysToPassKey(
Gpg::instance()->getAllKeys().second)); Gpg::instance()->getAllKeys().second)); // TODO Error handling
} }

View File

@ -6,69 +6,84 @@
using namespace GpgME; using namespace GpgME;
class UserIdModel : public QObject
{
Q_OBJECT
Q_PROPERTY(QString uid READ uid MEMBER m_uid CONSTANT)
Q_PROPERTY(QString name READ name MEMBER m_name CONSTANT)
Q_PROPERTY(QString email READ email MEMBER m_email CONSTANT)
UserID m_user_id;
public:
UserIdModel(UserID key):
m_user_id(key)
{};
QString uid() const
{
return QString::fromUtf8(m_user_id.id());
};
QString name() const
{
return QString::fromUtf8(m_user_id.name());
};
QString email() const
{
return QString::fromUtf8(m_user_id.email());
};
};
class PassKeyModel : public QObject class PassKeyModel : public QObject
{ {
Q_OBJECT Q_OBJECT
Q_PROPERTY(QString uid READ uid WRITE setUid NOTIFY uidChanged MEMBER m_uid) Q_PROPERTY(QString uid READ uid MEMBER m_uid CONSTANT)
Q_PROPERTY(bool secret READ secret WRITE setSecret NOTIFY secretChanged MEMBER m_secret) Q_PROPERTY(QList<QObject *> userIds READ userIds MEMBER m_user_ids CONSTANT)
Q_PROPERTY(bool expired READ expired WRITE setExpired NOTIFY expiredChanged MEMBER m_expired) Q_PROPERTY(bool isSecret READ isSecret MEMBER m_secret CONSTANT)
Q_PROPERTY(bool isExpired READ isExpired MEMBER m_expired CONSTANT)
QString m_uid;
bool m_secret;
bool m_expired;
Key m_key;
public: public:
PassKeyModel(QString uid, bool secret, bool expired):
m_uid(uid),
m_secret(secret),
m_expired(expired)
{};
PassKeyModel(Key key): PassKeyModel(Key key):
PassKeyModel(QString::fromUtf8(key.keyID()), key.hasSecret(), key.isExpired()) m_key(key)
{}; {};
static QList<QObject *> keysToPassKeyQObjectList(std::vector<Key> keys) static QList<QObject *> keysToPassKey(std::vector<Key> keys)
{ {
QList<QObject *> r; QList<QObject *> ret;
std::for_each(keys.begin(), keys.end(), [&r](Key k) { std::for_each(keys.begin(), keys.end(), [&ret](Key k) {
r.append(new PassKeyModel(k)); ret.append(new PassKeyModel(k));
}); });
return r; return ret;
}; };
QString uid() const QString uid() const
{ {
return m_uid; return QString::fromUtf8(m_key.keyID());
};
bool secret() const
{
return m_secret;
};
bool expired() const
{
return m_expired;
}; };
void setUid(QString uid) QList<QObject *> userIds() const
{ {
m_uid = uid; auto user_ids = m_key.userIDs();
emit uidChanged(uid); QList<QObject *> ret;
} std::for_each(user_ids.begin(), user_ids.end(), [&ret](UserID k) {
void setSecret(bool secret) ret.append(new UserIdModel(k));
{ });
m_secret = secret; return ret;
emit secretChanged(secret); };
}
void setExpired(bool expired)
{
m_expired = expired;
emit expiredChanged(expired);
}
signals: bool isSecret() const
void uidChanged(QString); {
void secretChanged(bool); return m_key.hasSecret();
void expiredChanged(bool); };
bool isExpired() const
{
return m_key.hasSecret();
};
}; };
#endif #endif

View File

@ -8,7 +8,7 @@ msgid ""
msgstr "" msgstr ""
"Project-Id-Version: utpass.qrouland\n" "Project-Id-Version: utpass.qrouland\n"
"Report-Msgid-Bugs-To: \n" "Report-Msgid-Bugs-To: \n"
"POT-Creation-Date: 2025-01-14 09:52+0100\n" "POT-Creation-Date: 2025-01-14 12:17+0100\n"
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
"Language-Team: LANGUAGE <LL@li.org>\n" "Language-Team: LANGUAGE <LL@li.org>\n"
@ -67,19 +67,19 @@ msgstr ""
msgid "<b>Maintainer</>" msgid "<b>Maintainer</>"
msgstr "" msgstr ""
#: ../qml/pages/Info.qml:109 #: ../qml/pages/Info.qml:108
msgid "Suggest improvement(s) or report a bug(s)" msgid "Suggest improvement(s) or report a bug(s)"
msgstr "" msgstr ""
#: ../qml/pages/Info.qml:114 #: ../qml/pages/Info.qml:113
msgid "Access to the source code" msgid "Access to the source code"
msgstr "" msgstr ""
#: ../qml/pages/Info.qml:122 #: ../qml/pages/Info.qml:121
msgid "Released under the terms of the GNU GPL v3" msgid "Released under the terms of the GNU GPL v3"
msgstr "" msgstr ""
#: ../qml/pages/Info.qml:131 ../qml/pages/headers/MainHeader.qml:33 #: ../qml/pages/Info.qml:130 ../qml/pages/headers/MainHeader.qml:33
msgid "Info" msgid "Info"
msgstr "" msgstr ""
@ -125,7 +125,8 @@ msgid ""
msgstr "" msgstr ""
#: ../qml/pages/settings/ImportGitClone.qml:91 #: ../qml/pages/settings/ImportGitClone.qml:91
#: ../qml/pages/settings/ImportZip.qml:62 ../qml/pages/settings/InfoKeys.qml:77 #: ../qml/pages/settings/ImportZip.qml:62
#: ../qml/pages/settings/InfoKeys.qml:117
msgid "Yes" msgid "Yes"
msgstr "" msgstr ""
@ -167,27 +168,31 @@ msgstr ""
msgid "Zip Password Store Import" msgid "Zip Password Store Import"
msgstr "" msgstr ""
#: ../qml/pages/settings/InfoKeys.qml:41 #: ../qml/pages/settings/InfoKeys.qml:39
msgid "Key id : %1" msgid "Key ID :"
msgstr "" msgstr ""
#: ../qml/pages/settings/InfoKeys.qml:54 #: ../qml/pages/settings/InfoKeys.qml:72
msgid "Users IDs : "
msgstr ""
#: ../qml/pages/settings/InfoKeys.qml:96
msgid "Delete this key" msgid "Delete this key"
msgstr "" msgstr ""
#: ../qml/pages/settings/InfoKeys.qml:76 #: ../qml/pages/settings/InfoKeys.qml:116
msgid "You're are about to delete<br>%1<br>Continue ?" msgid "You're are about to delete<br>%1<br>Continue ?"
msgstr "" msgstr ""
#: ../qml/pages/settings/InfoKeys.qml:94 #: ../qml/pages/settings/InfoKeys.qml:134
msgid "Key removal failed !" msgid "Key removal failed !"
msgstr "" msgstr ""
#: ../qml/pages/settings/InfoKeys.qml:103 #: ../qml/pages/settings/InfoKeys.qml:143
msgid "Key successfully deleted !" msgid "Key successfully deleted !"
msgstr "" msgstr ""
#: ../qml/pages/settings/InfoKeys.qml:114 #: ../qml/pages/settings/InfoKeys.qml:154
msgid "Info Keys" msgid "Info Keys"
msgstr "" msgstr ""

View File

@ -95,7 +95,6 @@ Page {
font.pixelSize: 72 font.pixelSize: 72
color: theme.palette.normal.backgroundText color: theme.palette.normal.backgroundText
} }
} }
Flow { Flow {

View File

@ -33,15 +33,57 @@ Page {
} }
Text { Text {
id: uidKey
width: parent.width width: parent.width
horizontalAlignment: Text.AlignHCenter horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter verticalAlignment: Text.AlignVCenter
text: i18n.tr('Key id : %1').arg(model.modelData.uid) text: i18n.tr('Key ID :')
color: theme.palette.normal.backgroundText color: theme.palette.normal.backgroundText
} }
Text {
width: parent.width
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: model.modelData.uid
color: theme.palette.normal.backgroundText
}
Rectangle {
width: parent.width
height: units.gu(1)
color: theme.palette.normal.background
}
ListModel {
id: userIdsModel
Component.onCompleted: {
for(var i=0; i< model.modelData.userIds.length; ++i){
userIdsModel.append({"model": model.modelData.userIds[i]})
}
}
}
Text {
width: parent.width
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: i18n.tr('Users IDs : ')
color: theme.palette.normal.backgroundText
}
Repeater {
model: userIdsModel
Text {
width: parent.width
horizontalAlignment: Text.AlignHCenter
verticalAlignment: Text.AlignVCenter
text: modelData.uid
color: theme.palette.normal.backgroundText
}
}
Rectangle { Rectangle {
width: parent.width width: parent.width
height: units.gu(1) height: units.gu(1)
@ -64,9 +106,7 @@ Page {
height: units.gu(1) height: units.gu(1)
color: theme.palette.normal.background color: theme.palette.normal.background
} }
} }
} }
Component { Component {