Skip to content

Commit 36642e2

Browse files
committed
GameList: Address review feedback - rename SetGameFavorite to SaveFavoriteForPath and remove unused getter
1 parent aa00926 commit 36642e2

4 files changed

Lines changed: 26 additions & 38 deletions

File tree

pcsx2-qt/GameList/GameListWidget.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,8 +200,7 @@ namespace
200200
}
201201

202202
// Draw star overlay on bottom-right corner if game is favorited.
203-
const bool is_favorite = (index.column() == GameListModel::Column_Cover) &&
204-
index.data(GameListModel::NeedsFavoriteBadgeRole).toBool();
203+
const bool is_favorite = index.data(GameListModel::NeedsFavoriteBadgeRole).toBool();
205204
if (is_favorite)
206205
{
207206
const auto* sort_model = static_cast<const QSortFilterProxyModel*>(index.model());

pcsx2-qt/MainWindow.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1556,7 +1556,7 @@ void MainWindow::onGameListEntryContextMenuRequested(const QPoint& point)
15561556
const bool is_favorite = entry->is_favorite;
15571557
action = menu.addAction(is_favorite ? tr("Remove from Favorites") : tr("Add to Favorites"));
15581558
connect(action, &QAction::triggered, [this, entry]() {
1559-
GameList::SetGameFavorite(entry->path, !entry->is_favorite);
1559+
GameList::SaveFavoriteForPath(entry->path, !entry->is_favorite);
15601560
m_game_list_widget->refresh(false, false);
15611561
});
15621562

pcsx2/GameList.cpp

Lines changed: 23 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1462,39 +1462,6 @@ std::string GameList::GetCustomPropertiesFile()
14621462
return Path::Combine(EmuFolders::Settings, "custom_properties.ini");
14631463
}
14641464

1465-
bool GameList::IsGameFavorited(const std::string& path)
1466-
{
1467-
std::unique_lock lock(s_mutex);
1468-
const GameList::Entry* entry = GetEntryForPath(path.c_str());
1469-
if (entry)
1470-
return entry->is_favorite;
1471-
1472-
return false;
1473-
}
1474-
1475-
void GameList::SetGameFavorite(const std::string& path, bool favorite)
1476-
{
1477-
INISettingsInterface custom_attributes(GetCustomPropertiesFile());
1478-
custom_attributes.Load();
1479-
1480-
if (favorite)
1481-
{
1482-
custom_attributes.SetBoolValue(path.c_str(), "Favorited", true);
1483-
}
1484-
else
1485-
{
1486-
custom_attributes.DeleteValue(path.c_str(), "Favorited");
1487-
}
1488-
1489-
if (custom_attributes.Save())
1490-
{
1491-
std::unique_lock lock(s_mutex);
1492-
GameList::Entry* entry = const_cast<GameList::Entry*>(GetEntryForPath(path.c_str()));
1493-
if (entry)
1494-
entry->is_favorite = favorite;
1495-
}
1496-
}
1497-
14981465
void GameList::CheckCustomAttributesForPath(const std::string& path, bool& has_custom_title, bool& has_custom_region)
14991466
{
15001467
INISettingsInterface names(GetCustomPropertiesFile());
@@ -1547,6 +1514,29 @@ void GameList::SaveCustomRegionForPath(const std::string& path, int custom_regio
15471514
}
15481515
}
15491516

1517+
void GameList::SaveFavoriteForPath(const std::string& path, bool favorite)
1518+
{
1519+
INISettingsInterface custom_attributes(GetCustomPropertiesFile());
1520+
custom_attributes.Load();
1521+
1522+
if (favorite)
1523+
{
1524+
custom_attributes.SetBoolValue(path.c_str(), "Favorited", true);
1525+
}
1526+
else
1527+
{
1528+
custom_attributes.DeleteValue(path.c_str(), "Favorited");
1529+
}
1530+
1531+
if (custom_attributes.Save())
1532+
{
1533+
std::unique_lock lock(s_mutex);
1534+
GameList::Entry* entry = const_cast<GameList::Entry*>(GetEntryForPath(path.c_str()));
1535+
if (entry)
1536+
entry->is_favorite = favorite;
1537+
}
1538+
}
1539+
15501540
std::string GameList::GetCustomTitleForPath(const std::string& path)
15511541
{
15521542
std::string ret;

pcsx2/GameList.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,10 +158,9 @@ namespace GameList
158158
std::function<void(const Entry*, std::string)> save_callback = {});
159159

160160
// Custom properties support
161-
bool IsGameFavorited(const std::string& path);
162-
void SetGameFavorite(const std::string& path, bool favorite);
163161
void CheckCustomAttributesForPath(const std::string& path, bool& has_custom_title, bool& has_custom_region);
164162
void SaveCustomTitleForPath(const std::string& path, const std::string& custom_title);
165163
void SaveCustomRegionForPath(const std::string& path, int custom_region);
164+
void SaveFavoriteForPath(const std::string& path, bool favorite);
166165
std::string GetCustomTitleForPath(const std::string& path);
167166
} // namespace GameList

0 commit comments

Comments
 (0)