Merge pull request #7570 from ameerj/favorites-expanded
game_list: Add persistent setting for the favorites row expanded state
This commit is contained in:
commit
77d06d5df0
|
@ -776,6 +776,7 @@ void Config::ReadUIGamelistValues() {
|
|||
ReadBasicSetting(UISettings::values.row_1_text_id);
|
||||
ReadBasicSetting(UISettings::values.row_2_text_id);
|
||||
ReadBasicSetting(UISettings::values.cache_game_list);
|
||||
ReadBasicSetting(UISettings::values.favorites_expanded);
|
||||
const int favorites_size = qt_config->beginReadArray(QStringLiteral("favorites"));
|
||||
for (int i = 0; i < favorites_size; i++) {
|
||||
qt_config->setArrayIndex(i);
|
||||
|
@ -1300,6 +1301,7 @@ void Config::SaveUIGamelistValues() {
|
|||
WriteBasicSetting(UISettings::values.row_1_text_id);
|
||||
WriteBasicSetting(UISettings::values.row_2_text_id);
|
||||
WriteBasicSetting(UISettings::values.cache_game_list);
|
||||
WriteBasicSetting(UISettings::values.favorites_expanded);
|
||||
qt_config->beginWriteArray(QStringLiteral("favorites"));
|
||||
for (int i = 0; i < UISettings::values.favorited_ids.size(); i++) {
|
||||
qt_config->setArrayIndex(i);
|
||||
|
|
|
@ -173,13 +173,17 @@ void GameList::OnItemExpanded(const QModelIndex& item) {
|
|||
const bool is_dir = type == GameListItemType::CustomDir || type == GameListItemType::SdmcDir ||
|
||||
type == GameListItemType::UserNandDir ||
|
||||
type == GameListItemType::SysNandDir;
|
||||
|
||||
if (!is_dir) {
|
||||
const bool is_fave = type == GameListItemType::Favorites;
|
||||
if (!is_dir && !is_fave) {
|
||||
return;
|
||||
}
|
||||
|
||||
UISettings::values.game_dirs[item.data(GameListDir::GameDirRole).toInt()].expanded =
|
||||
tree_view->isExpanded(item);
|
||||
const bool is_expanded = tree_view->isExpanded(item);
|
||||
if (is_fave) {
|
||||
UISettings::values.favorites_expanded = is_expanded;
|
||||
return;
|
||||
}
|
||||
const int item_dir_index = item.data(GameListDir::GameDirRole).toInt();
|
||||
UISettings::values.game_dirs[item_dir_index].expanded = is_expanded;
|
||||
}
|
||||
|
||||
// Event in order to filter the gamelist after editing the searchfield
|
||||
|
@ -458,10 +462,13 @@ void GameList::DonePopulating(const QStringList& watch_list) {
|
|||
emit ShowList(!IsEmpty());
|
||||
|
||||
item_model->invisibleRootItem()->appendRow(new GameListAddDir());
|
||||
|
||||
// Add favorites row
|
||||
item_model->invisibleRootItem()->insertRow(0, new GameListFavorites());
|
||||
tree_view->setRowHidden(0, item_model->invisibleRootItem()->index(),
|
||||
UISettings::values.favorited_ids.size() == 0);
|
||||
tree_view->expand(item_model->invisibleRootItem()->child(0)->index());
|
||||
tree_view->setExpanded(item_model->invisibleRootItem()->child(0)->index(),
|
||||
UISettings::values.favorites_expanded.GetValue());
|
||||
for (const auto id : UISettings::values.favorited_ids) {
|
||||
AddFavorite(id);
|
||||
}
|
||||
|
|
|
@ -74,7 +74,6 @@ struct Values {
|
|||
QString game_dir_deprecated;
|
||||
bool game_dir_deprecated_deepscan;
|
||||
QVector<UISettings::GameDir> game_dirs;
|
||||
QVector<u64> favorited_ids;
|
||||
QStringList recent_files;
|
||||
QString language;
|
||||
|
||||
|
@ -96,6 +95,8 @@ struct Values {
|
|||
Settings::BasicSetting<uint8_t> row_2_text_id{2, "row_2_text_id"};
|
||||
std::atomic_bool is_game_list_reload_pending{false};
|
||||
Settings::BasicSetting<bool> cache_game_list{true, "cache_game_list"};
|
||||
Settings::BasicSetting<bool> favorites_expanded{true, "favorites_expanded"};
|
||||
QVector<u64> favorited_ids;
|
||||
|
||||
bool configuration_applied;
|
||||
bool reset_to_defaults;
|
||||
|
|
Reference in New Issue