From 5286f5845f29b663a62646adda356eac6f939f08 Mon Sep 17 00:00:00 2001 From: nds Date: Thu, 6 May 2010 04:38:25 +0000 Subject: [PATCH] The small improvement to support vertical title bar of the dock widget control. --- src/Style/Style_Salome.cxx | 43 +++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/Style/Style_Salome.cxx b/src/Style/Style_Salome.cxx index a9446c7c4..87e139f66 100644 --- a/src/Style/Style_Salome.cxx +++ b/src/Style/Style_Salome.cxx @@ -694,9 +694,29 @@ void Style_Salome::drawControl( ControlElement ce, const QStyleOption* opt, } else { QRect r = dwOpt->rect.adjusted(0, 0, -1, -1); + QRect aRect = dwOpt->rect; + + const QStyleOptionDockWidgetV2 *v2 + = qstyleoption_cast(opt); + bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar; + + if (verticalTitleBar) { + QSize s = r.size(); + s.transpose(); + r.setSize(s); + + QSize aSize = aRect.size(); + aSize.transpose(); + aRect.setSize(aSize); + + p->save(); + p->translate(r.left(), r.top() + r.width()); + p->rotate(-90); + p->translate(-r.left(), -r.top()); + } + QColor bottom = opt->palette.color( QPalette::Window ), top = bottom.dark( BUT_PERCENT_COL ); - QRect aRect = dwOpt->rect; QLinearGradient gr( aRect.x(), aRect.y(), aRect.x(), aRect.y()+aRect.height() ); gr.setColorAt( 0.0, top ); gr.setColorAt( 0.4, bottom ); @@ -712,6 +732,9 @@ void Style_Salome::drawControl( ControlElement ce, const QStyleOption* opt, p->setPen( aBrdBotCol ); p->drawLine( r.x(), r.bottom(), r.right(), r.bottom() ); p->drawLine( r.right(), r.bottom(), r.right(), r.y() ); + + if (verticalTitleBar) + p->restore(); } } p->setPen(dwOpt->palette.color(QPalette::Light)); @@ -727,6 +750,21 @@ void Style_Salome::drawControl( ControlElement ce, const QStyleOption* opt, aWidth = aWidth - aPxm.width()-2/*button margins*/; r = QRect( r.x(), r.y(), aWidth-aMargin-2/*buttons separator*/-2/*margin from text*/, r.height() ); + const QStyleOptionDockWidgetV2 *v2 + = qstyleoption_cast(opt); + bool verticalTitleBar = v2 == 0 ? false : v2->verticalTitleBar; + + if (verticalTitleBar) { + QSize s = r.size(); + s.transpose(); + r.setSize(s); + + p->save(); + p->translate(r.left(), r.top() + r.width()); + p->rotate(-90); + p->translate(-r.left(), -r.top()); + } + QFont oldFont = p->font(); QFont font = oldFont; if (floating) { @@ -743,6 +781,9 @@ void Style_Salome::drawControl( ControlElement ce, const QStyleOption* opt, dwOpt->state & State_Enabled, aTitle, floating ? (active ? QPalette::BrightText : QPalette::Window) : QPalette::WindowText); p->setFont(oldFont); + + if (verticalTitleBar) + p->restore(); } break; } -- 2.39.2