From 97b034dbcbd4e3758a1dcbcb1be71cd9da1128fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Wolfram=20R=C3=B6sler?= Date: Sat, 11 Jan 2020 19:52:47 +0100 Subject: [PATCH] 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 --- src/core/FilePath.cpp | 6 +----- src/core/FilePath.h | 2 +- src/fdosecrets/widgets/SettingsModels.cpp | 4 ++-- src/fdosecrets/widgets/SettingsWidgetFdoSecrets.cpp | 7 +++---- src/gui/KMessageWidget.cpp | 2 +- src/gui/LineEdit.cpp | 11 +---------- src/gui/masterkey/PasswordEditWidget.cpp | 2 +- src/keeshare/group/EditGroupWidgetKeeShare.cpp | 2 +- utils/makeicons.sh | 7 ++----- 9 files changed, 13 insertions(+), 30 deletions(-) diff --git a/src/core/FilePath.cpp b/src/core/FilePath.cpp index 2725f4671..62db3929d 100644 --- a/src/core/FilePath.cpp +++ b/src/core/FilePath.cpp @@ -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 pngSizes = {16, 22, 24, 32, 48, 64, 128}; QString filename; diff --git a/src/core/FilePath.h b/src/core/FilePath.h index b304b5f14..ceb958237 100644 --- a/src/core/FilePath.h +++ b/src/core/FilePath.h @@ -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(); diff --git a/src/fdosecrets/widgets/SettingsModels.cpp b/src/fdosecrets/widgets/SettingsModels.cpp index edcb275c8..2921182c5 100644 --- a/src/fdosecrets/widgets/SettingsModels.cpp +++ b/src/fdosecrets/widgets/SettingsModels.cpp @@ -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 {}; } diff --git a/src/fdosecrets/widgets/SettingsWidgetFdoSecrets.cpp b/src/fdosecrets/widgets/SettingsWidgetFdoSecrets.cpp index 59399cdec..5ae267a12 100644 --- a/src/fdosecrets/widgets/SettingsWidgetFdoSecrets.cpp +++ b/src/fdosecrets/widgets/SettingsWidgetFdoSecrets.cpp @@ -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); }); diff --git a/src/gui/KMessageWidget.cpp b/src/gui/KMessageWidget.cpp index 80f302858..8df7b6384 100644 --- a/src/gui/KMessageWidget.cpp +++ b/src/gui/KMessageWidget.cpp @@ -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())); diff --git a/src/gui/LineEdit.cpp b/src/gui/LineEdit.cpp index 654f9a3a7..98a5c09e8 100644 --- a/src/gui/LineEdit.cpp +++ b/src/gui/LineEdit.cpp @@ -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); diff --git a/src/gui/masterkey/PasswordEditWidget.cpp b/src/gui/masterkey/PasswordEditWidget.cpp index 9353cbe7a..96b5fd305 100644 --- a/src/gui/masterkey/PasswordEditWidget.cpp +++ b/src/gui/masterkey/PasswordEditWidget.cpp @@ -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, diff --git a/src/keeshare/group/EditGroupWidgetKeeShare.cpp b/src/keeshare/group/EditGroupWidgetKeeShare.cpp index 5df9f13ee..43f32b343 100644 --- a/src/keeshare/group/EditGroupWidgetKeeShare.cpp +++ b/src/keeshare/group/EditGroupWidgetKeeShare.cpp @@ -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(); diff --git a/utils/makeicons.sh b/utils/makeicons.sh index 8ce435476..6efc608ee 100644 --- a/utils/makeicons.sh +++ b/utils/makeicons.sh @@ -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/