diff options
| -rw-r--r-- | src/yuzu/game_list.cpp | 14 | ||||
| -rw-r--r-- | src/yuzu/game_list.h | 32 | ||||
| -rw-r--r-- | src/yuzu/game_list_p.h | 40 |
3 files changed, 51 insertions, 35 deletions
diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp index e8b2f720a..ffe0b84c1 100644 --- a/src/yuzu/game_list.cpp +++ b/src/yuzu/game_list.cpp | |||
| @@ -26,10 +26,10 @@ | |||
| 26 | #include "yuzu/main.h" | 26 | #include "yuzu/main.h" |
| 27 | #include "yuzu/ui_settings.h" | 27 | #include "yuzu/ui_settings.h" |
| 28 | 28 | ||
| 29 | GameList::SearchField::KeyReleaseEater::KeyReleaseEater(GameList* gamelist) : gamelist{gamelist} {} | 29 | GameListSearchField::KeyReleaseEater::KeyReleaseEater(GameList* gamelist) : gamelist{gamelist} {} |
| 30 | 30 | ||
| 31 | // EventFilter in order to process systemkeys while editing the searchfield | 31 | // EventFilter in order to process systemkeys while editing the searchfield |
| 32 | bool GameList::SearchField::KeyReleaseEater::eventFilter(QObject* obj, QEvent* event) { | 32 | bool GameListSearchField::KeyReleaseEater::eventFilter(QObject* obj, QEvent* event) { |
| 33 | // If it isn't a KeyRelease event then continue with standard event processing | 33 | // If it isn't a KeyRelease event then continue with standard event processing |
| 34 | if (event->type() != QEvent::KeyRelease) | 34 | if (event->type() != QEvent::KeyRelease) |
| 35 | return QObject::eventFilter(obj, event); | 35 | return QObject::eventFilter(obj, event); |
| @@ -88,21 +88,21 @@ bool GameList::SearchField::KeyReleaseEater::eventFilter(QObject* obj, QEvent* e | |||
| 88 | return QObject::eventFilter(obj, event); | 88 | return QObject::eventFilter(obj, event); |
| 89 | } | 89 | } |
| 90 | 90 | ||
| 91 | void GameList::SearchField::setFilterResult(int visible, int total) { | 91 | void GameListSearchField::setFilterResult(int visible, int total) { |
| 92 | label_filter_result->setText(tr("%1 of %n result(s)", "", total).arg(visible)); | 92 | label_filter_result->setText(tr("%1 of %n result(s)", "", total).arg(visible)); |
| 93 | } | 93 | } |
| 94 | 94 | ||
| 95 | void GameList::SearchField::clear() { | 95 | void GameListSearchField::clear() { |
| 96 | edit_filter->setText(""); | 96 | edit_filter->setText(""); |
| 97 | } | 97 | } |
| 98 | 98 | ||
| 99 | void GameList::SearchField::setFocus() { | 99 | void GameListSearchField::setFocus() { |
| 100 | if (edit_filter->isVisible()) { | 100 | if (edit_filter->isVisible()) { |
| 101 | edit_filter->setFocus(); | 101 | edit_filter->setFocus(); |
| 102 | } | 102 | } |
| 103 | } | 103 | } |
| 104 | 104 | ||
| 105 | GameList::SearchField::SearchField(GameList* parent) : QWidget{parent} { | 105 | GameListSearchField::GameListSearchField(GameList* parent) : QWidget{parent} { |
| 106 | KeyReleaseEater* keyReleaseEater = new KeyReleaseEater(parent); | 106 | KeyReleaseEater* keyReleaseEater = new KeyReleaseEater(parent); |
| 107 | layout_filter = new QHBoxLayout; | 107 | layout_filter = new QHBoxLayout; |
| 108 | layout_filter->setMargin(8); | 108 | layout_filter->setMargin(8); |
| @@ -202,7 +202,7 @@ GameList::GameList(FileSys::VirtualFilesystem vfs, GMainWindow* parent) | |||
| 202 | this->main_window = parent; | 202 | this->main_window = parent; |
| 203 | layout = new QVBoxLayout; | 203 | layout = new QVBoxLayout; |
| 204 | tree_view = new QTreeView; | 204 | tree_view = new QTreeView; |
| 205 | search_field = new SearchField(this); | 205 | search_field = new GameListSearchField(this); |
| 206 | item_model = new QStandardItemModel(tree_view); | 206 | item_model = new QStandardItemModel(tree_view); |
| 207 | tree_view->setModel(item_model); | 207 | tree_view->setModel(item_model); |
| 208 | 208 | ||
diff --git a/src/yuzu/game_list.h b/src/yuzu/game_list.h index 2713e7b54..ba7921bdb 100644 --- a/src/yuzu/game_list.h +++ b/src/yuzu/game_list.h | |||
| @@ -22,6 +22,7 @@ | |||
| 22 | #include "yuzu/compatibility_list.h" | 22 | #include "yuzu/compatibility_list.h" |
| 23 | 23 | ||
| 24 | class GameListWorker; | 24 | class GameListWorker; |
| 25 | class GameListSearchField; | ||
| 25 | class GMainWindow; | 26 | class GMainWindow; |
| 26 | 27 | ||
| 27 | namespace FileSys { | 28 | namespace FileSys { |
| @@ -43,33 +44,6 @@ public: | |||
| 43 | COLUMN_COUNT, // Number of columns | 44 | COLUMN_COUNT, // Number of columns |
| 44 | }; | 45 | }; |
| 45 | 46 | ||
| 46 | class SearchField : public QWidget { | ||
| 47 | public: | ||
| 48 | void setFilterResult(int visible, int total); | ||
| 49 | void clear(); | ||
| 50 | void setFocus(); | ||
| 51 | explicit SearchField(GameList* parent = nullptr); | ||
| 52 | |||
| 53 | private: | ||
| 54 | class KeyReleaseEater : public QObject { | ||
| 55 | public: | ||
| 56 | explicit KeyReleaseEater(GameList* gamelist); | ||
| 57 | |||
| 58 | private: | ||
| 59 | GameList* gamelist = nullptr; | ||
| 60 | QString edit_filter_text_old; | ||
| 61 | |||
| 62 | protected: | ||
| 63 | bool eventFilter(QObject* obj, QEvent* event) override; | ||
| 64 | }; | ||
| 65 | QHBoxLayout* layout_filter = nullptr; | ||
| 66 | QTreeView* tree_view = nullptr; | ||
| 67 | QLabel* label_filter = nullptr; | ||
| 68 | QLineEdit* edit_filter = nullptr; | ||
| 69 | QLabel* label_filter_result = nullptr; | ||
| 70 | QToolButton* button_filter_close = nullptr; | ||
| 71 | }; | ||
| 72 | |||
| 73 | explicit GameList(std::shared_ptr<FileSys::VfsFilesystem> vfs, GMainWindow* parent = nullptr); | 47 | explicit GameList(std::shared_ptr<FileSys::VfsFilesystem> vfs, GMainWindow* parent = nullptr); |
| 74 | ~GameList() override; | 48 | ~GameList() override; |
| 75 | 49 | ||
| @@ -105,7 +79,7 @@ private: | |||
| 105 | void RefreshGameDirectory(); | 79 | void RefreshGameDirectory(); |
| 106 | 80 | ||
| 107 | std::shared_ptr<FileSys::VfsFilesystem> vfs; | 81 | std::shared_ptr<FileSys::VfsFilesystem> vfs; |
| 108 | SearchField* search_field; | 82 | GameListSearchField* search_field; |
| 109 | GMainWindow* main_window = nullptr; | 83 | GMainWindow* main_window = nullptr; |
| 110 | QVBoxLayout* layout = nullptr; | 84 | QVBoxLayout* layout = nullptr; |
| 111 | QTreeView* tree_view = nullptr; | 85 | QTreeView* tree_view = nullptr; |
| @@ -113,6 +87,8 @@ private: | |||
| 113 | GameListWorker* current_worker = nullptr; | 87 | GameListWorker* current_worker = nullptr; |
| 114 | QFileSystemWatcher* watcher = nullptr; | 88 | QFileSystemWatcher* watcher = nullptr; |
| 115 | CompatibilityList compatibility_list; | 89 | CompatibilityList compatibility_list; |
| 90 | |||
| 91 | friend class GameListSearchField; | ||
| 116 | }; | 92 | }; |
| 117 | 93 | ||
| 118 | Q_DECLARE_METATYPE(GameListOpenTarget); | 94 | Q_DECLARE_METATYPE(GameListOpenTarget); |
diff --git a/src/yuzu/game_list_p.h b/src/yuzu/game_list_p.h index b6272d536..7c0c47346 100644 --- a/src/yuzu/game_list_p.h +++ b/src/yuzu/game_list_p.h | |||
| @@ -16,6 +16,7 @@ | |||
| 16 | #include <QObject> | 16 | #include <QObject> |
| 17 | #include <QStandardItem> | 17 | #include <QStandardItem> |
| 18 | #include <QString> | 18 | #include <QString> |
| 19 | #include <QWidget> | ||
| 19 | 20 | ||
| 20 | #include "common/common_types.h" | 21 | #include "common/common_types.h" |
| 21 | #include "common/logging/log.h" | 22 | #include "common/logging/log.h" |
| @@ -176,3 +177,42 @@ public: | |||
| 176 | return data(SizeRole).toULongLong() < other.data(SizeRole).toULongLong(); | 177 | return data(SizeRole).toULongLong() < other.data(SizeRole).toULongLong(); |
| 177 | } | 178 | } |
| 178 | }; | 179 | }; |
| 180 | |||
| 181 | class GameList; | ||
| 182 | class QHBoxLayout; | ||
| 183 | class QTreeView; | ||
| 184 | class QLabel; | ||
| 185 | class QLineEdit; | ||
| 186 | class QToolButton; | ||
| 187 | |||
| 188 | class GameListSearchField : public QWidget { | ||
| 189 | Q_OBJECT | ||
| 190 | |||
| 191 | public: | ||
| 192 | explicit GameListSearchField(GameList* parent = nullptr); | ||
| 193 | |||
| 194 | void setFilterResult(int visible, int total); | ||
| 195 | |||
| 196 | void clear(); | ||
| 197 | void setFocus(); | ||
| 198 | |||
| 199 | private: | ||
| 200 | class KeyReleaseEater : public QObject { | ||
| 201 | public: | ||
| 202 | explicit KeyReleaseEater(GameList* gamelist); | ||
| 203 | |||
| 204 | private: | ||
| 205 | GameList* gamelist = nullptr; | ||
| 206 | QString edit_filter_text_old; | ||
| 207 | |||
| 208 | protected: | ||
| 209 | // EventFilter in order to process systemkeys while editing the searchfield | ||
| 210 | bool eventFilter(QObject* obj, QEvent* event) override; | ||
| 211 | }; | ||
| 212 | QHBoxLayout* layout_filter = nullptr; | ||
| 213 | QTreeView* tree_view = nullptr; | ||
| 214 | QLabel* label_filter = nullptr; | ||
| 215 | QLineEdit* edit_filter = nullptr; | ||
| 216 | QLabel* label_filter_result = nullptr; | ||
| 217 | QToolButton* button_filter_close = nullptr; | ||
| 218 | }; | ||