Respect focused and pressed state in the skinlet

This commit is contained in:
Clemens Manert 2023-02-12 01:32:21 +01:00
parent d510570943
commit bfc172c04f
No known key found for this signature in database
GPG Key ID: 9197EAE8F85E3A18
3 changed files with 15 additions and 2 deletions

View File

@ -66,6 +66,10 @@ int QskRadioBox::focusedIndex() const {
return m_data->focusedIndex; return m_data->focusedIndex;
} }
int QskRadioBox::pressedIndex() const {
return m_data->pressedIndex;
}
void QskRadioBox::setSelectedIndex( int index ) { void QskRadioBox::setSelectedIndex( int index ) {
if( index == m_data->selectedIndex if( index == m_data->selectedIndex
|| index >= m_data->items.count() ) { || index >= m_data->items.count() ) {

View File

@ -29,9 +29,10 @@ class QSK_EXPORT QskRadioBox : public QskControl
QskRadioBox( const QStringList&, QQuickItem* parent = nullptr ); QskRadioBox( const QStringList&, QQuickItem* parent = nullptr );
QskRadioBox( const QStringList&, int, QQuickItem* parent = nullptr ); QskRadioBox( const QStringList&, int, QQuickItem* parent = nullptr );
int selectedIndex() const;
const QStringList& items() const; const QStringList& items() const;
int selectedIndex() const;
int focusedIndex() const; int focusedIndex() const;
int pressedIndex() const;
public Q_SLOTS: public Q_SLOTS:
void setSelectedIndex( int ); void setSelectedIndex( int );

View File

@ -170,7 +170,15 @@ QskAspect::States QskRadioBoxSkinlet::sampleStates( const QskSkinnable* skinnabl
auto states = Inherited::sampleStates( skinnable, subControl, index ); auto states = Inherited::sampleStates( skinnable, subControl, index );
if( radio->selectedIndex() == index ) { if( radio->selectedIndex() == index ) {
return states | Q::Selected; states |= Q::Selected;
}
if( radio->pressedIndex() == index ) {
states |= Q::Pressed;
}
if( radio->focusedIndex() == index ) {
states |= Q::Focused;
} }
return states; return states;