2017-07-21 18:21:34 +02:00
|
|
|
/******************************************************************************
|
|
|
|
* QSkinny - Copyright (C) 2016 Uwe Rathmann
|
|
|
|
* This file may be used under the terms of the QSkinny License, Version 1.0
|
|
|
|
*****************************************************************************/
|
|
|
|
|
|
|
|
#include "QskPageIndicator.h"
|
|
|
|
#include "QskAspect.h"
|
|
|
|
|
|
|
|
QSK_SUBCONTROL( QskPageIndicator, Panel )
|
|
|
|
QSK_SUBCONTROL( QskPageIndicator, Bullet )
|
|
|
|
QSK_SUBCONTROL( QskPageIndicator, Highlighted )
|
|
|
|
|
|
|
|
class QskPageIndicator::PrivateData
|
|
|
|
{
|
2018-08-03 08:15:28 +02:00
|
|
|
public:
|
|
|
|
PrivateData( int count )
|
|
|
|
: count( count )
|
|
|
|
, currentIndex( -1 )
|
|
|
|
, orientation( Qt::Horizontal )
|
2017-07-21 18:21:34 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
int count;
|
|
|
|
qreal currentIndex;
|
|
|
|
Qt::Orientation orientation : 2;
|
|
|
|
};
|
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
QskPageIndicator::QskPageIndicator( int count, QQuickItem* parent )
|
|
|
|
: Inherited( parent )
|
|
|
|
, m_data( new PrivateData( count ) )
|
2017-07-21 18:21:34 +02:00
|
|
|
{
|
|
|
|
// as we don't stretch the bullets
|
2017-08-31 09:09:05 +02:00
|
|
|
initSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed );
|
2017-07-21 18:21:34 +02:00
|
|
|
}
|
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
QskPageIndicator::QskPageIndicator( QQuickItem* parent )
|
|
|
|
: QskPageIndicator( 0, parent )
|
2017-07-21 18:21:34 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
QskPageIndicator::~QskPageIndicator()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
int QskPageIndicator::count() const
|
|
|
|
{
|
|
|
|
return m_data->count;
|
|
|
|
}
|
|
|
|
|
|
|
|
qreal QskPageIndicator::currentIndex() const
|
|
|
|
{
|
|
|
|
return m_data->currentIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
Qt::Orientation QskPageIndicator::orientation() const
|
|
|
|
{
|
|
|
|
return m_data->orientation;
|
|
|
|
}
|
|
|
|
|
|
|
|
void QskPageIndicator::setOrientation( Qt::Orientation orientation )
|
|
|
|
{
|
2018-08-03 08:15:28 +02:00
|
|
|
if ( orientation != m_data->orientation )
|
2017-07-21 18:21:34 +02:00
|
|
|
{
|
|
|
|
m_data->orientation = orientation;
|
|
|
|
|
|
|
|
resetImplicitSize();
|
|
|
|
update();
|
|
|
|
|
2020-12-17 16:14:56 +01:00
|
|
|
Q_EMIT orientationChanged( orientation );
|
2017-07-21 18:21:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void QskPageIndicator::setCount( int count )
|
|
|
|
{
|
|
|
|
if ( count != m_data->count )
|
|
|
|
{
|
|
|
|
m_data->count = count;
|
|
|
|
|
|
|
|
resetImplicitSize();
|
|
|
|
update();
|
|
|
|
|
2020-12-17 16:14:56 +01:00
|
|
|
Q_EMIT countChanged( count );
|
2017-07-21 18:21:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void QskPageIndicator::setCurrentIndex( qreal index )
|
|
|
|
{
|
|
|
|
if ( index < 0 || index >= m_data->count )
|
|
|
|
index = -1;
|
|
|
|
|
2018-08-03 08:15:28 +02:00
|
|
|
if ( index != m_data->currentIndex )
|
2017-07-21 18:21:34 +02:00
|
|
|
{
|
|
|
|
m_data->currentIndex = index;
|
|
|
|
update();
|
|
|
|
|
2020-12-17 16:14:56 +01:00
|
|
|
Q_EMIT currentIndexChanged( index );
|
2017-07-21 18:21:34 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#include "moc_QskPageIndicator.cpp"
|