mirror of
https://github.com/Cockatrice/Cockatrice.git
synced 2026-09-23 01:55:10 -07:00
[Client] Open the invite dialog taller by default without enforcing a minimum size
This commit is contained in:
parent
06e0bda021
commit
e9b695ed21
3 changed files with 28 additions and 0 deletions
|
|
@ -525,6 +525,13 @@ void UserInfoPopup::rebuildActionButtons(const ServerInfo_User &userInfo, bool o
|
||||||
connect(games, &QPushButton::clicked, this, [this, name] { emit showGamesRequested(name); });
|
connect(games, &QPushButton::clicked, this, [this, name] { emit showGamesRequested(name); });
|
||||||
add(games);
|
add(games);
|
||||||
|
|
||||||
|
// ── Invite (only while the inviter has a joinable game for this user) ────
|
||||||
|
if (!isSelf && online && gameInviteAvailable && gameInviteAvailable(name)) {
|
||||||
|
auto *invite = makeBtn(tr("Invite"), tr("Invite to your game"), actionArea, theme);
|
||||||
|
connect(invite, &QPushButton::clicked, this, [this, name] { emit inviteRequested(name); });
|
||||||
|
add(invite);
|
||||||
|
}
|
||||||
|
|
||||||
// ── Buddy / ignore (registered users only) ────────────────────────────────
|
// ── Buddy / ignore (registered users only) ────────────────────────────────
|
||||||
if (!isSelf && isReg) {
|
if (!isSelf && isReg) {
|
||||||
if (isBuddy) {
|
if (isBuddy) {
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QPixmap>
|
#include <QPixmap>
|
||||||
#include <QStandardItemModel>
|
#include <QStandardItemModel>
|
||||||
|
#include <functional>
|
||||||
#include <libcockatrice/network/server/remote/user_level.h>
|
#include <libcockatrice/network/server/remote/user_level.h>
|
||||||
#include <libcockatrice/protocol/pb/response.pb.h>
|
#include <libcockatrice/protocol/pb/response.pb.h>
|
||||||
#include <libcockatrice/protocol/pb/serverinfo_game.pb.h>
|
#include <libcockatrice/protocol/pb/serverinfo_game.pb.h>
|
||||||
|
|
@ -149,6 +150,17 @@ public:
|
||||||
/** Re-pulls the avatar/card art for the currently shown user (e.g. after it loads). */
|
/** Re-pulls the avatar/card art for the currently shown user (e.g. after it loads). */
|
||||||
void refreshHeader();
|
void refreshHeader();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets a predicate evaluated on every action-button rebuild. It receives
|
||||||
|
* the name of the user the popup currently shows; when it returns true an
|
||||||
|
* "Invite" button is shown. The popup itself never resolves the invite
|
||||||
|
* link, it just forwards the request.
|
||||||
|
*/
|
||||||
|
void setGameInviteAvailable(std::function<bool(const QString &userName)> available)
|
||||||
|
{
|
||||||
|
gameInviteAvailable = std::move(available);
|
||||||
|
}
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void mouseEnteredPopup();
|
void mouseEnteredPopup();
|
||||||
void mouseLeftPopup();
|
void mouseLeftPopup();
|
||||||
|
|
@ -159,6 +171,7 @@ signals:
|
||||||
|
|
||||||
// ── Action signals — connect to UserContextMenu::exec*() ──────────────────
|
// ── Action signals — connect to UserContextMenu::exec*() ──────────────────
|
||||||
void chatRequested(const QString &userName);
|
void chatRequested(const QString &userName);
|
||||||
|
void inviteRequested(const QString &userName);
|
||||||
void detailsRequested(const QString &userName);
|
void detailsRequested(const QString &userName);
|
||||||
void showGamesRequested(const QString &userName);
|
void showGamesRequested(const QString &userName);
|
||||||
void addBuddyRequested(const QString &userName);
|
void addBuddyRequested(const QString &userName);
|
||||||
|
|
@ -200,6 +213,7 @@ private:
|
||||||
QString currentUser;
|
QString currentUser;
|
||||||
ServerInfo_User currentUserInfo;
|
ServerInfo_User currentUserInfo;
|
||||||
bool currentOnline = false;
|
bool currentOnline = false;
|
||||||
|
std::function<bool(const QString &userName)> gameInviteAvailable;
|
||||||
|
|
||||||
UserInfoHeaderWidget *header;
|
UserInfoHeaderWidget *header;
|
||||||
QWidget *actionArea; ///< rebuilt per user
|
QWidget *actionArea; ///< rebuilt per user
|
||||||
|
|
|
||||||
|
|
@ -345,6 +345,11 @@ UserListWidget::UserListWidget(TabSupervisor *_tabSupervisor,
|
||||||
&cardArtProvider->cache(), &cardArtParamsMap,
|
&cardArtProvider->cache(), &cardArtParamsMap,
|
||||||
window()); // parented to main window so it floats above siblings
|
window()); // parented to main window so it floats above siblings
|
||||||
|
|
||||||
|
// The invite availability is scoped to the room this list belongs to,
|
||||||
|
// and gated on the room's buddy-only setting for the hovered user.
|
||||||
|
userInfoPopup->setGameInviteAvailable(
|
||||||
|
[this](const QString &userName) { return userContextMenu->hasGameInviteLink(userName); });
|
||||||
|
|
||||||
userInfoPopup->hide();
|
userInfoPopup->hide();
|
||||||
userInfoPopup->setWindowOpacity(0.0);
|
userInfoPopup->setWindowOpacity(0.0);
|
||||||
userInfoPopup->installEventFilter(this);
|
userInfoPopup->installEventFilter(this);
|
||||||
|
|
@ -662,6 +667,8 @@ void UserListWidget::connectPopupSignals()
|
||||||
|
|
||||||
// Wire all action signals to UserContextMenu::exec*()
|
// Wire all action signals to UserContextMenu::exec*()
|
||||||
connect(userInfoPopup, &UserInfoPopup::chatRequested, userContextMenu, &UserContextMenu::execChat);
|
connect(userInfoPopup, &UserInfoPopup::chatRequested, userContextMenu, &UserContextMenu::execChat);
|
||||||
|
connect(userInfoPopup, &UserInfoPopup::inviteRequested, this,
|
||||||
|
[this](const QString &userName) { userContextMenu->execInvite(userName); });
|
||||||
connect(userInfoPopup, &UserInfoPopup::detailsRequested, userContextMenu, &UserContextMenu::execDetails);
|
connect(userInfoPopup, &UserInfoPopup::detailsRequested, userContextMenu, &UserContextMenu::execDetails);
|
||||||
connect(userInfoPopup, &UserInfoPopup::showGamesRequested, userContextMenu, &UserContextMenu::execShowGames);
|
connect(userInfoPopup, &UserInfoPopup::showGamesRequested, userContextMenu, &UserContextMenu::execShowGames);
|
||||||
connect(userInfoPopup, &UserInfoPopup::addBuddyRequested, userContextMenu, &UserContextMenu::execAddToBuddy);
|
connect(userInfoPopup, &UserInfoPopup::addBuddyRequested, userContextMenu, &UserContextMenu::execAddToBuddy);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue