From c6587f611663c40819836dd1f5f5e6a3be254cf8 Mon Sep 17 00:00:00 2001 From: gambas Date: Sat, 3 Mar 2018 03:12:24 +0100 Subject: [PATCH] Fix render of Slider controls with Breeze theme. [GB.QT4] * BUG: Fix render of Slider controls with Breeze theme. [GB.QT5] * BUG: Fix render of Slider controls with Breeze theme. --- gb.qt4/src/fix_breeze.cpp | 47 ++++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 8 deletions(-) diff --git a/gb.qt4/src/fix_breeze.cpp b/gb.qt4/src/fix_breeze.cpp index 0c91b36b1..3839b6af2 100644 --- a/gb.qt4/src/fix_breeze.cpp +++ b/gb.qt4/src/fix_breeze.cpp @@ -124,6 +124,20 @@ QRect FixBreezeStyle::subControlRect(ComplexControl element, const QStyleOptionC return visualRect( option, labelRect ); } } + else if (element == CC_Slider) + { + const QStyleOptionSlider *sliderOption( qstyleoption_cast( option ) ); + const bool horizontal( sliderOption->orientation == Qt::Horizontal ); + + QRect result(QProxyStyle::subControlRect(element, option, subControl, widget)); + + if (horizontal) + result.moveTop((widget->height() - result.height()) / 2); + else + result.moveLeft((widget->width() - result.width()) / 2); + + return result; + } return QProxyStyle::subControlRect(element, option, subControl, widget); } @@ -185,12 +199,8 @@ void FixBreezeStyle::drawComplexControl(ComplexControl element, const QStyleOpti } } } - - QProxyStyle::drawComplexControl(element, option, painter, widget); - return; } - - if (element == CC_ComboBox) + else if (element == CC_ComboBox) { QStyleOptionComboBox newOption; const QStyleOptionComboBox* comboBoxOption( qstyleoption_cast( option ) ); @@ -209,9 +219,30 @@ void FixBreezeStyle::drawComplexControl(ComplexControl element, const QStyleOpti } } } - - QProxyStyle::drawComplexControl(element, option, painter, widget); - return; + } + else if (element == CC_Slider) + { + //QStyleOptionSlider newOption; + const QStyleOptionSlider *sliderOption( qstyleoption_cast( option ) ); + const bool horizontal( sliderOption->orientation == Qt::Horizontal ); + + if (!(sliderOption->subControls & SC_SliderTickmarks)) + { + QRect handle(QProxyStyle::subControlRect(element, option, SC_SliderHandle, widget)); + //newOption = *sliderOption; + //option = &newOption; + + painter->save(); + if (horizontal) + painter->translate(0, (widget->height() - handle.height()) / 2); + else + painter->translate((option->rect.width() - handle.width()) / 2, 0); + //newOption.rect = QRect(newOption.rect.x(), (newOption.rect.height() - handle.height()) / 2, newOption.rect.width(), handle.height()); + + QProxyStyle::drawComplexControl(element, option, painter, widget); + painter->restore(); + return; + } } QProxyStyle::drawComplexControl(element, option, painter, widget);