2019-06-20 12:02:28 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
|
|
|
* This file may be used under the terms of the 3-clause BSD License
|
|
|
|
*****************************************************************************/
|
|
|
|
|
2020-08-11 17:56:53 +02:00
|
|
|
#include "CustomSlider.h"
|
|
|
|
#include "CustomSliderSkinlet.h"
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
#include <QskAnimationHint.h>
|
2017-07-21 18:21:34 +02:00
|
|
|
#include <QskAspect.h>
|
2017-10-20 20:26:39 +02:00
|
|
|
#include <QskBoxShapeMetrics.h>
|
|
|
|
#include <QskGradient.h>
|
2018-08-03 08:15:28 +02:00
|
|
|
#include <QskRgbValue.h>
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2020-12-27 11:11:31 +01:00
|
|
|
#include <QskSkinHintTable.h>
|
|
|
|
#include <QskSkinHintTableEditor.h>
|
|
|
|
|
2020-08-11 17:56:53 +02:00
|
|
|
QSK_SUBCONTROL( CustomSlider, Scale )
|
|
|
|
QSK_SUBCONTROL( CustomSlider, Decoration )
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2020-08-11 17:56:53 +02:00
|
|
|
CustomSlider::CustomSlider( QQuickItem* parentItem )
|
2018-08-03 08:15:28 +02:00
|
|
|
: QskSlider( parentItem )
|
2017-07-21 18:21:34 +02:00
|
|
|
{
|
2020-12-17 08:50:35 +01:00
|
|
|
using namespace QskRgb;
|
|
|
|
|
2020-12-27 11:11:31 +01:00
|
|
|
QskSkinHintTableEditor ed( &hintTable() );
|
|
|
|
|
|
|
|
ed.setBoxShape( Fill, 0 );
|
|
|
|
ed.setGradient( Fill, Grey700 );
|
|
|
|
ed.setColor( Scale, qRgb( 178, 178, 178 ) ); // for the ticks
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2020-12-27 11:11:31 +01:00
|
|
|
ed.setStrutSize( Handle, 80, 80 );
|
|
|
|
ed.setColor( Handle, Grey800 );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
|
|
|
for ( auto state : { Pressed, Focused | Hovered, Hovered, Focused } )
|
2020-12-27 11:11:31 +01:00
|
|
|
ed.setColor( Handle | state, Orange600 );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
2020-12-27 11:11:31 +01:00
|
|
|
ed.setAnimation( Handle | QskAspect::Color, 1000 );
|
2017-10-17 17:34:00 +02:00
|
|
|
for ( auto state : { Focused | Hovered, Hovered, Focused } )
|
2020-12-27 11:11:31 +01:00
|
|
|
ed.setAnimation( Handle | QskAspect::Color | state, 300 );
|
2017-07-21 18:21:34 +02:00
|
|
|
|
|
|
|
// using an individual skinlet, not known by the skin
|
|
|
|
|
2020-08-11 17:56:53 +02:00
|
|
|
auto skinlet = new CustomSliderSkinlet();
|
2017-07-21 18:21:34 +02:00
|
|
|
skinlet->setOwnedBySkinnable( true );
|
|
|
|
|
|
|
|
setSkinlet( skinlet );
|
2018-01-19 10:15:29 +01:00
|
|
|
|
2020-07-25 12:50:26 +02:00
|
|
|
connect( this, &QskSlider::valueChanged,
|
2018-01-19 10:15:29 +01:00
|
|
|
this, &QskControl::focusIndicatorRectChanged );
|
2017-07-21 18:21:34 +02:00
|
|
|
}
|
|
|
|
|
2020-08-11 17:56:53 +02:00
|
|
|
QSizeF CustomSlider::contentsSizeHint(
|
2019-09-10 17:01:47 +02:00
|
|
|
Qt::SizeHint which, const QSizeF& constraint ) const
|
2017-07-21 18:21:34 +02:00
|
|
|
{
|
2019-09-10 17:01:47 +02:00
|
|
|
auto size = Inherited::contentsSizeHint( which, constraint );
|
|
|
|
|
|
|
|
if ( which == Qt::PreferredSize && size.height() >= 0 )
|
|
|
|
size.setHeight( size.height() + 40 );
|
|
|
|
|
|
|
|
return size;
|
2017-07-21 18:21:34 +02:00
|
|
|
}
|
|
|
|
|
2020-08-11 17:56:53 +02:00
|
|
|
QRectF CustomSlider::focusIndicatorRect() const
|
2018-01-19 10:15:29 +01:00
|
|
|
{
|
2020-12-17 08:50:35 +01:00
|
|
|
return subControlRect( Handle );
|
2018-01-19 10:15:29 +01:00
|
|
|
}
|