Added the possibility to draw left-aligned toolbuttons

Apply to Gwenview's side bar toolbuttons
wilder-pre-rebase
Hugo Pereira Da Costa 12 years ago
parent 0cac9ffcff
commit 2fb62271d7
  1. 1
      kstyle/breezepropertynames.cpp
  2. 1
      kstyle/breezepropertynames.h
  3. 23
      kstyle/breezestyle.cpp

@ -25,5 +25,6 @@ namespace Breeze
const char* const PropertyNames::noAnimations = "_kde_no_animations";
const char* const PropertyNames::noWindowGrab = "_kde_no_window_grab";
const char* const PropertyNames::toolButtonAlignment = "_kde_toolButton_alignment";
}

@ -29,6 +29,7 @@ namespace Breeze
static const char* const noAnimations;
static const char* const noWindowGrab;
static const char* const toolButtonAlignment;
};

@ -48,6 +48,7 @@
#include "breezehelper.h"
#include "breezemdiwindowshadow.h"
#include "breezemnemonics.h"
#include "breezepropertynames.h"
#include "breezeshadowhelper.h"
#include "breezesplitterproxy.h"
#include "breezestyleconfigdata.h"
@ -308,6 +309,11 @@ namespace Breeze
widget->setForegroundRole( QPalette::WindowText );
}
if( widget->parentWidget() &&
widget->parentWidget()->parentWidget() &&
widget->parentWidget()->parentWidget()->inherits( "Gwenview::SideBarGroup" ) )
{ widget->setProperty( PropertyNames::toolButtonAlignment, Qt::AlignLeft ); }
} else if( qobject_cast<QDockWidget*>( widget ) ) {
// add event filter on dock widgets
@ -352,7 +358,7 @@ namespace Breeze
}
// alter palette for non document mode tab widgets
if( QTabWidget *tabWidget = qobject_cast<QTabWidget*>( widget ) )
else if( QTabWidget *tabWidget = qobject_cast<QTabWidget*>( widget ) )
{
if( !tabWidget->documentMode() )
{
@ -362,7 +368,7 @@ namespace Breeze
}
// alter palette for dock widgets
if( qobject_cast<QDockWidget*>( widget ) && StyleConfigData::dockWidgetDrawFrame() )
else if( qobject_cast<QDockWidget*>( widget ) && StyleConfigData::dockWidgetDrawFrame() )
{
const QPalette palette( _helper->framePalette( QApplication::palette() ) );
widget->setPalette( palette );
@ -3773,8 +3779,17 @@ namespace Breeze
} else {
const int contentsWidth( iconSize.width() + textSize.width() + Metrics::ToolButton_ItemSpacing );
iconRect = QRect( QPoint( rect.left() + (rect.width() - contentsWidth )/2, rect.top() + (rect.height() - iconSize.height())/2 ), iconSize );
const QVariant alignmentProperty( widget ? widget->property( PropertyNames::toolButtonAlignment ) : QVariant() );
const bool leftAlign = alignmentProperty.isValid() && alignmentProperty.toInt() == Qt::AlignLeft;
if( leftAlign ) iconRect = QRect( QPoint( rect.left(), rect.top() + (rect.height() - iconSize.height())/2 ), iconSize );
else {
const int contentsWidth( iconSize.width() + textSize.width() + Metrics::ToolButton_ItemSpacing );
iconRect = QRect( QPoint( rect.left() + (rect.width() - contentsWidth )/2, rect.top() + (rect.height() - iconSize.height())/2 ), iconSize );
}
textRect = QRect( QPoint( iconRect.right() + Metrics::ToolButton_ItemSpacing + 1, rect.top() + (rect.height() - textSize.height())/2 ), textSize );
// handle right to left layouts

Loading…
Cancel
Save