diff options
-rw-r--r-- | COPYING | 4 | ||||
-rw-r--r-- | share/icons/application/scalable/actions/chevron-double-down.svg | 1 | ||||
-rw-r--r-- | share/icons/application/scalable/actions/chevron-double-right.svg | 1 | ||||
-rw-r--r-- | share/icons/icons.qrc | 2 | ||||
-rw-r--r-- | src/CMakeLists.txt | 1 | ||||
-rw-r--r-- | src/gui/DatabaseOpenWidget.cpp | 13 | ||||
-rw-r--r-- | src/gui/DatabaseOpenWidget.h | 1 | ||||
-rw-r--r-- | src/gui/DatabaseOpenWidget.ui | 22 | ||||
-rw-r--r-- | src/gui/LineEdit.cpp | 70 | ||||
-rw-r--r-- | src/gui/LineEdit.h | 44 | ||||
-rw-r--r-- | src/gui/PasswordGeneratorWidget.cpp | 13 | ||||
-rw-r--r-- | src/gui/PasswordGeneratorWidget.ui | 22 | ||||
-rw-r--r-- | src/gui/SearchWidget.cpp | 8 | ||||
-rw-r--r-- | src/gui/SearchWidget.ui | 7 | ||||
-rw-r--r-- | src/gui/styles/base/BaseStyle.cpp | 17 | ||||
-rw-r--r-- | src/gui/styles/base/BaseStyle.h | 2 | ||||
-rw-r--r-- | tests/gui/TestGui.cpp | 8 |
17 files changed, 44 insertions, 192 deletions
@@ -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 diff --git a/share/icons/application/scalable/actions/chevron-double-down.svg b/share/icons/application/scalable/actions/chevron-double-down.svg new file mode 100644 index 000000000..edcf11814 --- /dev/null +++ b/share/icons/application/scalable/actions/chevron-double-down.svg @@ -0,0 +1 @@ +<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="24" height="24" viewBox="0 0 24 24"><path d="M16.59,5.59L18,7L12,13L6,7L7.41,5.59L12,10.17L16.59,5.59M16.59,11.59L18,13L12,19L6,13L7.41,11.59L12,16.17L16.59,11.59Z" /></svg>
\ No newline at end of file diff --git a/share/icons/application/scalable/actions/chevron-double-right.svg b/share/icons/application/scalable/actions/chevron-double-right.svg new file mode 100644 index 000000000..3f2a06b4f --- /dev/null +++ b/share/icons/application/scalable/actions/chevron-double-right.svg @@ -0,0 +1 @@ +<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" width="24" height="24" viewBox="0 0 24 24"><path d="M5.59,7.41L7,6L13,12L7,18L5.59,16.59L10.17,12L5.59,7.41M11.59,7.41L13,6L19,12L13,18L11.59,16.59L16.17,12L11.59,7.41Z" /></svg>
\ No newline at end of file diff --git a/share/icons/icons.qrc b/share/icons/icons.qrc index cb11f9068..cf73b4958 100644 --- a/share/icons/icons.qrc +++ b/share/icons/icons.qrc @@ -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> diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2f8c3b156..0ceccdd9a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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 diff --git a/src/gui/DatabaseOpenWidget.cpp b/src/gui/DatabaseOpenWidget.cpp index 4dbe9dc9d..b48f86365 100644 --- a/src/gui/DatabaseOpenWidget.cpp +++ b/src/gui/DatabaseOpenWidget.cpp @@ -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(); @@ -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)) { @@ -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) { diff --git a/src/gui/DatabaseOpenWidget.h b/src/gui/DatabaseOpenWidget.h index 6d2b688ca..fffdf8a7a 100644 --- a/src/gui/DatabaseOpenWidget.h +++ b/src/gui/DatabaseOpenWidget.h @@ -66,7 +66,6 @@ protected slots: private slots: void browseKeyFile(); void clearKeyFileText(); - void keyFileTextChanged(); void pollHardwareKey(); void hardwareKeyResponse(bool found); void openHardwareKeyHelp(); diff --git a/src/gui/DatabaseOpenWidget.ui b/src/gui/DatabaseOpenWidget.ui index a7510baba..eef4a2ed2 100644 --- a/src/gui/DatabaseOpenWidget.ui +++ b/src/gui/DatabaseOpenWidget.ui @@ -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> @@ -575,17 +578,15 @@ </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> <header>gui/MessageWidget.h</header> @@ -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> diff --git a/src/gui/LineEdit.cpp b/src/gui/LineEdit.cpp deleted file mode 100644 index ec5cb7f9c..000000000 --- a/src/gui/LineEdit.cpp +++ /dev/null @@ -1,70 +0,0 @@ -/* - * Copyright (C) 2007 Trolltech ASA <info@trolltech.com> - * Copyright (C) 2012 Felix Geyer <debfx@fobos.de> - * Copyright (C) 2012 Florian Geyer <blueice@fobos.de> - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 or (at your option) - * version 3 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#include "LineEdit.h" - -#include <QStyle> -#include <QToolButton> - -#include "core/Resources.h" - -LineEdit::LineEdit(QWidget* parent) - : QLineEdit(parent) - , m_clearButton(new QToolButton(this)) -{ - m_clearButton->setObjectName("clearButton"); - - QString iconNameDirected = - QString("edit-clear-locationbar-").append((layoutDirection() == Qt::LeftToRight) ? "rtl" : "ltr"); - - const auto icon = resources()->icon(iconNameDirected); - - m_clearButton->setIcon(icon); - m_clearButton->setCursor(Qt::ArrowCursor); - m_clearButton->setStyleSheet("QToolButton { border: none; padding: 0px; }"); - m_clearButton->hide(); - connect(m_clearButton, SIGNAL(clicked()), this, SLOT(clear())); - connect(this, SIGNAL(textChanged(QString)), this, SLOT(updateCloseButton(QString))); - int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); - setStyleSheet( - QString("QLineEdit { padding-right: %1px; } ").arg(m_clearButton->sizeHint().width() + frameWidth + 1)); - QSize msz = minimumSizeHint(); - setMinimumSize(qMax(msz.width(), m_clearButton->sizeHint().height() + frameWidth * 2 + 2), - qMax(msz.height(), m_clearButton->sizeHint().height() + frameWidth * 2 + 2)); -} - -void LineEdit::resizeEvent(QResizeEvent* event) -{ - QSize sz = m_clearButton->sizeHint(); - int frameWidth = style()->pixelMetric(QStyle::PM_DefaultFrameWidth); - int y = (rect().bottom() + 1 - sz.height()) / 2; - - if (layoutDirection() == Qt::LeftToRight) { - m_clearButton->move(rect().right() - frameWidth - sz.width(), y); - } else { - m_clearButton->move(rect().left() + frameWidth, y); - } - - QLineEdit::resizeEvent(event); -} - -void LineEdit::updateCloseButton(const QString& text) -{ - m_clearButton->setVisible(!text.isEmpty()); -} diff --git a/src/gui/LineEdit.h b/src/gui/LineEdit.h deleted file mode 100644 index 1695e8551..000000000 --- a/src/gui/LineEdit.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (C) 2007 Trolltech ASA <info@trolltech.com> - * Copyright (C) 2012 Felix Geyer <debfx@fobos.de> - * Copyright (C) 2012 Florian Geyer <blueice@fobos.de> - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 2 or (at your option) - * version 3 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef KEEPASSX_LINEEDIT_H -#define KEEPASSX_LINEEDIT_H - -#include <QLineEdit> - -class QToolButton; - -class LineEdit : public QLineEdit -{ - Q_OBJECT - -public: - explicit LineEdit(QWidget* parent = nullptr); - -protected: - void resizeEvent(QResizeEvent* event) override; - -private slots: - void updateCloseButton(const QString& text); - -private: - QToolButton* const m_clearButton; -}; - -#endif // KEEPASSX_LINEEDIT_H diff --git a/src/gui/PasswordGeneratorWidget.cpp b/src/gui/PasswordGeneratorWidget.cpp index 07dda651b..2dc643df2 100644 --- a/src/gui/PasswordGeneratorWidget.cpp +++ b/src/gui/PasswordGeneratorWidget.cpp @@ -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))); @@ -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))); @@ -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())); diff --git a/src/gui/PasswordGeneratorWidget.ui b/src/gui/PasswordGeneratorWidget.ui index 65018cbda..81964a517 100644 --- a/src/gui/PasswordGeneratorWidget.ui +++ b/src/gui/PasswordGeneratorWidget.ui @@ -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"> @@ -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"> @@ -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> diff --git a/src/gui/SearchWidget.cpp b/src/gui/SearchWidget.cpp index 1c7b683c1..6ade47e2e 100644 --- a/src/gui/SearchWidget.cpp +++ b/src/gui/SearchWidget.cpp @@ -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())); @@ -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()); @@ -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()); } diff --git a/src/gui/SearchWidget.ui b/src/gui/SearchWidget.ui index 74cc468cf..c924b4076 100644 --- a/src/gui/SearchWidget.ui +++ b/src/gui/SearchWidget.ui @@ -41,7 +41,7 @@ <string/> </property> <property name="clearButtonEnabled"> - <bool>false</bool> + <bool>true</bool> </property> </widget> </item> @@ -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> diff --git a/src/gui/styles/base/BaseStyle.cpp b/src/gui/styles/base/BaseStyle.cpp index aac9daf1c..2c72f9bcc 100644 --- a/src/gui/styles/base/BaseStyle.cpp +++ b/src/gui/styles/base/BaseStyle.cpp @@ -54,6 +54,8 @@ #include <cmath> +#include "core/Resources.h" + QT_BEGIN_NAMESPACE Q_GUI_EXPORT int qt_defaultDpiX(); QT_END_NAMESPACE @@ -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, diff --git a/src/gui/styles/base/BaseStyle.h b/src/gui/styles/base/BaseStyle.h index d6269fad7..86d81b44b 100644 --- a/src/gui/styles/base/BaseStyle.h +++ b/src/gui/styles/base/BaseStyle.h @@ -42,6 +42,8 @@ public: }; QPalette standardPalette() const override; + QIcon + standardIcon(StandardPixmap sp, const QStyleOption* opt = nullptr, const QWidget* widget = nullptr) const override; void drawPrimitive(PrimitiveElement elem, const QStyleOption* option, QPainter* painter, diff --git a/tests/gui/TestGui.cpp b/tests/gui/TestGui.cpp index d323744b6..060a29520 100644 --- a/tests/gui/TestGui.cpp +++ b/tests/gui/TestGui.cpp @@ -855,8 +855,7 @@ void TestGui::testSearch() auto* entryView = m_dbWidget->findChild<EntryView*>("entryView"); QVERIFY(entryView->isVisible()); - auto* clearButton = searchWidget->findChild<QAction*>("clearIcon"); - QVERIFY(!clearButton->isVisible()); + QVERIFY(searchTextEdit->isClearButtonEnabled()); auto* helpButton = searchWidget->findChild<QAction*>("helpIcon"); auto* helpPanel = searchWidget->findChild<QWidget*>("SearchHelpWidget"); @@ -866,7 +865,6 @@ void TestGui::testSearch() // Enter search QTest::mouseClick(searchTextEdit, Qt::LeftButton); QTRY_VERIFY(searchTextEdit->hasFocus()); - QTRY_VERIFY(!clearButton->isVisible()); // Show/Hide search help helpButton->trigger(); QTRY_VERIFY(helpPanel->isVisible()); @@ -877,14 +875,12 @@ void TestGui::testSearch() // Search for "ZZZ" QTest::keyClicks(searchTextEdit, "ZZZ"); QTRY_COMPARE(searchTextEdit->text(), QString("ZZZ")); - QTRY_VERIFY(clearButton->isVisible()); QTRY_VERIFY(m_dbWidget->isSearchActive()); QTRY_COMPARE(entryView->model()->rowCount(), 0); // Press the search clear button - clearButton->trigger(); + searchTextEdit->clear(); QTRY_VERIFY(searchTextEdit->text().isEmpty()); QTRY_VERIFY(searchTextEdit->hasFocus()); - QTRY_VERIFY(!clearButton->isVisible()); // Escape clears searchedit and retains focus QTest::keyClicks(searchTextEdit, "ZZZ"); QTest::keyClick(searchTextEdit, Qt::Key_Escape); |