Add custom QStyle class to tab bar to fix render issue on macOS. (#3095)
* Add custom QStyle class to tab bar to fix render issue on macOS. fixes #3070 * clangify
This commit is contained in:
parent
501e82f712
commit
2206328406
2 changed files with 28 additions and 0 deletions
|
@ -28,6 +28,18 @@
|
|||
#include "pb/serverinfo_room.pb.h"
|
||||
#include "pb/serverinfo_user.pb.h"
|
||||
|
||||
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 with Qt 5.10 on OSX 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);
|
||||
|
@ -86,6 +98,13 @@ TabSupervisor::TabSupervisor(AbstractClient *_client, QWidget *parent)
|
|||
setElideMode(Qt::ElideRight);
|
||||
setMovable(true);
|
||||
setIconSize(QSize(15, 15));
|
||||
|
||||
#if defined(Q_OS_MAC)
|
||||
// This is necessary to fix an issue on macOS with qt5.10,
|
||||
// where tabs with icons and buttons get drawn incorrectly
|
||||
tabBar()->setStyle(new MacOSTabFixStyle);
|
||||
#endif
|
||||
|
||||
connect(this, SIGNAL(currentChanged(int)), this, SLOT(updateCurrent(int)));
|
||||
|
||||
connect(client, SIGNAL(roomEventReceived(const RoomEvent &)), this, SLOT(processRoomEvent(const RoomEvent &)));
|
||||
|
|
|
@ -4,7 +4,9 @@
|
|||
#include "chatview/userlistProxy.h"
|
||||
#include "deck_loader.h"
|
||||
#include <QAbstractButton>
|
||||
#include <QCommonStyle>
|
||||
#include <QMap>
|
||||
#include <QProxyStyle>
|
||||
#include <QTabWidget>
|
||||
|
||||
class QMenu;
|
||||
|
@ -30,6 +32,13 @@ class ServerInfo_User;
|
|||
class GameReplay;
|
||||
class DeckList;
|
||||
|
||||
class MacOSTabFixStyle : public QProxyStyle
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
QRect subElementRect(SubElement, const QStyleOption *, const QWidget *) const;
|
||||
};
|
||||
|
||||
class CloseButton : public QAbstractButton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
|
Loading…
Reference in a new issue