Fix user card games for offline users and stale requests (#7738)

This commit is contained in:
Bryce! 2026-11-03 23:29:51 -05:00 • committed by GitHub
parent 7768416091
commit 94f7de42f2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 550 additions and 76 deletions

View file

@ -1,6 +1,7 @@
#ifndef COCKATRICE_USER_INFO_POPUP_H
#define COCKATRICE_USER_INFO_POPUP_H
#include "user_games_model.h"
#include "user_list_painter.h"
#include <QColor>
@ -21,15 +22,13 @@ class QPushButton;
class TabSupervisor;
class QListView;
class QPoint;
class QStandardItemModel;
class Response;
template <class Key, class T> class QMap;
// ── Roles ─────────────────────────────────────────────────────────────────────
namespace PopupRoles
{
constexpr int GameData = Qt::UserRole + 10;
constexpr int GameData = UserGamesModel::GameRole;
}
// Popup theme
@ -143,6 +142,7 @@ public:
void
showForUser(const QString &userName, const ServerInfo_User &userInfo, bool online, bool isBuddy, bool isIgnored);
void fetchGames();
void setOnline(bool online);
[[nodiscard]] QString getCurrentUser() const
{
@ -199,7 +199,7 @@ protected:
private slots:
void refreshGames();
void onGamesReceived(const Response &r, const QString &forUser);
void updateGamesDisplay();
void onGamesContextMenu(const QPoint &pos);
private:
@ -218,6 +218,8 @@ private:
QString currentUser;
ServerInfo_User currentUserInfo;
bool currentOnline = false;
bool currentBuddy = false;
bool currentIgnored = false;
std::function<bool(const QString &userName)> gameInviteAvailable;
UserInfoHeaderWidget *header;
@ -225,7 +227,7 @@ private:
QLabel *gamesLabel;
QFrame *separator;
QListView *gamesView;
QStandardItemModel *gamesModel;
UserGamesModel *gamesModel;
QLabel *gamesStatus;
QPushButton *closeBtn;
QPushButton *refreshBtn;