mirror of
https://github.com/keepassxreboot/keepassxc.git
synced 2024-10-01 01:26:01 -04:00
Changed built-in clear search button with custom one to fix pixelation
This commit is contained in:
parent
39e0708b3b
commit
b6f754c29a
@ -34,7 +34,9 @@ SearchWidget::SearchWidget(QWidget *parent)
|
||||
m_searchTimer->setSingleShot(true);
|
||||
|
||||
connect(m_ui->searchEdit, SIGNAL(textChanged(QString)), SLOT(startSearchTimer()));
|
||||
connect(m_ui->searchIcon, SIGNAL(triggered(QAction*)), m_ui->searchEdit, SLOT(setFocus()));
|
||||
connect(m_ui->searchIcon, SIGNAL(pressed()), m_ui->searchEdit, SLOT(setFocus()));
|
||||
connect(m_ui->clearIcon, SIGNAL(pressed()), m_ui->searchEdit, SLOT(clear()));
|
||||
connect(m_ui->clearIcon, SIGNAL(pressed()), m_ui->searchEdit, SLOT(setFocus()));
|
||||
connect(m_searchTimer, SIGNAL(timeout()), this, SLOT(startSearch()));
|
||||
connect(this, SIGNAL(escapePressed()), m_ui->searchEdit, SLOT(clear()));
|
||||
|
||||
@ -50,6 +52,9 @@ SearchWidget::SearchWidget(QWidget *parent)
|
||||
m_ui->searchIcon->setIcon(filePath()->icon("actions", "system-search"));
|
||||
m_ui->searchIcon->setMenu(searchMenu);
|
||||
m_ui->searchIcon->setPopupMode(QToolButton::MenuButtonPopup);
|
||||
|
||||
m_ui->clearIcon->setIcon(filePath()->icon("actions", "edit-clear-locationbar-rtl"));
|
||||
m_ui->clearIcon->setEnabled(false);
|
||||
}
|
||||
|
||||
SearchWidget::~SearchWidget()
|
||||
@ -126,6 +131,9 @@ void SearchWidget::startSearch()
|
||||
m_searchTimer->stop();
|
||||
}
|
||||
|
||||
bool hasText = m_ui->searchEdit->text().length() > 0;
|
||||
m_ui->clearIcon->setEnabled(hasText);
|
||||
|
||||
search(m_ui->searchEdit->text());
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,22 @@
|
||||
<string>Find</string>
|
||||
</property>
|
||||
<property name="clearButtonEnabled">
|
||||
<bool>false</bool>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="clearIcon">
|
||||
<property name="focusPolicy">
|
||||
<enum>Qt::ClickFocus</enum>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string>Clear</string>
|
||||
</property>
|
||||
<property name="toolButtonStyle">
|
||||
<enum>Qt::ToolButtonIconOnly</enum>
|
||||
</property>
|
||||
<property name="autoRaise">
|
||||
<bool>true</bool>
|
||||
</property>
|
||||
</widget>
|
||||
|
@ -401,7 +401,13 @@ void TestGui::testSearch()
|
||||
QTRY_COMPARE(searchTextEdit->text(), QString("ZZZ"));
|
||||
QTRY_VERIFY(m_dbWidget->isInSearchMode());
|
||||
QTRY_COMPARE(entryView->model()->rowCount(), 0);
|
||||
// Press the search clear button
|
||||
QToolButton* clearButton = searchWidget->findChild<QToolButton*>("clearIcon");
|
||||
QTest::mouseClick(clearButton, Qt::LeftButton);
|
||||
QTRY_VERIFY(searchTextEdit->text().isEmpty());
|
||||
QTRY_VERIFY(searchTextEdit->hasFocus());
|
||||
// Escape clears searchedit and retains focus
|
||||
QTest::keyClicks(searchTextEdit, "ZZZ");
|
||||
QTest::keyClick(searchTextEdit, Qt::Key_Escape);
|
||||
QTRY_VERIFY(searchTextEdit->text().isEmpty());
|
||||
QTRY_VERIFY(searchTextEdit->hasFocus());
|
||||
|
Loading…
Reference in New Issue
Block a user