Skip to content

Commit

Permalink
Use Icons for password strength (keepassxreboot#9844)
Browse files Browse the repository at this point in the history
---------

Co-authored-by: Jonathan White <[email protected]>
  • Loading branch information
newhinton and droidmonkey authored Aug 12, 2024
1 parent 6a9ed21 commit ac6654c
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 23 deletions.
3 changes: 3 additions & 0 deletions COPYING
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,9 @@ Files: share/icons/application/scalable/actions/application-exit.svg
share/icons/application/scalable/status/dialog-information.svg
share/icons/application/scalable/status/dialog-warning.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/>
License: SIL OPEN FONT LICENSE Version 1.1
Comment: Taken from Material Design icon set (https://github.com/templarian/MaterialDesign/)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions share/icons/application/scalable/actions/lock-open.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions share/icons/application/scalable/actions/lock.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions share/icons/icons.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,9 @@
<file>application/scalable/actions/hibp.svg</file>
<file>application/scalable/actions/lock-question.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/move-down.svg</file>
<file>application/scalable/actions/move-up.svg</file>
Expand Down
15 changes: 0 additions & 15 deletions share/translations/keepassxc_en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9060,29 +9060,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>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bad</source>
<comment>Password quality</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Bad — password must be changed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Poor</source>
<comment>Password quality</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Poor — password should be changed</source>
<translation type="unfinished"></translation>
</message>
<message>
<source>Weak</source>
<comment>Password quality</comment>
<translation type="unfinished"></translation>
</message>
<message>
<source>Weak — consider changing the password</source>
<translation type="unfinished"></translation>
Expand Down
8 changes: 7 additions & 1 deletion src/gui/entry/EntryModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,24 +297,30 @@ QVariant EntryModel::data(const QModelIndex& index, int role) const
break;
case PasswordStrength:
if (!entry->password().isEmpty() && !entry->excludeFromReports()) {
QString iconName = "lock-question";
StateColorPalette statePalette;
QColor color = statePalette.color(StateColorPalette::Error);

switch (entry->passwordHealth()->quality()) {
case PasswordHealth::Quality::Bad:
case PasswordHealth::Quality::Poor:
iconName = "lock-open-alert";
color = statePalette.color(StateColorPalette::HealthCritical);
break;
case PasswordHealth::Quality::Weak:
iconName = "lock-open";
color = statePalette.color(StateColorPalette::HealthBad);
break;
case PasswordHealth::Quality::Good:
case PasswordHealth::Quality::Excellent:
iconName = "lock";
color = statePalette.color(StateColorPalette::HealthExcellent);
break;
}

return color;
if (color.isValid()) {
return icons()->icon(iconName, true, color);
}
}
break;
}
Expand Down
14 changes: 7 additions & 7 deletions src/gui/reports/ReportsWidgetHealthcheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -165,31 +165,32 @@ void ReportsWidgetHealthcheck::addHealthRow(QSharedPointer<PasswordHealth> healt
Entry* entry,
bool excluded)
{
QString descr, tip;
QString tip;
QString iconName = "lock-question";
QColor qualityColor;
StateColorPalette statePalette;
const auto quality = health->quality();
switch (quality) {
case PasswordHealth::Quality::Bad:
descr = tr("Bad", "Password quality");
tip = tr("Bad — password must be changed");
iconName = "lock-open-alert";
qualityColor = statePalette.color(StateColorPalette::HealthCritical);
break;

case PasswordHealth::Quality::Poor:
descr = tr("Poor", "Password quality");
tip = tr("Poor — password should be changed");
iconName = "lock-open-alert";
qualityColor = statePalette.color(StateColorPalette::HealthBad);
break;

case PasswordHealth::Quality::Weak:
descr = tr("Weak", "Password quality");
tip = tr("Weak — consider changing the password");
iconName = "lock-open";
qualityColor = statePalette.color(StateColorPalette::HealthWeak);
break;

case PasswordHealth::Quality::Good:
case PasswordHealth::Quality::Excellent:
iconName = "lock";
qualityColor = statePalette.color(StateColorPalette::HealthOk);
break;
}
Expand All @@ -203,7 +204,7 @@ void ReportsWidgetHealthcheck::addHealthRow(QSharedPointer<PasswordHealth> healt
}

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::groupIconPixmap(group), group->hierarchy().join("/"));
row << new QStandardItem(QString::number(health->score()));
Expand All @@ -214,7 +215,6 @@ void ReportsWidgetHealthcheck::addHealthRow(QSharedPointer<PasswordHealth> healt
// invisible, it's just for screen readers etc.
QBrush brush(qualityColor);
row[0]->setForeground(brush);
row[0]->setBackground(brush);

// Set tooltips
row[0]->setToolTip(tip);
Expand Down

0 comments on commit ac6654c

Please sign in to comment.