getting rid of the confusing QskAbstractButton::Checkable state
This commit is contained in:
parent
1b4be3bc23
commit
66cc68bcda
@ -27,7 +27,7 @@ void SwitchButtonPage::populate()
|
||||
hbox1->setSizePolicy( Qt::Vertical, QskSizePolicy::Fixed );
|
||||
hbox1->setExtraSpacingAt( Qt::LeftEdge );
|
||||
|
||||
auto label = new QskTextLabel( "Disable the boxes: ", hbox1 );
|
||||
auto label = new QskTextLabel( "Disable the switches:", hbox1 );
|
||||
label->setSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed );
|
||||
|
||||
auto button0 = new QskSwitchButton( hbox1 );
|
||||
|
@ -45,7 +45,6 @@ MyToggleButton::MyToggleButton( QQuickItem* parent )
|
||||
: Inherited( parent )
|
||||
, m_data( new PrivateData() )
|
||||
{
|
||||
setCheckable( true );
|
||||
setAcceptHoverEvents( false );
|
||||
|
||||
initSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed );
|
||||
@ -55,6 +54,11 @@ MyToggleButton::~MyToggleButton()
|
||||
{
|
||||
}
|
||||
|
||||
bool MyToggleButton::isCheckable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void MyToggleButton::setInverted( bool on )
|
||||
{
|
||||
if ( m_data->inverted != on )
|
||||
|
@ -23,6 +23,8 @@ class MyToggleButton : public QskAbstractButton
|
||||
MyToggleButton( QQuickItem* parent = nullptr );
|
||||
~MyToggleButton() override;
|
||||
|
||||
bool isCheckable() const override final;
|
||||
|
||||
void setTextAt( int index, const QString& );
|
||||
QString textAt( int index ) const;
|
||||
|
||||
|
@ -335,7 +335,7 @@ void Editor::setupPushButton()
|
||||
setFontRole( Q::Text, ButtonFontRole );
|
||||
setAlignment( Q::Text, Qt::AlignCenter );
|
||||
|
||||
for ( auto state1 : { A::NoState, Q::Checkable, Q::Focused, Q::Focused | Q::Checkable } )
|
||||
for ( auto state1 : { A::NoState, Q::Focused } )
|
||||
{
|
||||
setBoxBorderColors( Q::Panel | Q::Hovered | state1, borderColors );
|
||||
setBoxBorderColors( Q::Panel | Q::Hovered | Q::Flat | state1, borderColors );
|
||||
@ -387,7 +387,7 @@ void Editor::setupDialogButton()
|
||||
setFontRole( Q::Text, ButtonFontRole );
|
||||
setAlignment( Q::Text, Qt::AlignCenter );
|
||||
|
||||
for ( auto state1 : { A::NoState, Q::Checkable, Q::Focused, Q::Focused | Q::Checkable } )
|
||||
for ( auto state1 : { A::NoState, Q::Focused } )
|
||||
{
|
||||
setBoxBorderColors( Q::Panel | Q::Hovered | state1, borderColors );
|
||||
|
||||
@ -502,8 +502,8 @@ void Editor::setupSwitchButton()
|
||||
setStrutSize( Q::Groove | A::Vertical, grooveSize.transposed() );
|
||||
|
||||
setGradient( Q::Groove, m_pal.darker125 );
|
||||
setGradient( Q::Groove | Q::Checkable | Q::Disabled, m_pal.lighter150 );
|
||||
setGradient( Q::Groove | Q::Checkable | Q::Checked, m_pal.darker200 );
|
||||
setGradient( Q::Groove | Q::Disabled, m_pal.lighter150 );
|
||||
setGradient( Q::Groove | Q::Checked, m_pal.darker200 );
|
||||
|
||||
setBoxBorderColors( Q::Groove, m_pal.darker200 );
|
||||
setBoxBorderMetrics( Q::Groove, 2 );
|
||||
@ -514,7 +514,7 @@ void Editor::setupSwitchButton()
|
||||
setBoxBorderMetrics( Q::Handle, 2 );
|
||||
|
||||
setGradient( Q::Handle, QskGradient( Qt::Vertical, m_pal.lighter150, m_pal.lighter125 ) );
|
||||
setGradient( Q::Handle | Q::Checkable | Q::Checked, m_pal.accentColor );
|
||||
setGradient( Q::Handle | Q::Checked, m_pal.accentColor );
|
||||
|
||||
setGradient( Q::Handle | Q::Disabled, m_pal.lighter125 );
|
||||
setBoxBorderColors( Q::Handle, m_pal.darker200 );
|
||||
@ -522,7 +522,7 @@ void Editor::setupSwitchButton()
|
||||
|
||||
for( auto state : { A::NoState, Q::Disabled } )
|
||||
{
|
||||
auto aspect = Q::Handle | Q::Checkable | state | A::Position;
|
||||
auto aspect = Q::Handle | state | A::Position;
|
||||
|
||||
setMetric( aspect, 0 );
|
||||
setMetric( aspect | Q::Checked, 1 );
|
||||
@ -581,7 +581,7 @@ void Editor::setupTabButton()
|
||||
setBoxBorderColors( aspect, borderColors );
|
||||
|
||||
borderColors.setColorsAt( edge, m_pal.accentColor );
|
||||
for ( auto state : { Q::Checked, Q::Pressed, Q::Checkable | Q::Hovered } )
|
||||
for ( auto state : { Q::Checked, Q::Pressed, Q::Hovered } )
|
||||
setBoxBorderColors( aspect | state, borderColors );
|
||||
}
|
||||
|
||||
@ -592,8 +592,7 @@ void Editor::setupTabButton()
|
||||
setAlignment( Q::Text, Qt::AlignCenter );
|
||||
|
||||
setColor( Q::Text, m_pal.textColor );
|
||||
setColor( Q::Text | Q::Checkable | Q::Disabled, qskShadedColor( m_pal.textColor, 0.6 ) );
|
||||
setColor( Q::Text | Q::Disabled, QskRgb::Grey600 );
|
||||
setColor( Q::Text | Q::Disabled, qskShadedColor( m_pal.textColor, 0.6 ) );
|
||||
}
|
||||
|
||||
void Editor::setupTabBar()
|
||||
|
@ -437,14 +437,11 @@ void Editor::setupPushButton()
|
||||
setPadding( Q::Panel, 10 );
|
||||
setMetric( Q::Panel | A::Spacing, 4 );
|
||||
|
||||
for ( auto state : { A::NoState, Q::Checkable } )
|
||||
{
|
||||
setButton( Q::Panel | state, Raised );
|
||||
setButton( Q::Panel | Q::Flat | Q::Hovered | state, Raised );
|
||||
setButton( Q::Panel, Raised );
|
||||
setButton( Q::Panel | Q::Flat | Q::Hovered, Raised );
|
||||
|
||||
setButton( Q::Panel | Q::Flat | state, Flat );
|
||||
setButton( Q::Panel | Q::Flat | Q::Disabled | state, Flat );
|
||||
}
|
||||
setButton( Q::Panel | Q::Flat, Flat );
|
||||
setButton( Q::Panel | Q::Flat | Q::Disabled, Flat );
|
||||
|
||||
for ( auto state : { Q::Pressed, Q::Checked } )
|
||||
{
|
||||
@ -601,7 +598,7 @@ void Editor::setupTabButton()
|
||||
// text
|
||||
setAlignment( Q::Text, Qt::AlignCenter );
|
||||
setColor( Q::Text, m_pal.themeForeground );
|
||||
setColor( Q::Text | Q::Checkable | Q::Disabled, m_pal.darker200 );
|
||||
setColor( Q::Text | Q::Disabled, m_pal.darker200 );
|
||||
}
|
||||
|
||||
void Editor::setupSlider()
|
||||
@ -868,8 +865,8 @@ void Editor::setupSwitchButton()
|
||||
setStrutSize( Q::Groove | A::Vertical, grooveSize.transposed() );
|
||||
|
||||
setGradient( Q::Groove, m_pal.theme );
|
||||
setGradient( Q::Groove | Q::Checkable | Q::Checked, m_pal.highlighted );
|
||||
setGradient( Q::Groove | Q::Checkable | Q::Disabled, m_pal.lighter150 );
|
||||
setGradient( Q::Groove | Q::Checked, m_pal.highlighted );
|
||||
setGradient( Q::Groove | Q::Disabled, m_pal.lighter150 );
|
||||
|
||||
setBoxBorderColors( Q::Groove | Q::Disabled, m_pal.theme );
|
||||
setBoxBorderMetrics( Q::Groove, 2 );
|
||||
@ -887,7 +884,7 @@ void Editor::setupSwitchButton()
|
||||
|
||||
for( auto state : { A::NoState, Q::Disabled } )
|
||||
{
|
||||
auto aspect = Q::Handle | Q::Checkable | state | A::Position;
|
||||
auto aspect = Q::Handle | state | A::Position;
|
||||
|
||||
setMetric( aspect, 0 );
|
||||
setMetric( aspect | Q::Checked, 1 );
|
||||
|
@ -12,12 +12,13 @@
|
||||
|
||||
// Flat/Checkable are no states - we need to get rid of them. TODO ...
|
||||
QSK_SYSTEM_STATE( QskAbstractButton, Flat, QskAspect::FirstSystemState << 1 )
|
||||
|
||||
#if 1
|
||||
// Wrong: we are overlapping with the user states, TODO ...
|
||||
QSK_STATE( QskAbstractButton, Checked, QskAspect::LastUserState )
|
||||
#endif
|
||||
|
||||
QSK_SYSTEM_STATE( QskAbstractButton, Pressed, QskAspect::LastSystemState >> 3 )
|
||||
QSK_SYSTEM_STATE( QskAbstractButton, Checkable, QskAspect::LastSystemState >> 2 )
|
||||
|
||||
static QskAbstractButton* qskCheckedSibling( const QskAbstractButton* button )
|
||||
{
|
||||
@ -82,7 +83,7 @@ void QskAbstractButton::releaseButton()
|
||||
if ( !isPressed() )
|
||||
return;
|
||||
|
||||
if ( skinState() & Checkable )
|
||||
if ( isCheckable() )
|
||||
{
|
||||
// we will have toggled before released,
|
||||
// maybe there is more work to have the signals coming
|
||||
@ -136,18 +137,9 @@ void QskAbstractButton::setPressed( bool on )
|
||||
}
|
||||
}
|
||||
|
||||
void QskAbstractButton::setCheckable( bool on )
|
||||
{
|
||||
if ( on == isCheckable() )
|
||||
return;
|
||||
|
||||
setSkinStateFlag( Checkable, on );
|
||||
Q_EMIT checkableChanged( on );
|
||||
}
|
||||
|
||||
bool QskAbstractButton::isCheckable() const
|
||||
{
|
||||
return skinState() & Checkable;
|
||||
return false;
|
||||
}
|
||||
|
||||
void QskAbstractButton::setChecked( bool on )
|
||||
|
@ -12,9 +12,6 @@ class QSK_EXPORT QskAbstractButton : public QskControl
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
Q_PROPERTY( bool checkable READ isCheckable
|
||||
WRITE setCheckable NOTIFY checkableChanged FINAL )
|
||||
|
||||
Q_PROPERTY( bool autoRepeat READ autoRepeat
|
||||
WRITE setAutoRepeat NOTIFY autoRepeatChanged FINAL )
|
||||
|
||||
@ -36,14 +33,12 @@ class QSK_EXPORT QskAbstractButton : public QskControl
|
||||
using Inherited = QskControl;
|
||||
|
||||
public:
|
||||
QSK_STATES( Flat, Checked, Pressed, Checkable )
|
||||
QSK_STATES( Flat, Checked, Pressed )
|
||||
|
||||
QskAbstractButton( QQuickItem* parent = nullptr );
|
||||
~QskAbstractButton() override;
|
||||
|
||||
void setCheckable( bool );
|
||||
bool isCheckable() const;
|
||||
|
||||
virtual bool isCheckable() const;
|
||||
bool isChecked() const;
|
||||
|
||||
void setPressed( bool on );
|
||||
|
@ -25,7 +25,7 @@ class QskPushButton::PrivateData
|
||||
public:
|
||||
PrivateData( const QString& txt )
|
||||
: text( txt )
|
||||
, graphicSourceSize( -1, -1 )
|
||||
, isCheckable( false )
|
||||
, isGraphicSourceDirty( false )
|
||||
{
|
||||
textOptions.setElideMode( Qt::ElideMiddle );
|
||||
@ -50,6 +50,7 @@ class QskPushButton::PrivateData
|
||||
|
||||
QSizeF graphicSourceSize;
|
||||
|
||||
bool isCheckable : 1;
|
||||
bool isGraphicSourceDirty : 1;
|
||||
};
|
||||
|
||||
@ -69,6 +70,20 @@ QskPushButton::~QskPushButton()
|
||||
{
|
||||
}
|
||||
|
||||
void QskPushButton::setCheckable( bool on )
|
||||
{
|
||||
if ( on != m_data->isCheckable )
|
||||
{
|
||||
m_data->isCheckable = on;
|
||||
Q_EMIT checkableChanged( on );
|
||||
}
|
||||
}
|
||||
|
||||
bool QskPushButton::isCheckable() const
|
||||
{
|
||||
return m_data->isCheckable;
|
||||
}
|
||||
|
||||
void QskPushButton::setCorner( const QskCorner& corner )
|
||||
{
|
||||
if ( setBoxShapeHint( Panel, corner.metrics() ) )
|
||||
|
@ -33,6 +33,9 @@ class QSK_EXPORT QskPushButton : public QskAbstractButton
|
||||
WRITE setGraphicSourceSize RESET resetGraphicSourceSize
|
||||
NOTIFY graphicSourceSizeChanged FINAL )
|
||||
|
||||
Q_PROPERTY( bool checkable READ isCheckable
|
||||
WRITE setCheckable NOTIFY checkableChanged FINAL )
|
||||
|
||||
Q_PROPERTY( bool flat READ isFlat WRITE setFlat NOTIFY flatChanged FINAL )
|
||||
Q_PROPERTY( QskCorner corner READ corner WRITE setCorner NOTIFY cornerChanged )
|
||||
|
||||
@ -46,6 +49,9 @@ class QSK_EXPORT QskPushButton : public QskAbstractButton
|
||||
|
||||
~QskPushButton() override;
|
||||
|
||||
void setCheckable( bool );
|
||||
bool isCheckable() const override final;
|
||||
|
||||
void setCorner( const QskCorner& );
|
||||
QskCorner corner() const;
|
||||
|
||||
@ -76,8 +82,8 @@ class QSK_EXPORT QskPushButton : public QskAbstractButton
|
||||
void setGraphicSourceSize( const QSizeF& );
|
||||
|
||||
Q_SIGNALS:
|
||||
void checkableChanged( bool );
|
||||
void cornerChanged();
|
||||
void borderWidthChanged();
|
||||
void textChanged();
|
||||
void textOptionsChanged();
|
||||
void flatChanged();
|
||||
|
@ -23,7 +23,6 @@ QskSwitchButton::QskSwitchButton( Qt::Orientation orientation, QQuickItem* paren
|
||||
: QskAbstractButton( parent )
|
||||
, m_data( new PrivateData( orientation ) )
|
||||
{
|
||||
setCheckable( true );
|
||||
initSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed );
|
||||
}
|
||||
|
||||
@ -31,6 +30,11 @@ QskSwitchButton::~QskSwitchButton()
|
||||
{
|
||||
}
|
||||
|
||||
bool QskSwitchButton::isCheckable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
Qt::Orientation QskSwitchButton::orientation() const
|
||||
{
|
||||
return m_data->orientation;
|
||||
|
@ -24,6 +24,8 @@ class QSK_EXPORT QskSwitchButton : public QskAbstractButton
|
||||
|
||||
~QskSwitchButton() override;
|
||||
|
||||
bool isCheckable() const final;
|
||||
|
||||
Qt::Orientation orientation() const;
|
||||
void setOrientation(Qt::Orientation);
|
||||
|
||||
|
@ -48,7 +48,6 @@ QskTabButton::QskTabButton( const QString& text, QQuickItem* parent )
|
||||
initSizePolicy( QskSizePolicy::MinimumExpanding,
|
||||
QskSizePolicy::QskSizePolicy::MinimumExpanding );
|
||||
|
||||
setCheckable( true );
|
||||
setExclusive( true );
|
||||
}
|
||||
|
||||
@ -56,6 +55,11 @@ QskTabButton::~QskTabButton()
|
||||
{
|
||||
}
|
||||
|
||||
bool QskTabButton::isCheckable() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void QskTabButton::setText( const QString& text )
|
||||
{
|
||||
if ( m_data->text == text )
|
||||
|
@ -30,6 +30,8 @@ class QSK_EXPORT QskTabButton : public QskAbstractButton
|
||||
|
||||
~QskTabButton() override;
|
||||
|
||||
bool isCheckable() const override final;
|
||||
|
||||
void setText( const QString& text );
|
||||
QString text() const;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user