menu item states instead of own API
This commit is contained in:
parent
aa6d3eba1b
commit
dd124afcf1
|
@ -12,6 +12,8 @@ QSK_SUBCONTROL( MenuBarGraphicLabel, Graphic )
|
|||
QSK_SUBCONTROL( MenuBarLabel, Text )
|
||||
QSK_SUBCONTROL( MenuItem, Panel )
|
||||
|
||||
QSK_STATE( MenuItem, Active, ( QskAspect::FirstUserState << 1 ) )
|
||||
|
||||
MenuItem::MenuItem( const QString& name, QQuickItem* parent ) : QskLinearBox( Qt::Horizontal, parent ),
|
||||
m_name( name )
|
||||
{
|
||||
|
@ -43,23 +45,6 @@ QskAspect::Subcontrol MenuItem::effectiveSubcontrol( QskAspect::Subcontrol subCo
|
|||
return subControl;
|
||||
}
|
||||
|
||||
void MenuItem::setActive( bool active )
|
||||
{
|
||||
QColor color;
|
||||
|
||||
if( active )
|
||||
{
|
||||
color = Qt::white;
|
||||
color.setAlphaF( 0.14 );
|
||||
}
|
||||
else
|
||||
{
|
||||
color = Qt::transparent;
|
||||
}
|
||||
|
||||
setBackgroundColor( color );
|
||||
}
|
||||
|
||||
|
||||
QSK_SUBCONTROL( MenuBar, Panel )
|
||||
|
||||
|
@ -85,7 +70,7 @@ MenuBar::MenuBar( QQuickItem* parent ) : QskLinearBox( Qt::Vertical, parent )
|
|||
m_entries.append( entry );
|
||||
}
|
||||
|
||||
m_entries.at( m_activeEntry )->setActive( true );
|
||||
m_entries.at( m_activeEntry )->setSkinState( MenuItem::Active );
|
||||
|
||||
addSpacer( 0, 1 ); // fill the space at the bottom
|
||||
|
||||
|
|
|
@ -59,13 +59,12 @@ class MenuItem : public QskLinearBox
|
|||
|
||||
public:
|
||||
QSK_SUBCONTROLS( Panel )
|
||||
QSK_STATES( Active )
|
||||
|
||||
MenuItem( const QString& name, QQuickItem* parent );
|
||||
|
||||
QskAspect::Subcontrol effectiveSubcontrol( QskAspect::Subcontrol subControl ) const override final;
|
||||
|
||||
void setActive( bool active );
|
||||
|
||||
private:
|
||||
QString m_name;
|
||||
bool m_isActive = false;
|
||||
|
|
|
@ -68,6 +68,8 @@ void Skin::initHints( const Palette& palette )
|
|||
QColor color( Qt::white );
|
||||
color.setAlphaF( 0.09 );
|
||||
ed.setGradient( MenuItem::Panel | QskControl::Hovered, color );
|
||||
color.setAlphaF( 0.14 );
|
||||
ed.setGradient( MenuItem::Panel | MenuItem::Active, color );
|
||||
|
||||
ed.setColor( MenuBarLabel::Text, Qt::white );
|
||||
ed.setFontRole( MenuBarLabel::Text, QskSkin::SmallFont );
|
||||
|
|
Loading…
Reference in New Issue