Browse Source

Fix warnings for custom theme build against latest Qt

tags/v2.1-rc1
falkTX 5 years ago
parent
commit
34fedef582
2 changed files with 74 additions and 35 deletions
  1. +53
    -34
      source/theme/CarlaStyle.cpp
  2. +21
    -1
      source/theme/CarlaStylePrivate.hpp

+ 53
- 34
source/theme/CarlaStyle.cpp View File

@@ -62,6 +62,12 @@


#include <cstdio> #include <cstdio>


#if (QT_VERSION >= QT_VERSION_CHECK(5, 13, 0))
#define PIXMAPCACHE_VAR_PREFIX &
#else
#define PIXMAPCACHE_VAR_PREFIX
#endif

#define BEGIN_STYLE_PIXMAPCACHE(a) \ #define BEGIN_STYLE_PIXMAPCACHE(a) \
QRect rect = option->rect; \ QRect rect = option->rect; \
QPixmap internalPixmapCache; \ QPixmap internalPixmapCache; \
@@ -70,7 +76,7 @@
QString unique = uniqueName((a), option, option->rect.size()); \ QString unique = uniqueName((a), option, option->rect.size()); \
int txType = painter->deviceTransform().type() | painter->worldTransform().type(); \ int txType = painter->deviceTransform().type() | painter->worldTransform().type(); \
bool doPixmapCache = txType <= QTransform::TxTranslate; \ bool doPixmapCache = txType <= QTransform::TxTranslate; \
if (doPixmapCache && QPixmapCache::find(unique, internalPixmapCache)) { \
if (doPixmapCache && QPixmapCache::find(unique, PIXMAPCACHE_VAR_PREFIX internalPixmapCache)) { \
painter->drawPixmap(option->rect.topLeft(), internalPixmapCache); \ painter->drawPixmap(option->rect.topLeft(), internalPixmapCache); \
} else { \ } else { \
if (doPixmapCache) { \ if (doPixmapCache) { \
@@ -169,6 +175,15 @@ inline QPixmap styleCachePixmap(const QSize &size)
return QPixmap(size); return QPixmap(size);
} }


inline int fontMetricsHorizontalAdvance(const QFontMetrics& fm, const QString& s)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 11, 0))
return fm.horizontalAdvance(s);
#else
return fm.width(s);
#endif
}

int calcBigLineSize(int radius) int calcBigLineSize(int radius)
{ {
int bigLineSize = radius / 6; int bigLineSize = radius / 6;
@@ -389,7 +404,7 @@ static QPixmap colorizedImage(const QString &fileName, const QColor &color, int
{ {
QString pixmapName = QLatin1String("$qt_ia-") % fileName % HexString<uint>(color.rgba()) % QString::number(rotation); QString pixmapName = QLatin1String("$qt_ia-") % fileName % HexString<uint>(color.rgba()) % QString::number(rotation);
QPixmap pixmap; QPixmap pixmap;
if (!QPixmapCache::find(pixmapName, pixmap)) {
if (!QPixmapCache::find(pixmapName, PIXMAPCACHE_VAR_PREFIX pixmap)) {
QImage image(fileName); QImage image(fileName);


if (image.format() != QImage::Format_ARGB32_Premultiplied) if (image.format() != QImage::Format_ARGB32_Premultiplied)
@@ -529,7 +544,6 @@ static void qt_fusion_draw_mdibutton(QPainter *painter, const QStyleOptionTitleB
painter->drawPoint(tmp.right() , tmp.bottom() - 1); painter->drawPoint(tmp.right() , tmp.bottom() - 1);
} }



CarlaStyle::CarlaStyle() CarlaStyle::CarlaStyle()
: QCommonStyle(), : QCommonStyle(),
d(new CarlaStylePrivate(this)) d(new CarlaStylePrivate(this))
@@ -824,7 +838,7 @@ void CarlaStyle::drawPrimitive(PrimitiveElement elem,
{ {
if (option->rect.width() <= 1 || option->rect.height() <= 1) if (option->rect.width() <= 1 || option->rect.height() <= 1)
break; break;
QColor arrowColor = option->palette.foreground().color();
QColor arrowColor = qt_palette_fg_color(option->palette);
QPixmap arrow; QPixmap arrow;
int rotation = 0; int rotation = 0;
switch (elem) { switch (elem) {
@@ -873,7 +887,7 @@ void CarlaStyle::drawPrimitive(PrimitiveElement elem,
if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) { if (const QStyleOptionHeader *header = qstyleoption_cast<const QStyleOptionHeader *>(option)) {
QRect r = header->rect; QRect r = header->rect;
QPixmap arrow; QPixmap arrow;
QColor arrowColor = header->palette.foreground().color();
QColor arrowColor = qt_palette_fg_color(header->palette);
QPoint offset = QPoint(0, -1); QPoint offset = QPoint(0, -1);


if (header->sortIndicator & QStyleOptionHeader::SortUp) { if (header->sortIndicator & QStyleOptionHeader::SortUp) {
@@ -905,7 +919,7 @@ void CarlaStyle::drawPrimitive(PrimitiveElement elem,
rect.bottomLeft().y() - margin, rect.bottomLeft().y() - margin,
rect.topLeft().x() + offset, rect.topLeft().x() + offset,
rect.topLeft().y() + margin); rect.topLeft().y() + margin);
painter->setPen(QPen(option->palette.background().color().lighter(110)));
painter->setPen(QPen(qt_palette_bg_color(option->palette).lighter(110)));
painter->drawLine(rect.bottomLeft().x() + offset + 1, painter->drawLine(rect.bottomLeft().x() + offset + 1,
rect.bottomLeft().y() - margin, rect.bottomLeft().y() - margin,
rect.topLeft().x() + offset + 1, rect.topLeft().x() + offset + 1,
@@ -916,7 +930,7 @@ void CarlaStyle::drawPrimitive(PrimitiveElement elem,
rect.topLeft().y() + offset, rect.topLeft().y() + offset,
rect.topRight().x() - margin, rect.topRight().x() - margin,
rect.topRight().y() + offset); rect.topRight().y() + offset);
painter->setPen(QPen(option->palette.background().color().lighter(110)));
painter->setPen(QPen(qt_palette_bg_color(option->palette).lighter(110)));
painter->drawLine(rect.topLeft().x() + margin , painter->drawLine(rect.topLeft().x() + margin ,
rect.topLeft().y() + offset + 1, rect.topLeft().y() + offset + 1,
rect.topRight().x() - margin, rect.topRight().x() - margin,
@@ -941,8 +955,8 @@ void CarlaStyle::drawPrimitive(PrimitiveElement elem,
{ {
painter->setPen(QPen(outline, 1)); painter->setPen(QPen(outline, 1));
painter->drawRect(option->rect.adjusted(0, 0, -1, -1)); painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
QColor frameLight = option->palette.background().color().lighter(160);
QColor frameShadow = option->palette.background().color().darker(110);
QColor frameLight = qt_palette_bg_color(option->palette).lighter(160);
QColor frameShadow = qt_palette_bg_color(option->palette).darker(110);


//paint beveleffect //paint beveleffect
QRect frame = option->rect.adjusted(1, 1, -1, -1); QRect frame = option->rect.adjusted(1, 1, -1, -1);
@@ -960,14 +974,14 @@ void CarlaStyle::drawPrimitive(PrimitiveElement elem,


painter->save(); painter->save();
{ {
QColor softshadow = option->palette.background().color().darker(120);
QColor softshadow = qt_palette_bg_color(option->palette).darker(120);


QRect rect= option->rect; QRect rect= option->rect;
painter->setPen(softshadow); painter->setPen(softshadow);
painter->drawRect(option->rect.adjusted(0, 0, -1, -1)); painter->drawRect(option->rect.adjusted(0, 0, -1, -1));
painter->setPen(QPen(option->palette.light(), 0)); painter->setPen(QPen(option->palette.light(), 0));
painter->drawLine(QPoint(rect.left() + 1, rect.top() + 1), QPoint(rect.left() + 1, rect.bottom() - 1)); painter->drawLine(QPoint(rect.left() + 1, rect.top() + 1), QPoint(rect.left() + 1, rect.bottom() - 1));
painter->setPen(QPen(option->palette.background().color().darker(120), 0));
painter->setPen(QPen(qt_palette_bg_color(option->palette).darker(120), 0));
painter->drawLine(QPoint(rect.left() + 1, rect.bottom() - 1), QPoint(rect.right() - 2, rect.bottom() - 1)); painter->drawLine(QPoint(rect.left() + 1, rect.bottom() - 1), QPoint(rect.right() - 2, rect.bottom() - 1));
painter->drawLine(QPoint(rect.right() - 1, rect.top() + 1), QPoint(rect.right() - 1, rect.bottom() - 1)); painter->drawLine(QPoint(rect.right() - 1, rect.top() + 1), QPoint(rect.right() - 1, rect.bottom() - 1));


@@ -1006,7 +1020,7 @@ void CarlaStyle::drawPrimitive(PrimitiveElement elem,
painter->setPen(QPen(option->palette.light(), 0)); painter->setPen(QPen(option->palette.light(), 0));
painter->drawLine(QPoint(rect.left() + 1, rect.top() + 1), painter->drawLine(QPoint(rect.left() + 1, rect.top() + 1),
QPoint(rect.left() + 1, rect.bottom() - 1)); QPoint(rect.left() + 1, rect.bottom() - 1));
painter->setPen(QPen(option->palette.background().color().darker(120), 0));
painter->setPen(QPen(qt_palette_bg_color(option->palette).darker(120), 0));
painter->drawLine(QPoint(rect.left() + 1, rect.bottom() - 1), painter->drawLine(QPoint(rect.left() + 1, rect.bottom() - 1),
QPoint(rect.right() - 2, rect.bottom() - 1)); QPoint(rect.right() - 2, rect.bottom() - 1));
painter->drawLine(QPoint(rect.right() - 1, rect.top() + 1), painter->drawLine(QPoint(rect.right() - 1, rect.top() + 1),
@@ -1053,7 +1067,7 @@ void CarlaStyle::drawPrimitive(PrimitiveElement elem,


const QColor& baseColor = option->palette.base().color(); const QColor& baseColor = option->palette.base().color();


QColor pressedColor = mergedColors(baseColor, option->palette.foreground().color(), 85);
QColor pressedColor = mergedColors(baseColor, qt_palette_fg_color(option->palette), 85);
painter->setBrush(Qt::NoBrush); painter->setBrush(Qt::NoBrush);


// Gradient fill // Gradient fill
@@ -1115,12 +1129,12 @@ void CarlaStyle::drawPrimitive(PrimitiveElement elem,
case PE_IndicatorRadioButton: case PE_IndicatorRadioButton:
painter->save(); painter->save();
{ {
QColor pressedColor = mergedColors(option->palette.base().color(), option->palette.foreground().color(), 85);
QColor pressedColor = mergedColors(option->palette.base().color(), qt_palette_fg_color(option->palette), 85);
painter->setBrush((state & State_Sunken) ? pressedColor : option->palette.base().color()); painter->setBrush((state & State_Sunken) ? pressedColor : option->palette.base().color());
painter->setRenderHint(QPainter::Antialiasing, true); painter->setRenderHint(QPainter::Antialiasing, true);
QPainterPath circle; QPainterPath circle;
circle.addEllipse(rect.center() + QPoint(1.0, 1.0), 6.5, 6.5); circle.addEllipse(rect.center() + QPoint(1.0, 1.0), 6.5, 6.5);
painter->setPen(QPen(option->palette.background().color().darker(150), 1));
painter->setPen(QPen(qt_palette_bg_color(option->palette).darker(150), 1));
if (option->state & State_HasFocus && option->state & State_KeyboardFocusChange) if (option->state & State_HasFocus && option->state & State_KeyboardFocusChange)
painter->setPen(QPen(highlightedOutline, 1)); painter->setPen(QPen(highlightedOutline, 1));
painter->drawPath(circle); painter->drawPath(circle);
@@ -1577,7 +1591,7 @@ void CarlaStyle::drawControl(ControlElement element, const QStyleOption *option,
pixmapName += QString::number(- int(header->orientation)); pixmapName += QString::number(- int(header->orientation));


QPixmap cache; QPixmap cache;
if (!QPixmapCache::find(pixmapName, cache)) {
if (!QPixmapCache::find(pixmapName, PIXMAPCACHE_VAR_PREFIX cache)) {
cache = styleCachePixmap(rect.size()); cache = styleCachePixmap(rect.size());
cache.fill(Qt::transparent); cache.fill(Qt::transparent);
QRect pixmapRect(0, 0, rect.width(), rect.height()); QRect pixmapRect(0, 0, rect.width(), rect.height());
@@ -1588,8 +1602,13 @@ void CarlaStyle::drawControl(ControlElement element, const QStyleOption *option,
gradientStopColor = buttonColor.darker(102); gradientStopColor = buttonColor.darker(102);
QLinearGradient gradient(pixmapRect.topLeft(), pixmapRect.bottomLeft()); QLinearGradient gradient(pixmapRect.topLeft(), pixmapRect.bottomLeft());


if (option->palette.background().gradient()) {
gradient.setStops(option->palette.background().gradient()->stops());
#if (QT_VERSION >= QT_VERSION_CHECK(5, 13, 0))
const QGradient* gradientBrush = option->palette.window().gradient();
#else
const QGradient* gradientBrush = option->palette.background().gradient();
#endif
if (gradientBrush) {
gradient.setStops(gradientBrush->stops());
} else { } else {
QColor midColor1 = mergedColors(gradientStartColor, gradientStopColor, 60); QColor midColor1 = mergedColors(gradientStartColor, gradientStopColor, 60);
QColor midColor2 = mergedColors(gradientStartColor, gradientStopColor, 40); QColor midColor2 = mergedColors(gradientStartColor, gradientStopColor, 40);
@@ -1823,7 +1842,7 @@ void CarlaStyle::drawControl(ControlElement element, const QStyleOption *option,
} }
else else
{ {
QColor shadow = mergedColors(option->palette.background().color().darker(120),
QColor shadow = mergedColors(qt_palette_bg_color(option->palette).darker(120),
outline.lighter(140), 60); outline.lighter(140), 60);
painter->setPen(QPen(shadow)); painter->setPen(QPen(shadow));
painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight()); painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight());
@@ -1844,7 +1863,7 @@ void CarlaStyle::drawControl(ControlElement element, const QStyleOption *option,
proxy()->drawItemText(painter, menuItem->rect.adjusted(5, 0, -5, 0), Qt::AlignLeft | Qt::AlignVCenter, proxy()->drawItemText(painter, menuItem->rect.adjusted(5, 0, -5, 0), Qt::AlignLeft | Qt::AlignVCenter,
menuItem->palette, menuItem->state & State_Enabled, menuItem->text, menuItem->palette, menuItem->state & State_Enabled, menuItem->text,
QPalette::Text); QPalette::Text);
w = menuItem->fontMetrics.width(menuItem->text) + 5;
w = fontMetricsHorizontalAdvance(menuItem->fontMetrics, menuItem->text) + 5;
} }
painter->setPen(highlight); painter->setPen(highlight);
bool reverse = menuItem->direction == Qt::RightToLeft; bool reverse = menuItem->direction == Qt::RightToLeft;
@@ -1947,7 +1966,7 @@ void CarlaStyle::drawControl(ControlElement element, const QStyleOption *option,
if (checkable && checked) { if (checkable && checked) {
QStyleOption opt = *option; QStyleOption opt = *option;
if (act) { if (act) {
QColor activeColor = mergedColors(option->palette.background().color(),
QColor activeColor = mergedColors(qt_palette_bg_color(option->palette),
option->palette.highlight().color()); option->palette.highlight().color());
opt.palette.setBrush(QPalette::Button, activeColor); opt.palette.setBrush(QPalette::Button, activeColor);
} }
@@ -2118,7 +2137,7 @@ void CarlaStyle::drawControl(ControlElement element, const QStyleOption *option,
{ {
painter->fillRect(rect, option->palette.window()); painter->fillRect(rect, option->palette.window());
if (widget && qobject_cast<const QMainWindow *>(widget->parentWidget())) { if (widget && qobject_cast<const QMainWindow *>(widget->parentWidget())) {
QColor shadow = mergedColors(option->palette.background().color().darker(120),
QColor shadow = mergedColors(qt_palette_bg_color(option->palette).darker(120),
outline.lighter(140), 60); outline.lighter(140), 60);
painter->setPen(QPen(shadow)); painter->setPen(QPen(shadow));
painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight()); painter->drawLine(option->rect.bottomLeft(), option->rect.bottomRight());
@@ -2318,7 +2337,7 @@ void CarlaStyle::drawComplexControl(ComplexControl control, const QStyleOptionCo
// ### backgroundrole/foregroundrole should be part of the style option // ### backgroundrole/foregroundrole should be part of the style option
alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), outline); alphaCornerColor = mergedColors(option->palette.color(widget->backgroundRole()), outline);
} else { } else {
alphaCornerColor = mergedColors(option->palette.background().color(), outline);
alphaCornerColor = mergedColors(qt_palette_bg_color(option->palette), outline);
} }


switch (control) { switch (control) {
@@ -2372,7 +2391,7 @@ void CarlaStyle::drawComplexControl(ComplexControl control, const QStyleOptionCo
if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) { if (const QStyleOptionSpinBox *spinBox = qstyleoption_cast<const QStyleOptionSpinBox *>(option)) {
QPixmap cache; QPixmap cache;
QString pixmapName = uniqueName(QLatin1String("spinbox"), spinBox, spinBox->rect.size()); QString pixmapName = uniqueName(QLatin1String("spinbox"), spinBox, spinBox->rect.size());
if (!QPixmapCache::find(pixmapName, cache)) {
if (!QPixmapCache::find(pixmapName, PIXMAPCACHE_VAR_PREFIX cache)) {


cache = styleCachePixmap(spinBox->rect.size()); cache = styleCachePixmap(spinBox->rect.size());
cache.fill(Qt::transparent); cache.fill(Qt::transparent);
@@ -2381,7 +2400,7 @@ void CarlaStyle::drawComplexControl(ComplexControl control, const QStyleOptionCo
QRect rect = pixmapRect; QRect rect = pixmapRect;
QRect r = rect; QRect r = rect;
QPainter cachePainter(&cache); QPainter cachePainter(&cache);
QColor arrowColor = spinBox->palette.foreground().color();
QColor arrowColor = qt_palette_fg_color(spinBox->palette);
arrowColor.setAlpha(220); arrowColor.setAlpha(220);


const bool isEnabled = (spinBox->state & State_Enabled); const bool isEnabled = (spinBox->state & State_Enabled);
@@ -2591,13 +2610,13 @@ void CarlaStyle::drawComplexControl(ComplexControl control, const QStyleOptionCo
QColor highlight = option->palette.highlight().color(); QColor highlight = option->palette.highlight().color();


QColor titleBarFrameBorder(active ? highlight.darker(180): outline.darker(110)); QColor titleBarFrameBorder(active ? highlight.darker(180): outline.darker(110));
QColor titleBarHighlight(active ? highlight.lighter(120): palette.background().color().lighter(120));
QColor titleBarHighlight(active ? highlight.lighter(120): qt_palette_bg_color(palette).lighter(120));
QColor textColor(active ? 0xffffff : 0xff000000); QColor textColor(active ? 0xffffff : 0xff000000);
QColor textAlphaColor(active ? 0xffffff : 0xff000000 ); QColor textAlphaColor(active ? 0xffffff : 0xff000000 );


{ {
// Fill title bar gradient // Fill title bar gradient
QColor titlebarColor = QColor(active ? highlight: palette.background().color());
QColor titlebarColor = QColor(active ? highlight: qt_palette_bg_color(palette));
QLinearGradient gradient(option->rect.center().x(), option->rect.top(), QLinearGradient gradient(option->rect.center().x(), option->rect.top(),
option->rect.center().x(), option->rect.bottom()); option->rect.center().x(), option->rect.bottom());


@@ -2857,7 +2876,7 @@ void CarlaStyle::drawComplexControl(ComplexControl control, const QStyleOptionCo
QColor alphaOutline = outline; QColor alphaOutline = outline;
alphaOutline.setAlpha(180); alphaOutline.setAlpha(180);


QColor arrowColor = option->palette.foreground().color();
QColor arrowColor = qt_palette_fg_color(option->palette);
arrowColor.setAlpha(220); arrowColor.setAlpha(220);


// Paint groove // Paint groove
@@ -3030,7 +3049,7 @@ void CarlaStyle::drawComplexControl(ComplexControl control, const QStyleOptionCo
if (isEnabled) if (isEnabled)
pixmapName += QLatin1String("-enabled"); pixmapName += QLatin1String("-enabled");


if (!QPixmapCache::find(pixmapName, cache)) {
if (!QPixmapCache::find(pixmapName, PIXMAPCACHE_VAR_PREFIX cache)) {
cache = styleCachePixmap(comboBox->rect.size()); cache = styleCachePixmap(comboBox->rect.size());
cache.fill(Qt::transparent); cache.fill(Qt::transparent);
QPainter cachePainter(&cache); QPainter cachePainter(&cache);
@@ -3138,7 +3157,7 @@ void CarlaStyle::drawComplexControl(ComplexControl control, const QStyleOptionCo
QRect pixmapRect(0, 0, groove.width(), groove.height()); QRect pixmapRect(0, 0, groove.width(), groove.height());


// draw background groove // draw background groove
if (!QPixmapCache::find(groovePixmapName, cache)) {
if (!QPixmapCache::find(groovePixmapName, PIXMAPCACHE_VAR_PREFIX cache)) {
cache = styleCachePixmap(pixmapRect.size()); cache = styleCachePixmap(pixmapRect.size());
cache.fill(Qt::transparent); cache.fill(Qt::transparent);
QPainter groovePainter(&cache); QPainter groovePainter(&cache);
@@ -3166,7 +3185,7 @@ void CarlaStyle::drawComplexControl(ComplexControl control, const QStyleOptionCo
// draw blue groove highlight // draw blue groove highlight
QRect clipRect; QRect clipRect;
groovePixmapName += QLatin1String("_blue"); groovePixmapName += QLatin1String("_blue");
if (!QPixmapCache::find(groovePixmapName, cache)) {
if (!QPixmapCache::find(groovePixmapName, PIXMAPCACHE_VAR_PREFIX cache)) {
cache = styleCachePixmap(pixmapRect.size()); cache = styleCachePixmap(pixmapRect.size());
cache.fill(Qt::transparent); cache.fill(Qt::transparent);
QPainter groovePainter(&cache); QPainter groovePainter(&cache);
@@ -3274,7 +3293,7 @@ void CarlaStyle::drawComplexControl(ComplexControl control, const QStyleOptionCo
// draw handle // draw handle
if ((option->subControls & SC_SliderHandle) ) { if ((option->subControls & SC_SliderHandle) ) {
QString handlePixmapName = uniqueName(QLatin1String("slider_handle"), option, handle.size()); QString handlePixmapName = uniqueName(QLatin1String("slider_handle"), option, handle.size());
if (!QPixmapCache::find(handlePixmapName, cache)) {
if (!QPixmapCache::find(handlePixmapName, PIXMAPCACHE_VAR_PREFIX cache)) {
cache = styleCachePixmap(handle.size()); cache = styleCachePixmap(handle.size());
cache.fill(Qt::transparent); cache.fill(Qt::transparent);
QRect pixmapRect(0, 0, handle.width(), handle.height()); QRect pixmapRect(0, 0, handle.width(), handle.height());
@@ -3495,7 +3514,7 @@ QSize CarlaStyle::sizeFromContents(ContentsType type, const QStyleOption* option
QFont fontBold = menuItem->font; QFont fontBold = menuItem->font;
fontBold.setBold(true); fontBold.setBold(true);
QFontMetrics fmBold(fontBold); QFontMetrics fmBold(fontBold);
w += fmBold.width(menuItem->text) - fm.width(menuItem->text);
w += fontMetricsHorizontalAdvance(fmBold, menuItem->text) - fontMetricsHorizontalAdvance(fm, menuItem->text);
} }
int checkcol = qMax<int>(maxpmw, CarlaStylePrivate::menuCheckMarkWidth); // Windows always shows a check column int checkcol = qMax<int>(maxpmw, CarlaStylePrivate::menuCheckMarkWidth); // Windows always shows a check column
w += checkcol; w += checkcol;
@@ -3945,7 +3964,7 @@ int CarlaStyle::styleHint(StyleHint hint, const QStyleOption* option, const QWid
return 0; return 0;


case SH_Table_GridLineColor: case SH_Table_GridLineColor:
return option ? option->palette.background().color().darker(120).rgb() : 0;
return option ? qt_palette_bg_color(option->palette).darker(120).rgb() : 0;


case SH_MessageBox_TextInteractionFlags: case SH_MessageBox_TextInteractionFlags:
return Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse; return Qt::TextSelectableByMouse | Qt::LinksAccessibleByMouse;


+ 21
- 1
source/theme/CarlaStylePrivate.hpp View File

@@ -23,6 +23,26 @@


#include <QtCore/QHash> #include <QtCore/QHash>


static inline
const QColor& qt_palette_bg_color(const QPalette& pal)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 13, 0))
return pal.window().color();
#else
return pal.background().color();
#endif
}

static inline
const QColor& qt_palette_fg_color(const QPalette& pal)
{
#if (QT_VERSION >= QT_VERSION_CHECK(5, 13, 0))
return pal.windowText().color();
#else
return pal.foreground().color();
#endif
}

class QStyleAnimation; class QStyleAnimation;


class CarlaStylePrivate : public QObject class CarlaStylePrivate : public QObject
@@ -95,7 +115,7 @@ public:
{ {
if (! pal.window().texture().isNull()) if (! pal.window().texture().isNull())
return QColor(0, 0, 0, 160); return QColor(0, 0, 0, 160);
const QColor& col = pal.background().color();
const QColor& col = qt_palette_bg_color(pal);
return col.blackF() > 0.4 ? col.lighter(160) : col.darker(140); return col.blackF() > 0.4 ? col.lighter(160) : col.darker(140);
} }




Loading…
Cancel
Save