fix my devices

This commit is contained in:
Peter Hartmann 2020-09-08 17:16:30 +02:00
parent 5cd2a693ea
commit cdfb833209
1 changed files with 51 additions and 48 deletions

View File

@ -9,7 +9,8 @@
#include <QImage> #include <QImage>
namespace { namespace
{
class Device : public QskLinearBox class Device : public QskLinearBox
{ {
public: public:
@ -17,14 +18,16 @@ namespace {
: QskLinearBox( Qt::Vertical, parent ) : QskLinearBox( Qt::Vertical, parent )
, m_name( name ) , m_name( name )
{ {
setDefaultAlignment( Qt::AlignCenter );
setAutoAddChildren( false ); setAutoAddChildren( false );
m_icon = new RoundedIcon( QString(), gradient, this ); m_icon = new RoundedIcon( QString(), gradient, this );
m_icon->setOpacity( 0.15 ); m_icon->setOpacity( 0.15 );
m_icon->setPreferredWidth(60); m_icon->setFixedWidth( 60 );
addItem( m_icon ); addItem( m_icon );
auto* textLabel = new QskTextLabel( name, this ); auto* textLabel = new QskTextLabel( name, this );
textLabel->setFontRole( QskSkin::TinyFont );
textLabel->setAlignment( Qt::AlignHCenter ); textLabel->setAlignment( Qt::AlignHCenter );
addItem( textLabel ); addItem( textLabel );
@ -42,8 +45,8 @@ namespace {
QskLinearBox::updateLayout(); QskLinearBox::updateLayout();
m_graphicLabel->setSize( {36, 36} ); m_graphicLabel->setSize( {36, 36} );
m_graphicLabel->setPosition( { ( m_icon->width() - m_graphicLabel->width() ) / 2, m_graphicLabel->setPosition( { m_icon->position().x() + ( m_icon->width() - m_graphicLabel->width() ) / 2,
( m_icon->height() - m_graphicLabel->height() ) / 2 } ); ( m_icon->position().y() + m_icon->height() - m_graphicLabel->height() ) / 2 } );
} }
private: private:
@ -71,9 +74,9 @@ MyDevices::MyDevices(QQuickItem *parent) : QskLinearBox(Qt::Vertical, parent)
auto* musicSystem = new Device( "Music System", gradient2, content ); auto* musicSystem = new Device( "Music System", gradient2, content );
content->addItem( musicSystem, 0, 1 ); content->addItem( musicSystem, 0, 1 );
auto* ac = new Device("AC", gradient1, content); auto* ac = new Device( "AC", gradient2, content );
content->addItem( ac, 1, 0 ); content->addItem( ac, 1, 0 );
auto* router = new Device("Router", gradient2, content); auto* router = new Device( "Router", gradient1, content );
content->addItem( router, 1, 1 ); content->addItem( router, 1, 1 );
} }