style menu bar properly

This commit is contained in:
Peter Hartmann 2021-03-26 09:52:45 +01:00
parent 10018cdabf
commit b9a113681c
3 changed files with 27 additions and 12 deletions

View File

@ -57,6 +57,14 @@ void DaytimeSkin::initHints()
QskSkinHintTableEditor ed( &hintTable() ); QskSkinHintTableEditor ed( &hintTable() );
ed.setPadding( MenuBar::Panel, {0, 35, 0, 12} );
ed.setGradient( MenuBar::Panel, {"#6D7BFB"} );
ed.setPadding( MenuItem::Panel, {30, 0, 30, 0} );
QColor color( Qt::white );
color.setAlphaF( 0.09 );
ed.setGradient( MenuItem::Panel | QskControl::Hovered, color );
ed.setGradient( MainContent::Panel, {"#fbfbfb"} ); ed.setGradient( MainContent::Panel, {"#fbfbfb"} );
ed.setGradient( Box::Panel, {"#ffffff"} ); ed.setGradient( Box::Panel, {"#ffffff"} );
ed.setColor( LightDisplay::Panel, "#ffffff" ); ed.setColor( LightDisplay::Panel, "#ffffff" );
@ -65,7 +73,4 @@ void DaytimeSkin::initHints()
ed.setBoxBorderColors( WeekdayBox::Panel, {"#f4f4f4"} ); ed.setBoxBorderColors( WeekdayBox::Panel, {"#f4f4f4"} );
ed.setColor( QskTextLabel::Text, "#000000" ); ed.setColor( QskTextLabel::Text, "#000000" );
QColor color( Qt::white );
color.setAlphaF( 0.09 );
ed.setGradient( MenuItem::Panel | QskControl::Hovered, color );
} }

View File

@ -16,8 +16,6 @@ MenuItem::MenuItem( const QString& name, QQuickItem* parent ) : QskLinearBox( Qt
setAutoLayoutChildren( true ); setAutoLayoutChildren( true );
setAutoAddChildren( true ); setAutoAddChildren( true );
setFixedSize( {140, 40} ); setFixedSize( {140, 40} );
setMargins( {0, 0, 0, 0} );
setPadding( {30, 0, 30, 0} );
setSpacing( 6 ); setSpacing( 6 );
setAcceptHoverEvents( true ); setAcceptHoverEvents( true );
@ -64,15 +62,13 @@ void MenuItem::setActive( bool active )
} }
QSK_SUBCONTROL( MenuBar, Panel )
MenuBar::MenuBar( QQuickItem* parent ) : QskLinearBox( Qt::Vertical, parent ) MenuBar::MenuBar( QQuickItem* parent ) : QskLinearBox( Qt::Vertical, parent )
{ {
setPanel( true );
setSizePolicy( QskSizePolicy::Minimum, QskSizePolicy::Preferred ); setSizePolicy( QskSizePolicy::Minimum, QskSizePolicy::Preferred );
setAutoLayoutChildren( true );
setAutoAddChildren( true );
setSpacing( 8 ); setSpacing( 8 );
setMargins( {0, 35, 0, 12} );
setBackgroundColor( "#6D7BFB" ); // ### style
auto* mainIcon = ":/images/main-icon.png"; auto* mainIcon = ":/images/main-icon.png";
QImage image( mainIcon ); QImage image( mainIcon );
@ -82,10 +78,9 @@ MenuBar::MenuBar( QQuickItem* parent ) : QskLinearBox( Qt::Vertical, parent )
graphicLabel->setMargins( { 50, 0, 50, 54 } ); graphicLabel->setMargins( { 50, 0, 50, 54 } );
graphicLabel->setSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed ); graphicLabel->setSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed );
m_entryStrings = { "Dashboard", "Rooms", "Devices", "Statistics", "Storage", "Members" }; m_entryStrings = { "Dashboard", "Rooms", "Devices", "Statistics", "Storage", "Members" };
for( const auto& entryString : m_entryStrings ) for( const auto& entryString : qAsConst( m_entryStrings ) )
{ {
auto* entry = new MenuItem( entryString, this ); auto* entry = new MenuItem( entryString, this );
m_entries.append( entry ); m_entries.append( entry );
@ -97,3 +92,13 @@ MenuBar::MenuBar( QQuickItem* parent ) : QskLinearBox( Qt::Vertical, parent )
new MenuItem( "Logout", this ); new MenuItem( "Logout", this );
} }
QskAspect::Subcontrol MenuBar::effectiveSubcontrol( QskAspect::Subcontrol subControl ) const
{
if( subControl == QskBox::Panel )
{
return MenuBar::Panel;
}
return subControl;
}

View File

@ -26,8 +26,13 @@ class MenuBar : public QskLinearBox
Q_OBJECT Q_OBJECT
public: public:
QSK_SUBCONTROLS( Panel )
MenuBar( QQuickItem* parent ); MenuBar( QQuickItem* parent );
QskAspect::Subcontrol effectiveSubcontrol(
QskAspect::Subcontrol subControl ) const override final;
private: private:
QList< QString > m_entryStrings; QList< QString > m_entryStrings;
QList< MenuItem* > m_entries; QList< MenuItem* > m_entries;