QMacStyle: Fix QToolButton appearance on Yosemite

On Yosemite checkable toolbuttons look differently
when highlighted - this modification tries to imitate such look
without pixmaps we used on OS X >= 10.5 && < 10.10.

Change-Id: I0fcdff42a67fa6d5188c9dc64401f0f27ae60b5d
Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
This commit is contained in:
Timur Pocheptsov 2014-10-02 13:18:05 +02:00
parent 7ca54ce5d9
commit 11c1fe13b8

View File

@ -93,6 +93,7 @@
#include <qmath.h>
#include <QtWidgets/qgraphicsproxywidget.h>
#include <QtWidgets/qgraphicsview.h>
#include <QtCore/qvariant.h>
#include <private/qstylehelper_p.h>
#include <private/qstyleanimation_p.h>
#include <qpa/qplatformfontdatabase.h>
@ -5813,7 +5814,25 @@ void QMacStyle::drawComplexControl(ComplexControl cc, const QStyleOptionComplex
drawToolbarButtonArrow(tb->rect, tds, cg);
}
if (tb->state & State_On) {
if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
if (QSysInfo::MacintoshVersion > QSysInfo::MV_MAVERICKS) {
QWindow *window = 0;
if (widget && widget->window())
window = widget->window()->windowHandle();
else if (opt->styleObject)
window = opt->styleObject->property("_q_styleObjectWindow").value<QWindow *>();
NSView *view = window ? (NSView *)window->winId() : nil;
bool isKey = false;
if (view)
isKey = [view.window isKeyWindow];
QBrush brush(isKey ? QColor(0, 0, 0, 28)
: QColor(0, 0, 0, 21));
QPainterPath path;
path.addRoundedRect(QRectF(tb->rect.x(), tb->rect.y(), tb->rect.width(), tb->rect.height() + 4), 4, 4);
p->setRenderHint(QPainter::Antialiasing);
p->fillPath(path, brush);
} else if (QSysInfo::MacintoshVersion >= QSysInfo::MV_10_5) {
static QPixmap pm(QLatin1String(":/qt-project.org/mac/style/images/leopard-unified-toolbar-on.png"));
p->setRenderHint(QPainter::SmoothPixmapTransform);
QStyleHelper::drawBorderPixmap(pm, p, tb->rect, 2, 2, 2, 2);