diff --git a/src/duckstation-qt/CMakeLists.txt b/src/duckstation-qt/CMakeLists.txt index 378dc493e..520a0585f 100644 --- a/src/duckstation-qt/CMakeLists.txt +++ b/src/duckstation-qt/CMakeLists.txt @@ -160,6 +160,8 @@ set(SRCS qtwindowinfo.cpp qtwindowinfo.h resource.h + searchbox.cpp + searchbox.h selectdiscdialog.cpp selectdiscdialog.h selectdiscdialog.ui diff --git a/src/duckstation-qt/duckstation-qt.vcxproj b/src/duckstation-qt/duckstation-qt.vcxproj index 890922a82..68a8a39cc 100644 --- a/src/duckstation-qt/duckstation-qt.vcxproj +++ b/src/duckstation-qt/duckstation-qt.vcxproj @@ -54,6 +54,7 @@ + @@ -111,6 +112,7 @@ + diff --git a/src/duckstation-qt/duckstation-qt.vcxproj.filters b/src/duckstation-qt/duckstation-qt.vcxproj.filters index a7e8da89a..76ae44b2b 100644 --- a/src/duckstation-qt/duckstation-qt.vcxproj.filters +++ b/src/duckstation-qt/duckstation-qt.vcxproj.filters @@ -58,6 +58,7 @@ + @@ -128,6 +129,7 @@ + diff --git a/src/duckstation-qt/gamecheatsettingswidget.ui b/src/duckstation-qt/gamecheatsettingswidget.ui index b92e390e8..e32bc33bc 100644 --- a/src/duckstation-qt/gamecheatsettingswidget.ui +++ b/src/duckstation-qt/gamecheatsettingswidget.ui @@ -37,28 +37,16 @@ Qt::Orientation::Horizontal - - - 40 - 20 - - - + 100 0 - - Search... - - - true - @@ -214,6 +202,13 @@ + + + SearchBox + QLineEdit +
searchbox.h
+
+
diff --git a/src/duckstation-qt/gamelistwidget.ui b/src/duckstation-qt/gamelistwidget.ui index 607196f16..d4ac455a8 100644 --- a/src/duckstation-qt/gamelistwidget.ui +++ b/src/duckstation-qt/gamelistwidget.ui @@ -225,19 +225,13 @@ - + 200 0 - - Search... - - - true - @@ -247,6 +241,13 @@ + + + SearchBox + QLineEdit +
searchbox.h
+
+
diff --git a/src/duckstation-qt/hotkeysettingswidget.cpp b/src/duckstation-qt/hotkeysettingswidget.cpp index 340eb01d0..5dbfc4dba 100644 --- a/src/duckstation-qt/hotkeysettingswidget.cpp +++ b/src/duckstation-qt/hotkeysettingswidget.cpp @@ -6,6 +6,7 @@ #include "inputbindingwidgets.h" #include "mainwindow.h" #include "qtutils.h" +#include "searchbox.h" #include "settingswindow.h" #include "settingwidgetbinder.h" @@ -14,7 +15,6 @@ #include #include #include -#include #include #include "moc_hotkeysettingswidget.cpp" @@ -30,9 +30,7 @@ HotkeySettingsWidget::~HotkeySettingsWidget() = default; HotkeySettingsWidget::Container::Container(QWidget* parent) : QWidget(parent) { - m_search = new QLineEdit(this); - m_search->setPlaceholderText(tr("Search...")); - m_search->setClearButtonEnabled(true); + m_search = new SearchBox(this); } HotkeySettingsWidget::Container::~Container() = default; diff --git a/src/duckstation-qt/postprocessingselectshaderdialog.ui b/src/duckstation-qt/postprocessingselectshaderdialog.ui index 149cf4724..c61a40a08 100644 --- a/src/duckstation-qt/postprocessingselectshaderdialog.ui +++ b/src/duckstation-qt/postprocessingselectshaderdialog.ui @@ -27,11 +27,7 @@ - - - Search... - - + @@ -106,6 +102,13 @@ + + + SearchBox + QLineEdit +
searchbox.h
+
+
diff --git a/src/duckstation-qt/searchbox.cpp b/src/duckstation-qt/searchbox.cpp new file mode 100644 index 000000000..6684a86e4 --- /dev/null +++ b/src/duckstation-qt/searchbox.cpp @@ -0,0 +1,24 @@ +// SPDX-FileCopyrightText: 2019-2026 Connor McLaughlin and contributors. +// SPDX-License-Identifier: CC-BY-NC-ND-4.0 + +#include "searchbox.h" + +#include + +#include "moc_searchbox.cpp" + +SearchBox::SearchBox(QWidget* parent) : QLineEdit(parent) +{ + setClearButtonEnabled(true); + setPlaceholderText(tr("Search...")); +} + +SearchBox::~SearchBox() = default; + +void SearchBox::keyPressEvent(QKeyEvent* event) +{ + if (event->key() == Qt::Key_Escape && !text().isEmpty()) + clear(); + else + QLineEdit::keyPressEvent(event); +} diff --git a/src/duckstation-qt/searchbox.h b/src/duckstation-qt/searchbox.h new file mode 100644 index 000000000..b56148666 --- /dev/null +++ b/src/duckstation-qt/searchbox.h @@ -0,0 +1,18 @@ +// SPDX-FileCopyrightText: 2019-2026 Connor McLaughlin and contributors. +// SPDX-License-Identifier: CC-BY-NC-ND-4.0 + +#pragma once + +#include + +class SearchBox final : public QLineEdit +{ + Q_OBJECT + +public: + explicit SearchBox(QWidget* parent = nullptr); + ~SearchBox() override; + +protected: + void keyPressEvent(QKeyEvent* event) override; +};