Ignore system icon theme, always use our own icons

With the Material Design icons, any other icons brought in through
the system icon theme will look inconsistent.

Also remove the KEEPASSXC_IGNORE_ICON_THEME environment variable
(which was introduced during development of the new icons to
disable the system icon theme and is thus no longer needed).

Fixes #475
This commit is contained in:
Wolfram Rösler 2020-01-11 19:52:47 +01:00 committed by Jonathan White
parent 94b45ea16f
commit 97b034dbcb
9 changed files with 13 additions and 30 deletions

View File

@ -133,7 +133,7 @@ QIcon FilePath::trayIconUnlocked()
#endif
}
QIcon FilePath::icon(const QString& category, const QString& name, bool fromTheme)
QIcon FilePath::icon(const QString& category, const QString& name)
{
QString combinedName = category + "/" + name;
@ -143,10 +143,6 @@ QIcon FilePath::icon(const QString& category, const QString& name, bool fromThem
return icon;
}
if (fromTheme && !getenv("KEEPASSXC_IGNORE_ICON_THEME")) {
icon = QIcon::fromTheme(name);
}
if (icon.isNull()) {
const QList<int> pngSizes = {16, 22, 24, 32, 48, 64, 128};
QString filename;

View File

@ -32,7 +32,7 @@ public:
QIcon trayIcon();
QIcon trayIconLocked();
QIcon trayIconUnlocked();
QIcon icon(const QString& category, const QString& name, bool fromTheme = true);
QIcon icon(const QString& category, const QString& name);
QIcon onOffIcon(const QString& category, const QString& name);
static FilePath* instance();

View File

@ -130,7 +130,7 @@ namespace FdoSecrets
case Qt::DisplayRole:
return tr("Unlock to show");
case Qt::DecorationRole:
return filePath()->icon(QStringLiteral("apps"), QStringLiteral("object-locked"), true);
return filePath()->icon(QStringLiteral("apps"), QStringLiteral("object-locked"));
case Qt::FontRole: {
QFont font;
font.setItalic(true);
@ -165,7 +165,7 @@ namespace FdoSecrets
case Qt::DisplayRole:
return tr("None");
case Qt::DecorationRole:
return filePath()->icon(QStringLiteral("apps"), QStringLiteral("paint-none"), true);
return filePath()->icon(QStringLiteral("apps"), QStringLiteral("paint-none"));
default:
return {};
}

View File

@ -75,7 +75,7 @@ namespace
// unlock/lock
m_lockAct = new QAction(tr("Unlock database"), this);
m_lockAct->setIcon(filePath()->icon(QStringLiteral("actions"), QStringLiteral("object-locked"), false));
m_lockAct->setIcon(filePath()->icon(QStringLiteral("actions"), QStringLiteral("object-locked")));
m_lockAct->setToolTip(tr("Unlock database to show more information"));
connect(m_lockAct, &QAction::triggered, this, [this]() {
if (!m_dbWidget) {
@ -133,14 +133,13 @@ namespace
}
connect(m_dbWidget, &DatabaseWidget::databaseLocked, this, [this]() {
m_lockAct->setText(tr("Unlock database"));
m_lockAct->setIcon(filePath()->icon(QStringLiteral("actions"), QStringLiteral("object-locked"), false));
m_lockAct->setIcon(filePath()->icon(QStringLiteral("actions"), QStringLiteral("object-locked")));
m_lockAct->setToolTip(tr("Unlock database to show more information"));
m_dbSettingsAct->setEnabled(false);
});
connect(m_dbWidget, &DatabaseWidget::databaseUnlocked, this, [this]() {
m_lockAct->setText(tr("Lock database"));
m_lockAct->setIcon(
filePath()->icon(QStringLiteral("actions"), QStringLiteral("object-unlocked"), false));
m_lockAct->setIcon(filePath()->icon(QStringLiteral("actions"), QStringLiteral("object-unlocked")));
m_lockAct->setToolTip(tr("Lock database"));
m_dbSettingsAct->setEnabled(true);
});

View File

@ -94,7 +94,7 @@ void KMessageWidgetPrivate::init(KMessageWidget *q_ptr)
QAction *closeAction = new QAction(q);
closeAction->setText(KMessageWidget::tr("&Close"));
closeAction->setToolTip(KMessageWidget::tr("Close message"));
closeAction->setIcon(FilePath::instance()->icon("actions", "message-close", false));
closeAction->setIcon(FilePath::instance()->icon("actions", "message-close"));
QObject::connect(closeAction, SIGNAL(triggered(bool)), q, SLOT(animatedHide()));

View File

@ -33,16 +33,7 @@ LineEdit::LineEdit(QWidget* parent)
QString iconNameDirected =
QString("edit-clear-locationbar-").append((layoutDirection() == Qt::LeftToRight) ? "rtl" : "ltr");
QIcon icon;
if (!getenv("KEEPASSXC_IGNORE_ICON_THEME")) {
icon = QIcon::fromTheme(iconNameDirected);
if (icon.isNull()) {
icon = QIcon::fromTheme("edit-clear");
}
}
if (icon.isNull()) {
icon = filePath()->icon("actions", iconNameDirected);
}
const auto icon = filePath()->icon("actions", iconNameDirected);
m_clearButton->setIcon(icon);
m_clearButton->setCursor(Qt::ArrowCursor);

View File

@ -74,7 +74,7 @@ QWidget* PasswordEditWidget::componentEditWidget()
m_compEditWidget = new QWidget();
m_compUi->setupUi(m_compEditWidget);
m_compUi->togglePasswordButton->setIcon(filePath()->onOffIcon("actions", "password-show"));
m_compUi->passwordGeneratorButton->setIcon(filePath()->icon("actions", "password-generator", false));
m_compUi->passwordGeneratorButton->setIcon(filePath()->icon("actions", "password-generator"));
m_compUi->repeatPasswordEdit->enableVerifyMode(m_compUi->enterPasswordEdit);
connect(m_compUi->togglePasswordButton,

View File

@ -37,7 +37,7 @@ EditGroupWidgetKeeShare::EditGroupWidgetKeeShare(QWidget* parent)
m_ui->setupUi(this);
m_ui->togglePasswordButton->setIcon(filePath()->onOffIcon("actions", "password-show"));
m_ui->togglePasswordGeneratorButton->setIcon(filePath()->icon("actions", "password-generator", false));
m_ui->togglePasswordGeneratorButton->setIcon(filePath()->icon("actions", "password-generator"));
m_ui->passwordGenerator->layout()->setContentsMargins(0, 0, 0, 0);
m_ui->passwordGenerator->hide();

View File

@ -32,12 +32,9 @@
# 3. Create the icons:
# $ bash ../../utils/makeicons.sh ~/src/MaterialDesign
#
# 4. Re-build KeePassXC:
# 4. Re-build and run KeePassXC:
# $ cd ~/keepassxc/build
# $ make keepassxc
#
# 5. Check icons by disabling the OS icon theme:
# $ KEEPASSXC_IGNORE_ICON_THEME=1 src/keepassxc
# $ make keepassxc && src/keepassxc
#
# Material icons: https://materialdesignicons.com/