hmi-demo code uncrustified

This commit is contained in:
Uwe Rathmann 2017-07-25 10:47:40 +02:00
parent fffc983bb7
commit d3be6aaa27
9 changed files with 68 additions and 63 deletions

View File

@ -56,20 +56,20 @@ public:
namespace { namespace {
static inline QFont qskFont( int pointSize ) static inline QFont qskFont( int pointSize )
{ {
QFont font( "Roboto" ); QFont font( "Roboto" );
font.setPointSize( pointSize / qskDpiScaled( 1.0 ) ); font.setPointSize( pointSize / qskDpiScaled( 1.0 ) );
return font; return font;
} }
} }
DefaultSkin::DefaultSkin( const QString &name, QObject *parent ) DefaultSkin::DefaultSkin( const QString& name, QObject* parent ) :
: QskSkin( parent ), QskSkin( parent ),
m_name( name ), m_name( name ),
m_palette( new Palette ), m_palette( new Palette ),
m_scheme( Daylight ) m_scheme( Daylight )
{ {
setObjectName( "DefaultSkin" ); setObjectName( "DefaultSkin" );
initHints(); initHints();

View File

@ -14,7 +14,8 @@ public:
void toggleScheme(); void toggleScheme();
void resetColors(); void resetColors();
enum Scheme { enum Scheme
{
Daylight, Daylight,
Nighttime Nighttime
}; };

View File

@ -12,15 +12,16 @@
#include <QDate> #include <QDate>
#include <QTimer> #include <QTimer>
namespace { namespace
{
void addIcon( QskLayout* layout, const QString& fileName ) void addIcon( QskLayout* layout, const QString& fileName )
{ {
QImage buildIcon( fileName ); const QImage buildIcon( fileName );
QskGraphic graphic = QskGraphic::fromImage( buildIcon );
QskGraphicLabel* buildLabel = new QskGraphicLabel( layout ); QskGraphicLabel* buildLabel = new QskGraphicLabel( layout );
buildLabel->setFixedSize( 76, 36 ); buildLabel->setFixedSize( 76, 36 );
buildLabel->setMargins( QMarginsF( 20, 7, 20, 7 ) ); buildLabel->setMargins( QMarginsF( 20, 7, 20, 7 ) );
buildLabel->setGraphic( graphic ); buildLabel->setGraphic( QskGraphic::fromImage( buildIcon ) );
} }
} }

View File

@ -33,19 +33,19 @@ public:
namespace { namespace {
static inline QFont qskFont( int pointSize ) static inline QFont qskFont( int pointSize )
{ {
QFont font( "Roboto" ); QFont font( "Roboto" );
font.setPointSize( pointSize / qskDpiScaled( 1.0 ) ); font.setPointSize( pointSize / qskDpiScaled( 1.0 ) );
return font; return font;
} }
} }
OtherSkin::OtherSkin( const QString &name, QObject *parent ) OtherSkin::OtherSkin( const QString& name, QObject* parent ) :
: QskSkin( parent ), QskSkin( parent ),
m_name( name ), m_name( name ),
m_palette( new Palette ) m_palette( new Palette )
{ {
setObjectName( "OtherSkin" ); setObjectName( "OtherSkin" );
initHints(); initHints();
@ -75,7 +75,6 @@ void OtherSkin::initHints()
setColor( BalanceFadeBox::Panel, m_palette->color5 ); setColor( BalanceFadeBox::Panel, m_palette->color5 );
setMetric( BalanceFadeBox::Panel | QskAspect::Radius, 15 ); setMetric( BalanceFadeBox::Panel | QskAspect::Radius, 15 );
} }
OtherSkin::~OtherSkin() OtherSkin::~OtherSkin()

View File

@ -8,8 +8,9 @@
#include <QskTabButton.h> #include <QskTabButton.h>
#include <QskTextLabel.h> #include <QskTextLabel.h>
RadioControl::RadioControl( QQuickItem* parent ) : QskControl( parent ) RadioControl::RadioControl( QQuickItem* parent ):
, m_currentBand( "FM" ) QskControl( parent ),
m_currentBand( "FM" )
{ {
setMargins( QMarginsF( 40, 30, 40, 30 ) ); setMargins( QMarginsF( 40, 30, 40, 30 ) );
setAutoLayoutChildren( true ); setAutoLayoutChildren( true );

View File

@ -6,7 +6,7 @@
class RadioControl : public QskControl class RadioControl : public QskControl
{ {
public: public:
RadioControl( QQuickItem *parent = nullptr ); RadioControl( QQuickItem* parent = nullptr );
private: private:
QString m_currentBand; QString m_currentBand;

View File

@ -26,7 +26,7 @@ QskAspect::Subcontrol FilledRectangle::effectiveSubcontrol(
QSK_SUBCONTROL( BalanceFadeBox, Panel ) QSK_SUBCONTROL( BalanceFadeBox, Panel )
QskAspect::Subcontrol BalanceFadeBox::effectiveSubcontrol( QskAspect::Subcontrol BalanceFadeBox::effectiveSubcontrol(
QskAspect::Subcontrol subControl ) const QskAspect::Subcontrol subControl ) const
{ {
if ( subControl == QskPushButton::Panel ) if ( subControl == QskPushButton::Panel )
return BalanceFadeBox::Panel; return BalanceFadeBox::Panel;
@ -36,7 +36,8 @@ QskAspect::Subcontrol BalanceFadeBox::effectiveSubcontrol(
class StackedControl : public QskControl { class StackedControl : public QskControl {
public: public:
StackedControl( QQuickItem* parent = nullptr ) : QskControl( parent ), StackedControl( QQuickItem* parent = nullptr ):
QskControl( parent ),
m_offset( 0.0, 0.0 ) m_offset( 0.0, 0.0 )
{ {
} }
@ -95,7 +96,8 @@ private:
QPointF m_offset; QPointF m_offset;
}; };
SoundControl::SoundControl( QQuickItem *parent ) : QskControl( parent ) SoundControl::SoundControl( QQuickItem* parent ):
QskControl( parent )
{ {
setMargins( QMarginsF( 40, 20, 40, 20 ) ); setMargins( QMarginsF( 40, 20, 40, 20 ) );
setAutoLayoutChildren( true ); setAutoLayoutChildren( true );

View File

@ -12,7 +12,7 @@ class FilledRectangle : public QskPushButton // ### move to some main control fi
public: public:
QSK_SUBCONTROLS( Panel ) QSK_SUBCONTROLS( Panel )
FilledRectangle( QQuickItem* parent ) : QskPushButton( parent ) FilledRectangle( QQuickItem* parent ): QskPushButton( parent )
{ {
setFlat( true ); setFlat( true );
setFixedWidth( 80 ); // ### style setFixedWidth( 80 ); // ### style
@ -27,7 +27,7 @@ class BalanceFadeBox : public QskPushButton
public: public:
QSK_SUBCONTROLS( Panel ) QSK_SUBCONTROLS( Panel )
BalanceFadeBox( QQuickItem* parent ) : QskPushButton( parent ) BalanceFadeBox( QQuickItem* parent ): QskPushButton( parent )
{ {
} }
@ -38,7 +38,7 @@ public:
class SoundControl : public QskControl class SoundControl : public QskControl
{ {
public: public:
SoundControl( QQuickItem *parent = nullptr ); SoundControl( QQuickItem* parent = nullptr );
}; };
#endif // SOUNDCONTROL_H #endif // SOUNDCONTROL_H

View File

@ -12,43 +12,43 @@
namespace { namespace {
class SkinFactory : public QskSkinFactory class SkinFactory : public QskSkinFactory
{ {
Q_OBJECT Q_OBJECT
public: public:
SkinFactory() : QskSkinFactory() SkinFactory(): QskSkinFactory()
{ {
} }
virtual QStringList skinNames() const override final virtual QStringList skinNames() const override final
{ {
return { "DefaultSkin", "OtherSkin" }; return { "DefaultSkin", "OtherSkin" };
} }
virtual QskSkin* createSkin( const QString& skinName ) override virtual QskSkin* createSkin( const QString& skinName ) override
{ {
if ( skinName == "DefaultSkin" ) if ( skinName == "DefaultSkin" )
return new DefaultSkin( skinName ); return new DefaultSkin( skinName );
if ( skinName == "OtherSkin" ) if ( skinName == "OtherSkin" )
return new OtherSkin( skinName ); return new OtherSkin( skinName );
return nullptr; return nullptr;
} }
public Q_SLOTS: public Q_SLOTS:
void toggleScheme() void toggleScheme()
{ {
DefaultSkin* skin = static_cast< DefaultSkin* >( qskSetup->skin() ); DefaultSkin* skin = static_cast< DefaultSkin* >( qskSetup->skin() );
if ( skin ) if ( skin )
skin->toggleScheme(); skin->toggleScheme();
} }
}; };
} }
int main( int argc, char **argv ) int main( int argc, char** argv )
{ {
QGuiApplication app( argc, argv ); QGuiApplication app( argc, argv );
@ -59,10 +59,11 @@ int main( int argc, char **argv )
SkinnyShortcut::enable( SkinnyShortcut::DebugBackground | SkinnyShortcut::Quit | SkinnyShortcut::RotateSkin ); SkinnyShortcut::enable( SkinnyShortcut::DebugBackground | SkinnyShortcut::Quit | SkinnyShortcut::RotateSkin );
QskShortcut::addShortcut( QKeySequence( Qt::CTRL + Qt::Key_T ), &skinFactory, QskShortcut::addShortcut( QKeySequence( Qt::CTRL + Qt::Key_T ), &skinFactory,
SLOT( toggleScheme() ), false ); SLOT(toggleScheme()), false );
MainWindow mainWindow; MainWindow mainWindow;
mainWindow.show(); mainWindow.show();
return app.exec(); return app.exec();
} }