diff options
Diffstat (limited to 'src')
| -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 991ae10cd..67890455a 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 3bf51870e..05e115e19 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 { |
| @@ -46,33 +47,6 @@ public: | |||
| 46 | COLUMN_COUNT, // Number of columns | 47 | COLUMN_COUNT, // Number of columns |
| 47 | }; | 48 | }; |
| 48 | 49 | ||
| 49 | class SearchField : public QWidget { | ||
| 50 | public: | ||
| 51 | void setFilterResult(int visible, int total); | ||
| 52 | void clear(); | ||
| 53 | void setFocus(); | ||
| 54 | explicit SearchField(GameList* parent = nullptr); | ||
| 55 | |||
| 56 | private: | ||
| 57 | class KeyReleaseEater : public QObject { | ||
| 58 | public: | ||
| 59 | explicit KeyReleaseEater(GameList* gamelist); | ||
| 60 | |||
| 61 | private: | ||
| 62 | GameList* gamelist = nullptr; | ||
| 63 | QString edit_filter_text_old; | ||
| 64 | |||
| 65 | protected: | ||
| 66 | bool eventFilter(QObject* obj, QEvent* event) override; | ||
| 67 | }; | ||
| 68 | QHBoxLayout* layout_filter = nullptr; | ||
| 69 | QTreeView* tree_view = nullptr; | ||
| 70 | QLabel* label_filter = nullptr; | ||
| 71 | QLineEdit* edit_filter = nullptr; | ||
| 72 | QLabel* label_filter_result = nullptr; | ||
| 73 | QToolButton* button_filter_close = nullptr; | ||
| 74 | }; | ||
| 75 | |||
| 76 | explicit GameList(std::shared_ptr<FileSys::VfsFilesystem> vfs, GMainWindow* parent = nullptr); | 50 | explicit GameList(std::shared_ptr<FileSys::VfsFilesystem> vfs, GMainWindow* parent = nullptr); |
| 77 | ~GameList() override; | 51 | ~GameList() override; |
| 78 | 52 | ||
| @@ -110,7 +84,7 @@ private: | |||
| 110 | void RefreshGameDirectory(); | 84 | void RefreshGameDirectory(); |
| 111 | 85 | ||
| 112 | std::shared_ptr<FileSys::VfsFilesystem> vfs; | 86 | std::shared_ptr<FileSys::VfsFilesystem> vfs; |
| 113 | SearchField* search_field; | 87 | GameListSearchField* search_field; |
| 114 | GMainWindow* main_window = nullptr; | 88 | GMainWindow* main_window = nullptr; |
| 115 | QVBoxLayout* layout = nullptr; | 89 | QVBoxLayout* layout = nullptr; |
| 116 | QTreeView* tree_view = nullptr; | 90 | QTreeView* tree_view = nullptr; |
| @@ -118,6 +92,8 @@ private: | |||
| 118 | GameListWorker* current_worker = nullptr; | 92 | GameListWorker* current_worker = nullptr; |
| 119 | QFileSystemWatcher* watcher = nullptr; | 93 | QFileSystemWatcher* watcher = nullptr; |
| 120 | CompatibilityList compatibility_list; | 94 | CompatibilityList compatibility_list; |
| 95 | |||
| 96 | friend class GameListSearchField; | ||
| 121 | }; | 97 | }; |
| 122 | 98 | ||
| 123 | Q_DECLARE_METATYPE(GameListOpenTarget); | 99 | Q_DECLARE_METATYPE(GameListOpenTarget); |
diff --git a/src/yuzu/game_list_p.h b/src/yuzu/game_list_p.h index cee109730..3db0e90da 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 | }; | ||