diff options
| author | 2021-12-17 16:09:05 -0800 | |
|---|---|---|
| committer | 2021-12-17 16:09:05 -0800 | |
| commit | 77d06d5df02d18da381bcd572ce11fee790d9edf (patch) | |
| tree | 90660425aa1c928a09a53693e529fef861aa4991 | |
| parent | Merge pull request #7532 from goldenx86/patch-3 (diff) | |
| parent | game_list: Add persistent setting for the favorites row expanded state (diff) | |
| download | yuzu-77d06d5df02d18da381bcd572ce11fee790d9edf.tar.gz yuzu-77d06d5df02d18da381bcd572ce11fee790d9edf.tar.xz yuzu-77d06d5df02d18da381bcd572ce11fee790d9edf.zip | |
Merge pull request #7570 from ameerj/favorites-expanded
game_list: Add persistent setting for the favorites row expanded state
| -rw-r--r-- | src/yuzu/configuration/config.cpp | 2 | ||||
| -rw-r--r-- | src/yuzu/game_list.cpp | 19 | ||||
| -rw-r--r-- | src/yuzu/uisettings.h | 3 |
3 files changed, 17 insertions, 7 deletions
diff --git a/src/yuzu/configuration/config.cpp b/src/yuzu/configuration/config.cpp index 463d500c2..0f679c37e 100644 --- a/src/yuzu/configuration/config.cpp +++ b/src/yuzu/configuration/config.cpp | |||
| @@ -776,6 +776,7 @@ void Config::ReadUIGamelistValues() { | |||
| 776 | ReadBasicSetting(UISettings::values.row_1_text_id); | 776 | ReadBasicSetting(UISettings::values.row_1_text_id); |
| 777 | ReadBasicSetting(UISettings::values.row_2_text_id); | 777 | ReadBasicSetting(UISettings::values.row_2_text_id); |
| 778 | ReadBasicSetting(UISettings::values.cache_game_list); | 778 | ReadBasicSetting(UISettings::values.cache_game_list); |
| 779 | ReadBasicSetting(UISettings::values.favorites_expanded); | ||
| 779 | const int favorites_size = qt_config->beginReadArray(QStringLiteral("favorites")); | 780 | const int favorites_size = qt_config->beginReadArray(QStringLiteral("favorites")); |
| 780 | for (int i = 0; i < favorites_size; i++) { | 781 | for (int i = 0; i < favorites_size; i++) { |
| 781 | qt_config->setArrayIndex(i); | 782 | qt_config->setArrayIndex(i); |
| @@ -1300,6 +1301,7 @@ void Config::SaveUIGamelistValues() { | |||
| 1300 | WriteBasicSetting(UISettings::values.row_1_text_id); | 1301 | WriteBasicSetting(UISettings::values.row_1_text_id); |
| 1301 | WriteBasicSetting(UISettings::values.row_2_text_id); | 1302 | WriteBasicSetting(UISettings::values.row_2_text_id); |
| 1302 | WriteBasicSetting(UISettings::values.cache_game_list); | 1303 | WriteBasicSetting(UISettings::values.cache_game_list); |
| 1304 | WriteBasicSetting(UISettings::values.favorites_expanded); | ||
| 1303 | qt_config->beginWriteArray(QStringLiteral("favorites")); | 1305 | qt_config->beginWriteArray(QStringLiteral("favorites")); |
| 1304 | for (int i = 0; i < UISettings::values.favorited_ids.size(); i++) { | 1306 | for (int i = 0; i < UISettings::values.favorited_ids.size(); i++) { |
| 1305 | qt_config->setArrayIndex(i); | 1307 | qt_config->setArrayIndex(i); |
diff --git a/src/yuzu/game_list.cpp b/src/yuzu/game_list.cpp index 1a5e41588..8b5c4a10a 100644 --- a/src/yuzu/game_list.cpp +++ b/src/yuzu/game_list.cpp | |||
| @@ -173,13 +173,17 @@ void GameList::OnItemExpanded(const QModelIndex& item) { | |||
| 173 | const bool is_dir = type == GameListItemType::CustomDir || type == GameListItemType::SdmcDir || | 173 | const bool is_dir = type == GameListItemType::CustomDir || type == GameListItemType::SdmcDir || |
| 174 | type == GameListItemType::UserNandDir || | 174 | type == GameListItemType::UserNandDir || |
| 175 | type == GameListItemType::SysNandDir; | 175 | type == GameListItemType::SysNandDir; |
| 176 | 176 | const bool is_fave = type == GameListItemType::Favorites; | |
| 177 | if (!is_dir) { | 177 | if (!is_dir && !is_fave) { |
| 178 | return; | 178 | return; |
| 179 | } | 179 | } |
| 180 | 180 | const bool is_expanded = tree_view->isExpanded(item); | |
| 181 | UISettings::values.game_dirs[item.data(GameListDir::GameDirRole).toInt()].expanded = | 181 | if (is_fave) { |
| 182 | tree_view->isExpanded(item); | 182 | UISettings::values.favorites_expanded = is_expanded; |
| 183 | return; | ||
| 184 | } | ||
| 185 | const int item_dir_index = item.data(GameListDir::GameDirRole).toInt(); | ||
| 186 | UISettings::values.game_dirs[item_dir_index].expanded = is_expanded; | ||
| 183 | } | 187 | } |
| 184 | 188 | ||
| 185 | // Event in order to filter the gamelist after editing the searchfield | 189 | // Event in order to filter the gamelist after editing the searchfield |
| @@ -458,10 +462,13 @@ void GameList::DonePopulating(const QStringList& watch_list) { | |||
| 458 | emit ShowList(!IsEmpty()); | 462 | emit ShowList(!IsEmpty()); |
| 459 | 463 | ||
| 460 | item_model->invisibleRootItem()->appendRow(new GameListAddDir()); | 464 | item_model->invisibleRootItem()->appendRow(new GameListAddDir()); |
| 465 | |||
| 466 | // Add favorites row | ||
| 461 | item_model->invisibleRootItem()->insertRow(0, new GameListFavorites()); | 467 | item_model->invisibleRootItem()->insertRow(0, new GameListFavorites()); |
| 462 | tree_view->setRowHidden(0, item_model->invisibleRootItem()->index(), | 468 | tree_view->setRowHidden(0, item_model->invisibleRootItem()->index(), |
| 463 | UISettings::values.favorited_ids.size() == 0); | 469 | UISettings::values.favorited_ids.size() == 0); |
| 464 | tree_view->expand(item_model->invisibleRootItem()->child(0)->index()); | 470 | tree_view->setExpanded(item_model->invisibleRootItem()->child(0)->index(), |
| 471 | UISettings::values.favorites_expanded.GetValue()); | ||
| 465 | for (const auto id : UISettings::values.favorited_ids) { | 472 | for (const auto id : UISettings::values.favorited_ids) { |
| 466 | AddFavorite(id); | 473 | AddFavorite(id); |
| 467 | } | 474 | } |
diff --git a/src/yuzu/uisettings.h b/src/yuzu/uisettings.h index 936914ef3..a610e7e25 100644 --- a/src/yuzu/uisettings.h +++ b/src/yuzu/uisettings.h | |||
| @@ -74,7 +74,6 @@ struct Values { | |||
| 74 | QString game_dir_deprecated; | 74 | QString game_dir_deprecated; |
| 75 | bool game_dir_deprecated_deepscan; | 75 | bool game_dir_deprecated_deepscan; |
| 76 | QVector<UISettings::GameDir> game_dirs; | 76 | QVector<UISettings::GameDir> game_dirs; |
| 77 | QVector<u64> favorited_ids; | ||
| 78 | QStringList recent_files; | 77 | QStringList recent_files; |
| 79 | QString language; | 78 | QString language; |
| 80 | 79 | ||
| @@ -96,6 +95,8 @@ struct Values { | |||
| 96 | Settings::BasicSetting<uint8_t> row_2_text_id{2, "row_2_text_id"}; | 95 | Settings::BasicSetting<uint8_t> row_2_text_id{2, "row_2_text_id"}; |
| 97 | std::atomic_bool is_game_list_reload_pending{false}; | 96 | std::atomic_bool is_game_list_reload_pending{false}; |
| 98 | Settings::BasicSetting<bool> cache_game_list{true, "cache_game_list"}; | 97 | Settings::BasicSetting<bool> cache_game_list{true, "cache_game_list"}; |
| 98 | Settings::BasicSetting<bool> favorites_expanded{true, "favorites_expanded"}; | ||
| 99 | QVector<u64> favorited_ids; | ||
| 99 | 100 | ||
| 100 | bool configuration_applied; | 101 | bool configuration_applied; |
| 101 | bool reset_to_defaults; | 102 | bool reset_to_defaults; |