fixed right click bug

This commit is contained in:
David Antunes 2025-06-16 19:15:02 +01:00
parent a8d0b0b210
commit aed2e0e024
2 changed files with 12 additions and 9 deletions

View File

@ -80,9 +80,10 @@ GameListFrame::GameListFrame(std::shared_ptr<gui_settings> gui_settings,
}); });
connect(this, &QTableWidget::customContextMenuRequested, this, [=, this](const QPoint& pos) { connect(this, &QTableWidget::customContextMenuRequested, this, [=, this](const QPoint& pos) {
m_gui_context_menus.RequestGameMenu(pos, m_game_info->m_games, m_compat_info, int changedFavorite = m_gui_context_menus.RequestGameMenu(
m_gui_settings, this, true); pos, m_game_info->m_games, m_compat_info, m_gui_settings, this, true);
PopulateGameList(false); if (changedFavorite)
PopulateGameList(false);
}); });
connect(this, &QTableWidget::cellClicked, this, [=, this](int row, int column) { connect(this, &QTableWidget::cellClicked, this, [=, this](int row, int column) {

View File

@ -31,13 +31,13 @@
class GuiContextMenus : public QObject { class GuiContextMenus : public QObject {
Q_OBJECT Q_OBJECT
public: public:
void RequestGameMenu(const QPoint& pos, QVector<GameInfo>& m_games, int RequestGameMenu(const QPoint& pos, QVector<GameInfo>& m_games,
std::shared_ptr<CompatibilityInfoClass> m_compat_info, std::shared_ptr<CompatibilityInfoClass> m_compat_info,
std::shared_ptr<gui_settings> settings, QTableWidget* widget, std::shared_ptr<gui_settings> settings, QTableWidget* widget, bool isList) {
bool isList) {
QPoint global_pos = widget->viewport()->mapToGlobal(pos); QPoint global_pos = widget->viewport()->mapToGlobal(pos);
std::shared_ptr<gui_settings> m_gui_settings = std::move(settings); std::shared_ptr<gui_settings> m_gui_settings = std::move(settings);
int itemID = 0; int itemID = 0;
int changedFavorite = 0;
if (isList) { if (isList) {
itemID = widget->currentRow(); itemID = widget->currentRow();
} else { } else {
@ -46,7 +46,7 @@ public:
// Do not show the menu if no item is selected // Do not show the menu if no item is selected
if (itemID < 0 || itemID >= m_games.size()) { if (itemID < 0 || itemID >= m_games.size()) {
return; return changedFavorite;
} }
// Setup menu. // Setup menu.
@ -142,7 +142,7 @@ public:
// Show menu. // Show menu.
auto selected = menu.exec(global_pos); auto selected = menu.exec(global_pos);
if (!selected) { if (!selected) {
return; return changedFavorite;
} }
if (selected == openGameFolder) { if (selected == openGameFolder) {
@ -318,6 +318,7 @@ public:
if (selected == toggleFavorite) { if (selected == toggleFavorite) {
m_gui_settings->SetValue(gui::favorites, serialStr, !isFavorite, true); m_gui_settings->SetValue(gui::favorites, serialStr, !isFavorite, true);
widget->setCurrentCell(-1, -1); widget->setCurrentCell(-1, -1);
changedFavorite = 1;
} }
if (selected == &openCheats) { if (selected == &openCheats) {
@ -605,6 +606,7 @@ public:
QUrl(url_issues + m_games[itemID].compatibility.issue_number)); QUrl(url_issues + m_games[itemID].compatibility.issue_number));
} }
} }
return changedFavorite;
} }
int GetRowIndex(QTreeWidget* treeWidget, QTreeWidgetItem* item) { int GetRowIndex(QTreeWidget* treeWidget, QTreeWidgetItem* item) {