From 239850bcbeb64666b19012dcfaa12f8ca7d6de4d Mon Sep 17 00:00:00 2001 From: Hugo Pereira Da Costa Date: Wed, 6 Aug 2014 22:03:46 +0200 Subject: [PATCH] implemented tab close --- kstyle/breezestyle.cpp | 36 ++++++++++++++++++++++++++++++++++++ kstyle/breezestyle.h | 2 +- 2 files changed, 37 insertions(+), 1 deletion(-) diff --git a/kstyle/breezestyle.cpp b/kstyle/breezestyle.cpp index a104bccd..08b52c70 100644 --- a/kstyle/breezestyle.cpp +++ b/kstyle/breezestyle.cpp @@ -725,6 +725,9 @@ namespace Breeze // menu indicator case PE_IndicatorButtonDropDown: fcn = &Style::drawIndicatorButtonDropDownPrimitive; break; + // tab close + case PE_IndicatorTabClose: fcn = &Style::drawIndicatorTabClosePrimitive; break; + // arrows case PE_IndicatorArrowUp: fcn = &Style::drawIndicatorArrowUpPrimitive; break; case PE_IndicatorArrowDown: fcn = &Style::drawIndicatorArrowDownPrimitive; break; @@ -2998,6 +3001,39 @@ namespace Breeze } + //___________________________________________________________________________________ + bool Style::drawIndicatorTabClosePrimitive( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const + { + + // get icon and check + QIcon icon( standardIcon( SP_TitleBarCloseButton, option, widget ) ); + if( icon.isNull() ) return false; + + // store state + const State& state( option->state ); + const bool enabled( state & State_Enabled ); + const bool active( state & State_Raised ); + const bool sunken( state & State_Sunken ); + + // decide icon mode and state + QIcon::Mode iconMode; + if( enabled ) iconMode = active ? QIcon::Active:QIcon::Normal; + else iconMode = QIcon::Disabled; + + const QIcon::State iconState( sunken ? QIcon::On : QIcon::Off ); + + // icon size + const int iconWidth( pixelMetric(QStyle::PM_SmallIconSize, option, widget ) ); + const QSize iconSize( iconWidth, iconWidth ); + + // get pixmap + const QPixmap pixmap( icon.pixmap( iconSize, iconMode, iconState ) ); + + // render + drawItemPixmap( painter, option->rect, Qt::AlignCenter, pixmap ); + return true; + } + //___________________________________________________________________________________ bool Style::drawIndicatorToolBarSeparatorPrimitive( const QStyleOption* option, QPainter* painter, const QWidget* ) const { diff --git a/kstyle/breezestyle.h b/kstyle/breezestyle.h index d0461f56..45dd25db 100644 --- a/kstyle/breezestyle.h +++ b/kstyle/breezestyle.h @@ -265,7 +265,7 @@ namespace Breeze bool drawFrameTabWidgetPrimitive( const QStyleOption*, QPainter*, const QWidget* ) const; bool drawFrameTabBarBasePrimitive( const QStyleOption*, QPainter*, const QWidget* ) const; bool drawFrameWindowPrimitive( const QStyleOption*, QPainter*, const QWidget* ) const; -// bool drawIndicatorTabClose( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const; + bool drawIndicatorTabClosePrimitive( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const; bool drawIndicatorArrowUpPrimitive( const QStyleOption* option, QPainter* painter, const QWidget* widget ) const { return drawIndicatorArrowPrimitive( ArrowUp, option, painter, widget ); }