diff --git a/kstyle/animations/breezescrollbardata.h b/kstyle/animations/breezescrollbardata.h
--- a/kstyle/animations/breezescrollbardata.h
+++ b/kstyle/animations/breezescrollbardata.h
@@ -34,6 +34,7 @@
Q_OBJECT
Q_PROPERTY( qreal addLineOpacity READ addLineOpacity WRITE setAddLineOpacity )
Q_PROPERTY( qreal subLineOpacity READ subLineOpacity WRITE setSubLineOpacity )
+ Q_PROPERTY( qreal grooveOpacity READ grooveOpacity WRITE setGrooveOpacity )
public:
@@ -64,6 +65,7 @@
{
case QStyle::SC_ScrollBarAddLine: return addLineArrowHovered();
case QStyle::SC_ScrollBarSubLine: return subLineArrowHovered();
+ case QStyle::SC_ScrollBarGroove: return grooveHovered();
default: return false;
}
@@ -105,6 +107,7 @@
WidgetStateData::setDuration( duration );
addLineAnimation().data()->setDuration( duration );
subLineAnimation().data()->setDuration( duration );
+ grooveAnimation().data()->setDuration( duration );
}
//* addLine opacity
@@ -133,6 +136,19 @@
virtual qreal subLineOpacity( void ) const
{ return _subLineData._opacity; }
+ //* groove opacity
+ virtual void setGrooveOpacity( qreal value )
+ {
+ value = digitize( value );
+ if( _grooveData._opacity == value ) return;
+ _grooveData._opacity = value;
+ setDirty();
+ }
+
+ //* groove opacity
+ virtual qreal grooveOpacity( void ) const
+ { return _grooveData._opacity; }
+
//* mouse position
QPoint position( void ) const
{ return _position; }
@@ -176,6 +192,12 @@
virtual void setSubLineArrowHovered( bool value )
{ _subLineData._hovered = value; }
+ virtual bool grooveHovered( void ) const
+ { return _grooveData._hovered; }
+
+ virtual void setGrooveHovered( bool value )
+ { _grooveData._hovered = value; }
+
//@}
//* update add line arrow
@@ -193,9 +215,12 @@
virtual const Animation::Pointer& subLineAnimation( void ) const
{ return _subLineData._animation; }
+ virtual const Animation::Pointer& grooveAnimation( void ) const
+ { return _grooveData._animation; }
+
private:
- //* stores arrow data
+ //* stores sub control data
class Data
{
@@ -228,6 +253,9 @@
//* subtract line data (up arrow)
Data _subLineData;
+ //* groove data
+ Data _grooveData;
+
//* mouse position
QPoint _position;
diff --git a/kstyle/animations/breezescrollbardata.cpp b/kstyle/animations/breezescrollbardata.cpp
--- a/kstyle/animations/breezescrollbardata.cpp
+++ b/kstyle/animations/breezescrollbardata.cpp
@@ -38,13 +38,15 @@
_addLineData._animation = new Animation( duration, this );
_subLineData._animation = new Animation( duration, this );
+ _grooveData._animation = new Animation( duration, this );
connect( addLineAnimation().data(), SIGNAL(finished()), SLOT(clearAddLineRect()) );
connect( subLineAnimation().data(), SIGNAL(finished()), SLOT(clearSubLineRect()) );
// setup animation
setupAnimation( addLineAnimation(), "addLineOpacity" );
setupAnimation( subLineAnimation(), "subLineOpacity" );
+ setupAnimation( grooveAnimation(), "grooveOpacity" );
}
@@ -60,12 +62,20 @@
{
case QEvent::HoverEnter:
+ setGrooveHovered(true);
+ grooveAnimation().data()->setDirection( Animation::Forward );
+ if( !grooveAnimation().data()->isRunning() ) grooveAnimation().data()->start();
+
case QEvent::HoverMove:
hoverMoveEvent( object, event );
break;
case QEvent::HoverLeave:
+ setGrooveHovered(false);
+ grooveAnimation().data()->setDirection( Animation::Backward );
+ if( !grooveAnimation().data()->isRunning() ) grooveAnimation().data()->start();
hoverLeaveEvent( object, event );
+
break;
default: break;
@@ -90,6 +100,9 @@
case QStyle::SC_ScrollBarSubLine:
return subLineAnimation();
+
+ case QStyle::SC_ScrollBarGroove:
+ return grooveAnimation();
}
}
@@ -108,6 +121,9 @@
case QStyle::SC_ScrollBarSubLine:
return subLineOpacity();
+
+ case QStyle::SC_ScrollBarGroove:
+ return grooveOpacity();
}
}
diff --git a/kstyle/breeze.kcfg b/kstyle/breeze.kcfg
--- a/kstyle/breeze.kcfg
+++ b/kstyle/breeze.kcfg
@@ -72,6 +72,11 @@
1
+
+
+ true
+
+
diff --git a/kstyle/breezestyle.cpp b/kstyle/breezestyle.cpp
--- a/kstyle/breezestyle.cpp
+++ b/kstyle/breezestyle.cpp
@@ -4956,13 +4956,14 @@
// enable animation state
const bool handleActive( sliderOption->activeSubControls & SC_ScrollBarSlider );
_animations->scrollBarEngine().updateState( widget, AnimationFocus, hasFocus );
+
_animations->scrollBarEngine().updateState( widget, AnimationHover, mouseOver && handleActive );
+
const AnimationMode mode( _animations->scrollBarEngine().animationMode( widget, SC_ScrollBarSlider ) );
const qreal opacity( _animations->scrollBarEngine().opacity( widget, SC_ScrollBarSlider ) );
+ const QColor color = _helper->scrollBarHandleColor( palette, mouseOver, hasFocus, opacity, mode );
- const QColor color( _helper->scrollBarHandleColor( palette, mouseOver, hasFocus, opacity, mode ) );
_helper->renderScrollBarHandle( painter, handleRect, color );
-
return true;
}
@@ -6357,28 +6358,35 @@
//______________________________________________________________
bool Style::drawScrollBarComplexControl( const QStyleOptionComplex* option, QPainter* painter, const QWidget* widget ) const
{
+ //the animation for QStyle::SC_ScrollBarGroove is special: it will animate
+ //the opacity of everything else as well, included slider and arrows
+ qreal opacity( _animations->scrollBarEngine().opacity( widget, QStyle::SC_ScrollBarGroove ) );
+ const bool animated( StyleConfigData::scrollBarShowOnMouseOver() && _animations->scrollBarEngine().isAnimated( widget, AnimationHover, QStyle::SC_ScrollBarGroove ) );
+ const bool mouseOver( option->state & State_MouseOver );
+
+ if( opacity == AnimationData::OpacityInvalid ) opacity = 1;
// render full groove directly, rather than using the addPage and subPage control element methods
- if( option->subControls & SC_ScrollBarGroove )
+ if( (mouseOver || animated) && option->subControls & SC_ScrollBarGroove )
{
// retrieve groove rectangle
QRect grooveRect( subControlRect( CC_ScrollBar, option, SC_ScrollBarGroove, widget ) );
const QPalette& palette( option->palette );
- const QColor color( _helper->alphaColor( palette.color( QPalette::WindowText ), 0.3 ) );
+ const QColor color( _helper->alphaColor( palette.color( QPalette::WindowText ), 0.3 * (animated ? opacity : 1) ) );
const State& state( option->state );
const bool horizontal( state & State_Horizontal );
if( horizontal ) grooveRect = centerRect( grooveRect, grooveRect.width(), Metrics::ScrollBar_SliderWidth );
else grooveRect = centerRect( grooveRect, Metrics::ScrollBar_SliderWidth, grooveRect.height() );
// render
_helper->renderScrollBarGroove( painter, grooveRect, color );
-
}
// call base class primitive
ParentStyleClass::drawComplexControl( CC_ScrollBar, option, painter, widget );
+
return true;
}
@@ -6638,18 +6646,39 @@
const QPalette& palette( option->palette );
QColor color( _helper->arrowColor( palette, QPalette::WindowText ) );
+ bool widgetMouseOver;
+ if( widget ) widgetMouseOver = widget->underMouse();
+ // in case this QStyle is used by QQuickControls QStyle wrapper
+ else if( option->styleObject ) widgetMouseOver = option->styleObject->property("hover").toBool();
+
// check enabled state
const bool enabled( option->state & State_Enabled );
- if( !enabled ) return color;
+ if( !enabled ) {
+ if( StyleConfigData::scrollBarShowOnMouseOver() ) {
+ // finally, global opacity when ScrollBarShowOnMouseOver
+ const qreal globalOpacity( _animations->scrollBarEngine().opacity( widget, QStyle::SC_ScrollBarGroove ) );
+ if( globalOpacity >= 0 ) color.setAlphaF( globalOpacity );
+ // no mouse over and no animation in progress, don't draw arrows at all
+ else if( !widgetMouseOver ) return Qt::transparent;
+ }
+ return color;
+ }
if(
( control == SC_ScrollBarSubLine && option->sliderValue == option->minimum ) ||
( control == SC_ScrollBarAddLine && option->sliderValue == option->maximum ) )
{
// manually disable arrow, to indicate that scrollbar is at limit
- return _helper->arrowColor( palette, QPalette::Disabled, QPalette::WindowText );
-
+ color = _helper->arrowColor( palette, QPalette::Disabled, QPalette::WindowText );
+ if( StyleConfigData::scrollBarShowOnMouseOver() ) {
+ // finally, global opacity when ScrollBarShowOnMouseOver
+ const qreal globalOpacity( _animations->scrollBarEngine().opacity( widget, QStyle::SC_ScrollBarGroove ) );
+ if( globalOpacity >= 0 ) color.setAlphaF( globalOpacity );
+ // no mouse over and no animation in progress, don't draw arrows at all
+ else if( !widgetMouseOver ) return Qt::transparent;
+ }
+ return color;
}
const bool mouseOver( _animations->scrollBarEngine().isHovered( widget, control ) );
@@ -6684,6 +6713,15 @@
}
+ if( StyleConfigData::scrollBarShowOnMouseOver() ) {
+ const bool mouseOver( ( option->state & State_MouseOver ) );
+ // finally, global opacity when ScrollBarShowOnMouseOver
+ const qreal globalOpacity( _animations->scrollBarEngine().opacity( widget, QStyle::SC_ScrollBarGroove ) );
+ if( globalOpacity >= 0 ) color.setAlphaF( globalOpacity );
+ // no mouse over and no animation in progress, don't draw arrows at all
+ else if( !widgetMouseOver ) return Qt::transparent;
+ }
+
return color;
}
diff --git a/kstyle/config/breezestyleconfig.cpp b/kstyle/config/breezestyleconfig.cpp
--- a/kstyle/config/breezestyleconfig.cpp
+++ b/kstyle/config/breezestyleconfig.cpp
@@ -63,6 +63,7 @@
connect( _animationsDuration, SIGNAL(valueChanged(int)), SLOT(updateChanged()) );
connect( _scrollBarAddLineButtons, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) );
connect( _scrollBarSubLineButtons, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) );
+ connect( _scrollBarShowOnMouseOver, SIGNAL(toggled(bool)), SLOT(updateChanged()) );
connect( _windowDragMode, SIGNAL(currentIndexChanged(int)), SLOT(updateChanged()) );
}
@@ -82,6 +83,7 @@
StyleConfigData::setMnemonicsMode( _mnemonicsMode->currentIndex() );
StyleConfigData::setScrollBarAddLineButtons( _scrollBarAddLineButtons->currentIndex() );
StyleConfigData::setScrollBarSubLineButtons( _scrollBarSubLineButtons->currentIndex() );
+ StyleConfigData::setScrollBarShowOnMouseOver( _scrollBarShowOnMouseOver->isChecked() );
StyleConfigData::setAnimationsEnabled( _animationsEnabled->isChecked() );
StyleConfigData::setAnimationsDuration( _animationsDuration->value() );
StyleConfigData::setWindowDragMode( _windowDragMode->currentIndex() );
@@ -143,6 +145,7 @@
else if( _mnemonicsMode->currentIndex() != StyleConfigData::mnemonicsMode() ) modified = true;
else if( _scrollBarAddLineButtons->currentIndex() != StyleConfigData::scrollBarAddLineButtons() ) modified = true;
else if( _scrollBarSubLineButtons->currentIndex() != StyleConfigData::scrollBarSubLineButtons() ) modified = true;
+ else if( _scrollBarShowOnMouseOver->isChecked() != StyleConfigData::scrollBarShowOnMouseOver() ) modified = true;
else if( _splitterProxyEnabled->isChecked() != StyleConfigData::splitterProxyEnabled() ) modified = true;
else if( _animationsEnabled->isChecked() != StyleConfigData::animationsEnabled() ) modified = true;
else if( _animationsDuration->value() != StyleConfigData::animationsDuration() ) modified = true;
@@ -168,6 +171,7 @@
_splitterProxyEnabled->setChecked( StyleConfigData::splitterProxyEnabled() );
_scrollBarAddLineButtons->setCurrentIndex( StyleConfigData::scrollBarAddLineButtons() );
_scrollBarSubLineButtons->setCurrentIndex( StyleConfigData::scrollBarSubLineButtons() );
+ _scrollBarShowOnMouseOver->setChecked( StyleConfigData::scrollBarShowOnMouseOver() );
_animationsEnabled->setChecked( StyleConfigData::animationsEnabled() );
_animationsDuration->setValue( StyleConfigData::animationsDuration() );
_windowDragMode->setCurrentIndex( StyleConfigData::windowDragMode() );
diff --git a/kstyle/config/ui/breezestyleconfig.ui b/kstyle/config/ui/breezestyleconfig.ui
--- a/kstyle/config/ui/breezestyleconfig.ui
+++ b/kstyle/config/ui/breezestyleconfig.ui
@@ -6,12 +6,21 @@
0
0
- 464
+ 508
246
-
+
+ 0
+
+
+ 0
+
+
+ 0
+
+
0
-
@@ -279,10 +288,23 @@
Scrollbars
+
-
+
+
+ Qt::Horizontal
+
+
+
+ 40
+ 20
+
+
+
+
-
- Botto&m arrow button type:
+ Bottom arrow button t&ype:
Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter
@@ -343,20 +365,7 @@
- -
-
-
- Qt::Horizontal
-
-
-
- 40
- 20
-
-
-
-
- -
+
-
Qt::Vertical
@@ -369,6 +378,16 @@
+ -
+
+
+ Only show full scrollbar on mouse over
+
+
+ true
+
+
+