Use Icons for password strength (#9844)

---------

Co-authored-by: Jonathan White <support@dmapps.us>
This commit is contained in:
Felix Nüsse 2024-08-12 15:39:11 +02:00 committed by Jonathan White
parent 4317e9d829
commit 8bdbccf13f
No known key found for this signature in database
GPG Key ID: 440FC65F2E0C6E01
8 changed files with 23 additions and 23 deletions

View File

@ -239,6 +239,9 @@ Files: share/icons/application/scalable/actions/application-exit.svg
share/icons/application/scalable/status/dialog-information.svg share/icons/application/scalable/status/dialog-information.svg
share/icons/application/scalable/status/dialog-warning.svg share/icons/application/scalable/status/dialog-warning.svg
share/icons/application/scalable/status/security-high.svg share/icons/application/scalable/status/security-high.svg
share/icons/application/scalable/actions/lock-open-alert.svg
share/icons/application/scalable/actions/lock-open.svg
share/icons/application/scalable/actions/lock.svg
Copyright: 2019 Austin Andrews <http://templarian.com/> Copyright: 2019 Austin Andrews <http://templarian.com/>
License: SIL OPEN FONT LICENSE Version 1.1 License: SIL OPEN FONT LICENSE Version 1.1
Comment: Taken from Material Design icon set (https://github.com/templarian/MaterialDesign/) Comment: Taken from Material Design icon set (https://github.com/templarian/MaterialDesign/)

View File

@ -0,0 +1 @@
<svg viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" xml:space="preserve" style="fill-rule:evenodd;clip-rule:evenodd;stroke-linejoin:round;stroke-miterlimit:2"><path d="M22.326 14.864h-2.652v-12h2.652v12m0 5h-2.652v-3h2.652v3Z" style="fill-rule:nonzero" transform="matrix(1.13122 0 0 1 -1.2557 2.1364)"/><path d="M18 8c1.097 0 2 .903 2 2v10c0 1.097-.903 2-2 2H6c-1.11 0-2-.9-2-2V10c0-1.097.903-2 2-2h9V6c0-1.646-1.354-3-3-3S9 4.354 9 6H7c0-2.743 2.257-5 5-5s5 2.257 5 5v2h1m-6 9c1.097 0 2-.903 2-2s-.903-2-2-2-2 .903-2 2 .903 2 2 2Z" style="fill-rule:nonzero" transform="translate(-1)"/></svg>

After

Width:  |  Height:  |  Size: 600 B

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M18,8A2,2 0 0,1 20,10V20A2,2 0 0,1 18,22H6C4.89,22 4,21.1 4,20V10A2,2 0 0,1 6,8H15V6A3,3 0 0,0 12,3A3,3 0 0,0 9,6H7A5,5 0 0,1 12,1A5,5 0 0,1 17,6V8H18M12,17A2,2 0 0,0 14,15A2,2 0 0,0 12,13A2,2 0 0,0 10,15A2,2 0 0,0 12,17Z" /></svg>

After

Width:  |  Height:  |  Size: 300 B

View File

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24"><path d="M12,17A2,2 0 0,0 14,15C14,13.89 13.1,13 12,13A2,2 0 0,0 10,15A2,2 0 0,0 12,17M18,8A2,2 0 0,1 20,10V20A2,2 0 0,1 18,22H6A2,2 0 0,1 4,20V10C4,8.89 4.9,8 6,8H7V6A5,5 0 0,1 12,1A5,5 0 0,1 17,6V8H18M12,3A3,3 0 0,0 9,6V8H15V6A3,3 0 0,0 12,3Z" /></svg>

After

Width:  |  Height:  |  Size: 314 B

View File

@ -55,6 +55,9 @@
<file>application/scalable/actions/hibp.svg</file> <file>application/scalable/actions/hibp.svg</file>
<file>application/scalable/actions/lock-question.svg</file> <file>application/scalable/actions/lock-question.svg</file>
<file>application/scalable/actions/keyboard-shortcuts.svg</file> <file>application/scalable/actions/keyboard-shortcuts.svg</file>
<file>application/scalable/actions/lock.svg</file>
<file>application/scalable/actions/lock-open.svg</file>
<file>application/scalable/actions/lock-open-alert.svg</file>
<file>application/scalable/actions/message-close.svg</file> <file>application/scalable/actions/message-close.svg</file>
<file>application/scalable/actions/move-down.svg</file> <file>application/scalable/actions/move-down.svg</file>
<file>application/scalable/actions/move-up.svg</file> <file>application/scalable/actions/move-up.svg</file>

View File

@ -8674,29 +8674,14 @@ This option is deprecated, use --set-key-file instead.</source>
<source>Hover over reason to show additional details. Double-click entries to edit.</source> <source>Hover over reason to show additional details. Double-click entries to edit.</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Bad</source>
<comment>Password quality</comment>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>Bad password must be changed</source> <source>Bad password must be changed</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Poor</source>
<comment>Password quality</comment>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>Poor password should be changed</source> <source>Poor password should be changed</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>
</message> </message>
<message>
<source>Weak</source>
<comment>Password quality</comment>
<translation type="unfinished"></translation>
</message>
<message> <message>
<source>Weak consider changing the password</source> <source>Weak consider changing the password</source>
<translation type="unfinished"></translation> <translation type="unfinished"></translation>

View File

@ -286,24 +286,30 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const
break; break;
case PasswordStrength: case PasswordStrength:
if (!entry->password().isEmpty() && !entry->excludeFromReports()) { if (!entry->password().isEmpty() && !entry->excludeFromReports()) {
QString iconName = "lock-question";
StateColorPalette statePalette; StateColorPalette statePalette;
QColor color = statePalette.color(StateColorPalette::Error); QColor color = statePalette.color(StateColorPalette::Error);
switch (entry->passwordHealth()->quality()) { switch (entry->passwordHealth()->quality()) {
case PasswordHealth::Quality::Bad: case PasswordHealth::Quality::Bad:
case PasswordHealth::Quality::Poor: case PasswordHealth::Quality::Poor:
iconName = "lock-open-alert";
color = statePalette.color(StateColorPalette::HealthCritical); color = statePalette.color(StateColorPalette::HealthCritical);
break; break;
case PasswordHealth::Quality::Weak: case PasswordHealth::Quality::Weak:
iconName = "lock-open";
color = statePalette.color(StateColorPalette::HealthBad); color = statePalette.color(StateColorPalette::HealthBad);
break; break;
case PasswordHealth::Quality::Good: case PasswordHealth::Quality::Good:
case PasswordHealth::Quality::Excellent: case PasswordHealth::Quality::Excellent:
iconName = "lock";
color = statePalette.color(StateColorPalette::HealthExcellent); color = statePalette.color(StateColorPalette::HealthExcellent);
break; break;
} }
return color; if (color.isValid()) {
return icons()->icon(iconName, true, color);
}
} }
break; break;
} }

View File

@ -167,31 +167,32 @@ void ReportsWidgetHealthcheck::addHealthRow(QSharedPointer<PasswordHealth> healt
Entry* entry, Entry* entry,
bool excluded) bool excluded)
{ {
QString descr, tip; QString tip;
QString iconName = "lock-question";
QColor qualityColor; QColor qualityColor;
StateColorPalette statePalette; StateColorPalette statePalette;
const auto quality = health->quality(); const auto quality = health->quality();
switch (quality) { switch (quality) {
case PasswordHealth::Quality::Bad: case PasswordHealth::Quality::Bad:
descr = tr("Bad", "Password quality");
tip = tr("Bad — password must be changed"); tip = tr("Bad — password must be changed");
iconName = "lock-open-alert";
qualityColor = statePalette.color(StateColorPalette::HealthCritical); qualityColor = statePalette.color(StateColorPalette::HealthCritical);
break; break;
case PasswordHealth::Quality::Poor: case PasswordHealth::Quality::Poor:
descr = tr("Poor", "Password quality");
tip = tr("Poor — password should be changed"); tip = tr("Poor — password should be changed");
iconName = "lock-open-alert";
qualityColor = statePalette.color(StateColorPalette::HealthBad); qualityColor = statePalette.color(StateColorPalette::HealthBad);
break; break;
case PasswordHealth::Quality::Weak: case PasswordHealth::Quality::Weak:
descr = tr("Weak", "Password quality");
tip = tr("Weak — consider changing the password"); tip = tr("Weak — consider changing the password");
iconName = "lock-open";
qualityColor = statePalette.color(StateColorPalette::HealthWeak); qualityColor = statePalette.color(StateColorPalette::HealthWeak);
break; break;
case PasswordHealth::Quality::Good: case PasswordHealth::Quality::Good:
case PasswordHealth::Quality::Excellent: case PasswordHealth::Quality::Excellent:
iconName = "lock";
qualityColor = statePalette.color(StateColorPalette::HealthOk); qualityColor = statePalette.color(StateColorPalette::HealthOk);
break; break;
} }
@ -205,7 +206,7 @@ void ReportsWidgetHealthcheck::addHealthRow(QSharedPointer<PasswordHealth> healt
} }
auto row = QList<QStandardItem*>(); auto row = QList<QStandardItem*>();
row << new QStandardItem(descr); row << new QStandardItem(Icons::instance()->icon(iconName, true, qualityColor), "");
row << new QStandardItem(Icons::entryIconPixmap(entry), title); row << new QStandardItem(Icons::entryIconPixmap(entry), title);
row << new QStandardItem(Icons::groupIconPixmap(group), group->hierarchy().join("/")); row << new QStandardItem(Icons::groupIconPixmap(group), group->hierarchy().join("/"));
row << new QStandardItem(QString::number(health->score())); row << new QStandardItem(QString::number(health->score()));
@ -216,7 +217,6 @@ void ReportsWidgetHealthcheck::addHealthRow(QSharedPointer<PasswordHealth> healt
// invisible, it's just for screen readers etc. // invisible, it's just for screen readers etc.
QBrush brush(qualityColor); QBrush brush(qualityColor);
row[0]->setForeground(brush); row[0]->setForeground(brush);
row[0]->setBackground(brush);
// Set tooltips // Set tooltips
row[0]->setToolTip(tip); row[0]->setToolTip(tip);