mirror of
https://github.com/shadps4-emu/shadPS4.git
synced 2025-12-10 05:38:49 +00:00
* Favorites in the game list (#2649) Changed how favorites are saved to match PR #2984. Adjusted the favorite icon size. Fixed bug where favorites were inconsistent when changing to list mode. Instantly sort list when adding or removing a favorite. Co-authored-by: David Antunes <david.f.antunes@tecnico.ulisboa.pt> * fix formatting * Favorites in the game list (#2649) Fixed issue where background change was inconsistent while adding favorites, unselect row when adding favorites, cleaned code, changed right click menu options to match the game's favorite status. * fixed right click bug * keep row selection when adding favorites * fixed sorting on game grid after using search bar * change the way favorites are saved to match #3119
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
#include "common/scm_rev.h"
|
||||
#include "compatibility_info.h"
|
||||
#include "game_info.h"
|
||||
#include "gui_settings.h"
|
||||
#include "trophy_viewer.h"
|
||||
|
||||
#ifdef Q_OS_WIN
|
||||
@@ -30,13 +31,13 @@
|
||||
class GuiContextMenus : public QObject {
|
||||
Q_OBJECT
|
||||
public:
|
||||
void RequestGameMenu(const QPoint& pos, QVector<GameInfo>& m_games,
|
||||
std::shared_ptr<CompatibilityInfoClass> m_compat_info,
|
||||
std::shared_ptr<gui_settings> settings, QTableWidget* widget,
|
||||
bool isList) {
|
||||
int RequestGameMenu(const QPoint& pos, QVector<GameInfo>& m_games,
|
||||
std::shared_ptr<CompatibilityInfoClass> m_compat_info,
|
||||
std::shared_ptr<gui_settings> settings, QTableWidget* widget, bool isList) {
|
||||
QPoint global_pos = widget->viewport()->mapToGlobal(pos);
|
||||
std::shared_ptr<gui_settings> m_gui_settings = std::move(settings);
|
||||
int itemID = 0;
|
||||
int changedFavorite = 0;
|
||||
if (isList) {
|
||||
itemID = widget->currentRow();
|
||||
} else {
|
||||
@@ -45,7 +46,7 @@ public:
|
||||
|
||||
// Do not show the menu if no item is selected
|
||||
if (itemID < 0 || itemID >= m_games.size()) {
|
||||
return;
|
||||
return changedFavorite;
|
||||
}
|
||||
|
||||
// Setup menu.
|
||||
@@ -65,11 +66,22 @@ public:
|
||||
|
||||
menu.addMenu(openFolderMenu);
|
||||
|
||||
QString serialStr = QString::fromStdString(m_games[itemID].serial);
|
||||
QList<QString> list = gui_settings::Var2List(m_gui_settings->GetValue(gui::favorites_list));
|
||||
bool isFavorite = list.contains(serialStr);
|
||||
QAction* toggleFavorite;
|
||||
|
||||
if (isFavorite) {
|
||||
toggleFavorite = new QAction(tr("Remove from Favorites"), widget);
|
||||
} else {
|
||||
toggleFavorite = new QAction(tr("Add to Favorites"), widget);
|
||||
}
|
||||
QAction createShortcut(tr("Create Shortcut"), widget);
|
||||
QAction openCheats(tr("Cheats / Patches"), widget);
|
||||
QAction openSfoViewer(tr("SFO Viewer"), widget);
|
||||
QAction openTrophyViewer(tr("Trophy Viewer"), widget);
|
||||
|
||||
menu.addAction(toggleFavorite);
|
||||
menu.addAction(&createShortcut);
|
||||
menu.addAction(&openCheats);
|
||||
menu.addAction(&openSfoViewer);
|
||||
@@ -130,7 +142,7 @@ public:
|
||||
// Show menu.
|
||||
auto selected = menu.exec(global_pos);
|
||||
if (!selected) {
|
||||
return;
|
||||
return changedFavorite;
|
||||
}
|
||||
|
||||
if (selected == openGameFolder) {
|
||||
@@ -303,6 +315,16 @@ public:
|
||||
}
|
||||
}
|
||||
|
||||
if (selected == toggleFavorite) {
|
||||
if (isFavorite) {
|
||||
list.removeOne(serialStr);
|
||||
} else {
|
||||
list.append(serialStr);
|
||||
}
|
||||
m_gui_settings->SetValue(gui::favorites_list, gui_settings::List2Var(list));
|
||||
changedFavorite = 1;
|
||||
}
|
||||
|
||||
if (selected == &openCheats) {
|
||||
QString gameName = QString::fromStdString(m_games[itemID].name);
|
||||
QString gameSerial = QString::fromStdString(m_games[itemID].serial);
|
||||
@@ -588,6 +610,7 @@ public:
|
||||
QUrl(url_issues + m_games[itemID].compatibility.issue_number));
|
||||
}
|
||||
}
|
||||
return changedFavorite;
|
||||
}
|
||||
|
||||
int GetRowIndex(QTreeWidget* treeWidget, QTreeWidgetItem* item) {
|
||||
|
||||
Reference in New Issue
Block a user