Skip to content

Commit

Permalink
Improve default Qt widget icons
Browse files Browse the repository at this point in the history
* Include new icons for toolbar overflow to ensure they are tinted correctly and fit in with the rest of the UI.
* Replace custom code for clearing line edits by including a proper icon for the default action.
  • Loading branch information
droidmonkey committed Oct 15, 2020
1 parent a09acc8 commit b0e038e
Show file tree
Hide file tree
Showing 17 changed files with 44 additions and 192 deletions.
4 changes: 3 additions & 1 deletion COPYING
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,9 @@ Files: share/icons/badges/2_Expired.svg
Copyright: 2020 KeePassXC Team <team@keepassxc.org>
License: MIT

Files: share/icons/application/scalable/actions/document-close.svg
Files: share/icons/application/scalable/actions/chevron-double-down.svg
share/icons/application/scalable/actions/chevron-double-right.svg
share/icons/application/scalable/actions/document-close.svg
share/icons/application/scalable/actions/document-edit.svg
share/icons/application/scalable/actions/document-export.svg
share/icons/application/scalable/actions/document-import.svg
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions share/icons/icons.qrc
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
<file>application/scalable/actions/application-exit.svg</file>
<file>application/scalable/actions/auto-type.svg</file>
<file>application/scalable/actions/bugreport.svg</file>
<file>application/scalable/actions/chevron-double-down.svg</file>
<file>application/scalable/actions/chevron-double-right.svg</file>
<file>application/scalable/actions/chronometer.svg</file>
<file>application/scalable/actions/clipboard-text.svg</file>
<file>application/scalable/actions/configure.svg</file>
Expand Down
1 change: 0 additions & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ set(keepassx_SOURCES
gui/IconModels.cpp
gui/KeePass1OpenWidget.cpp
gui/KMessageWidget.cpp
gui/LineEdit.cpp
gui/MainWindow.cpp
gui/MessageBox.cpp
gui/MessageWidget.cpp
Expand Down
13 changes: 0 additions & 13 deletions src/gui/DatabaseOpenWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,6 @@ DatabaseOpenWidget::DatabaseOpenWidget(QWidget* parent)
m_ui->keyFileLabelHelp->setIcon(resources()->icon("system-help").pixmap(QSize(12, 12)));
connect(m_ui->keyFileLabelHelp, SIGNAL(clicked(bool)), SLOT(openKeyFileHelp()));

connect(m_ui->keyFileLineEdit, SIGNAL(textChanged(QString)), SLOT(keyFileTextChanged()));
m_ui->keyFileLineEdit->addAction(m_ui->keyFileClearIcon, QLineEdit::TrailingPosition);
m_ui->keyFileClearIcon->setIcon(resources()->icon("edit-clear-locationbar-rtl"));
m_ui->keyFileClearIcon->setVisible(false);
connect(m_ui->keyFileClearIcon, SIGNAL(triggered(bool)), SLOT(clearKeyFileText()));

#ifdef WITH_XC_YUBIKEY
m_ui->hardwareKeyProgress->setVisible(false);
QSizePolicy sp = m_ui->hardwareKeyProgress->sizePolicy();
Expand Down Expand Up @@ -145,8 +139,6 @@ void DatabaseOpenWidget::load(const QString& filename)
m_filename = filename;
m_ui->fileNameLabel->setRawText(m_filename);

m_ui->keyFileClearIcon->setVisible(false);

if (config()->get(Config::RememberLastKeyFiles).toBool()) {
auto lastKeyFiles = config()->get(Config::LastKeyFiles).toHash();
if (lastKeyFiles.contains(m_filename)) {
Expand Down Expand Up @@ -388,11 +380,6 @@ void DatabaseOpenWidget::clearKeyFileText()
m_ui->keyFileLineEdit->clear();
}

void DatabaseOpenWidget::keyFileTextChanged()
{
m_ui->keyFileClearIcon->setVisible(!m_ui->keyFileLineEdit->text().isEmpty());
}

void DatabaseOpenWidget::pollHardwareKey()
{
if (m_pollingHardwareKey) {
Expand Down
1 change: 0 additions & 1 deletion src/gui/DatabaseOpenWidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ protected slots:
private slots:
void browseKeyFile();
void clearKeyFileText();
void keyFileTextChanged();
void pollHardwareKey();
void hardwareKeyResponse(bool found);
void openHardwareKeyHelp();
Expand Down
22 changes: 9 additions & 13 deletions src/gui/DatabaseOpenWidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -416,6 +416,9 @@
<property name="accessibleName">
<string>Key file to unlock the database</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
Expand Down Expand Up @@ -575,16 +578,14 @@
</spacer>
</item>
</layout>
<action name="keyFileClearIcon">
<property name="text">
<string>Clear</string>
</property>
<property name="toolTip">
<string>Clear Key File</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
<class>PasswordEdit</class>
<extends>QLineEdit</extends>
<header>gui/PasswordEdit.h</header>
<container>1</container>
</customwidget>
<customwidget>
<class>MessageWidget</class>
<extends>QWidget</extends>
Expand All @@ -596,11 +597,6 @@
<extends>QLabel</extends>
<header>gui/widgets/ElidedLabel.h</header>
</customwidget>
<customwidget>
<class>PasswordEdit</class>
<extends>QLineEdit</extends>
<header>gui/PasswordEdit.h</header>
</customwidget>
</customwidgets>
<tabstops>
<tabstop>editPassword</tabstop>
Expand Down
70 changes: 0 additions & 70 deletions src/gui/LineEdit.cpp

This file was deleted.

44 changes: 0 additions & 44 deletions src/gui/LineEdit.h

This file was deleted.

13 changes: 0 additions & 13 deletions src/gui/PasswordGeneratorWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,6 @@ PasswordGeneratorWidget::PasswordGeneratorWidget(QWidget* parent)
m_ui->buttonCopy->setIcon(resources()->icon("clipboard-text"));
m_ui->buttonClose->setShortcut(Qt::Key_Escape);

m_ui->clearInclude->setIcon(resources()->icon("edit-clear-locationbar-rtl"));
m_ui->editAdditionalChars->addAction(m_ui->clearInclude, QLineEdit::TrailingPosition);
m_ui->clearInclude->setVisible(false);

m_ui->clearExclude->setIcon(resources()->icon("edit-clear-locationbar-rtl"));
m_ui->editExcludedChars->addAction(m_ui->clearExclude, QLineEdit::TrailingPosition);
m_ui->clearExclude->setVisible(false);

connect(m_ui->editNewPassword, SIGNAL(textChanged(QString)), SLOT(updateButtonsEnabled(QString)));
connect(m_ui->editNewPassword, SIGNAL(textChanged(QString)), SLOT(updatePasswordStrength(QString)));
connect(m_ui->buttonAdvancedMode, SIGNAL(toggled(bool)), SLOT(setAdvancedMode(bool)));
Expand All @@ -63,8 +55,6 @@ PasswordGeneratorWidget::PasswordGeneratorWidget(QWidget* parent)
connect(m_ui->buttonCopy, SIGNAL(clicked()), SLOT(copyPassword()));
connect(m_ui->buttonGenerate, SIGNAL(clicked()), SLOT(regeneratePassword()));
connect(m_ui->buttonClose, SIGNAL(clicked()), SIGNAL(closed()));
connect(m_ui->clearInclude, SIGNAL(triggered(bool)), m_ui->editAdditionalChars, SLOT(clear()));
connect(m_ui->clearExclude, SIGNAL(triggered(bool)), m_ui->editExcludedChars, SLOT(clear()));

connect(m_ui->sliderLength, SIGNAL(valueChanged(int)), SLOT(passwordLengthChanged(int)));
connect(m_ui->spinBoxLength, SIGNAL(valueChanged(int)), SLOT(passwordLengthChanged(int)));
Expand Down Expand Up @@ -530,9 +520,6 @@ void PasswordGeneratorWidget::updateGenerator()
} else {
m_ui->buttonGenerate->setEnabled(false);
}

m_ui->clearInclude->setVisible(!m_ui->editAdditionalChars->text().isEmpty());
m_ui->clearExclude->setVisible(!m_ui->editExcludedChars->text().isEmpty());
} else {
m_dicewareGenerator->setWordCase(
static_cast<PassphraseGenerator::PassphraseWordCase>(m_ui->wordCaseComboBox->currentData().toInt()));
Expand Down
22 changes: 6 additions & 16 deletions src/gui/PasswordGeneratorWidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -608,6 +608,9 @@ QProgressBar::chunk {
<property name="accessibleName">
<string>Additional characters</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="1" column="2">
Expand Down Expand Up @@ -646,6 +649,9 @@ QProgressBar::chunk {
<property name="accessibleName">
<string>Excluded characters</string>
</property>
<property name="clearButtonEnabled">
<bool>true</bool>
</property>
</widget>
</item>
<item row="0" column="0">
Expand Down Expand Up @@ -944,22 +950,6 @@ QProgressBar::chunk {
</spacer>
</item>
</layout>
<action name="clearInclude">
<property name="text">
<string>Clear</string>
</property>
<property name="toolTip">
<string>Clear</string>
</property>
</action>
<action name="clearExclude">
<property name="text">
<string>Clear</string>
</property>
<property name="toolTip">
<string>Clear</string>
</property>
</action>
</widget>
<customwidgets>
<customwidget>
Expand Down
8 changes: 0 additions & 8 deletions src/gui/SearchWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@ SearchWidget::SearchWidget(QWidget* parent)
m_clearSearchTimer->setSingleShot(true);

connect(m_ui->searchEdit, SIGNAL(textChanged(QString)), SLOT(startSearchTimer()));
connect(m_ui->clearIcon, SIGNAL(triggered(bool)), m_ui->searchEdit, SLOT(clear()));
connect(m_ui->helpIcon, SIGNAL(triggered()), SLOT(toggleHelp()));
connect(m_ui->searchIcon, SIGNAL(triggered()), SLOT(showSearchMenu()));
connect(m_searchTimer, SIGNAL(timeout()), SLOT(startSearch()));
Expand Down Expand Up @@ -75,10 +74,6 @@ SearchWidget::SearchWidget(QWidget* parent)
m_ui->helpIcon->setIcon(resources()->icon("system-help"));
m_ui->searchEdit->addAction(m_ui->helpIcon, QLineEdit::TrailingPosition);

m_ui->clearIcon->setIcon(resources()->icon("edit-clear-locationbar-rtl"));
m_ui->clearIcon->setVisible(false);
m_ui->searchEdit->addAction(m_ui->clearIcon, QLineEdit::TrailingPosition);

// Fix initial visibility of actions (bug in Qt)
for (QToolButton* toolButton : m_ui->searchEdit->findChildren<QToolButton*>()) {
toolButton->setVisible(toolButton->defaultAction()->isVisible());
Expand Down Expand Up @@ -172,9 +167,6 @@ void SearchWidget::startSearch()
m_searchTimer->stop();
}

bool hasText = m_ui->searchEdit->text().length() > 0;
m_ui->clearIcon->setVisible(hasText);

search(m_ui->searchEdit->text());
}

Expand Down
7 changes: 1 addition & 6 deletions src/gui/SearchWidget.ui
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
<string/>
</property>
<property name="clearButtonEnabled">
<bool>false</bool>
<bool>true</bool>
</property>
</widget>
</item>
Expand All @@ -51,11 +51,6 @@
<string>Search</string>
</property>
</action>
<action name="clearIcon">
<property name="text">
<string>Clear</string>
</property>
</action>
<action name="helpIcon">
<property name="text">
<string>Search Help</string>
Expand Down
17 changes: 17 additions & 0 deletions src/gui/styles/base/BaseStyle.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@

#include <cmath>

#include "core/Resources.h"

QT_BEGIN_NAMESPACE
Q_GUI_EXPORT int qt_defaultDpiX();
QT_END_NAMESPACE
Expand Down Expand Up @@ -3036,6 +3038,21 @@ QPalette BaseStyle::standardPalette() const
return QCommonStyle::standardPalette();
}

QIcon BaseStyle::standardIcon(StandardPixmap sp, const QStyleOption* opt, const QWidget* widget) const
{
switch (sp) {
case SP_ToolBarHorizontalExtensionButton:
return resources()->icon("chevron-double-down");
case SP_ToolBarVerticalExtensionButton:
return resources()->icon("chevron-double-right");
case SP_LineEditClearButton:
return resources()->icon(
QString("edit-clear-locationbar-").append((opt->direction == Qt::LeftToRight) ? "rtl" : "ltr"));
default:
return QCommonStyle::standardIcon(sp, opt, widget);
}
}

void BaseStyle::drawComplexControl(ComplexControl control,
const QStyleOptionComplex* option,
QPainter* painter,
Expand Down
Loading

0 comments on commit b0e038e

Please sign in to comment.