From 6af266601803d1efaf74b20c069b22456329f92c Mon Sep 17 00:00:00 2001 From: tooomm Date: Fri, 28 Aug 2026 13:09:18 +0200 Subject: [PATCH] Revert "remove MacOSTabFixStyle" This reverts commit 28e53f97a4a58aafe742686fa0b09b711059a853. Update tab_supervisor.cpp --- .../interface/widgets/tabs/tab_supervisor.cpp | 18 ++++++++++++++++++ .../interface/widgets/tabs/tab_supervisor.h | 8 ++++++++ 2 files changed, 26 insertions(+) diff --git a/cockatrice/src/interface/widgets/tabs/tab_supervisor.cpp b/cockatrice/src/interface/widgets/tabs/tab_supervisor.cpp index a59e83637..23ed0e490 100644 --- a/cockatrice/src/interface/widgets/tabs/tab_supervisor.cpp +++ b/cockatrice/src/interface/widgets/tabs/tab_supervisor.cpp @@ -49,6 +49,18 @@ #include #include +QRect MacOSTabFixStyle::subElementRect(SubElement element, const QStyleOption *option, const QWidget *widget) const +{ + if (element != SE_TabBarTabText) { + return QProxyStyle::subElementRect(element, option, widget); + } + + // Skip over QProxyStyle handling subElementRect, + // This fixes an issue on macOS where the labels for tabs with a button and an icon + // get cut-off too early + return QCommonStyle::subElementRect(element, option, widget); +} + CloseButton::CloseButton(QWidget *parent) : QAbstractButton(parent) { setFocusPolicy(Qt::NoFocus); @@ -112,6 +124,12 @@ TabSupervisor::TabSupervisor(AbstractClient *_client, QMenu *tabsMenu, QWidget * setMovable(true); setIconSize(QSize(15, 15)); +#if defined(Q_OS_MAC) + // This is necessary to fix an issue on macOS, + // where tabs with icons and buttons get drawn incorrectly + tabBar()->setStyle(new MacOSTabFixStyle); +#endif + userListManager = new UserListManager(client, this); // connect tab changes diff --git a/cockatrice/src/interface/widgets/tabs/tab_supervisor.h b/cockatrice/src/interface/widgets/tabs/tab_supervisor.h index 852ebe645..b389bad3e 100644 --- a/cockatrice/src/interface/widgets/tabs/tab_supervisor.h +++ b/cockatrice/src/interface/widgets/tabs/tab_supervisor.h @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -55,6 +56,13 @@ class ServerInfo_User; class GameReplay; class DeckList; +class MacOSTabFixStyle : public QProxyStyle +{ + Q_OBJECT +public: + QRect subElementRect(SubElement, const QStyleOption *, const QWidget *) const override; +}; + class CloseButton : public QAbstractButton { Q_OBJECT