diff --git a/playground/dashboard/ButtonBar.cpp b/playground/dashboard/ButtonBar.cpp deleted file mode 100644 index 69d27844..00000000 --- a/playground/dashboard/ButtonBar.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/****************************************************************************** - * QSkinny - Copyright (C) 2016 Uwe Rathmann - * This file may be used under the terms of the 3-clause BSD License - *****************************************************************************/ - -#include "ButtonBar.h" -#include "SkinFactory.h" - -#include -#include -#include -#include - -QSK_SUBCONTROL( ButtonBar, Indicator ) - -namespace -{ - class IndicatorLabel final : public QskGraphicLabel - { - public: - IndicatorLabel( QQuickItem* parentItem = nullptr ) - : QskGraphicLabel( parentItem ) - { - // so the skins are able to colorize them - setGraphicRole( SkinFactory::Indicator ); - setSubcontrolProxy( QskGraphicLabel::Graphic, ButtonBar::Indicator ); - } - }; -} - -ButtonBar::ButtonBar( QQuickItem* parentItem ) - : QskLinearBox( parentItem ) -{ - QColor c( Qt::black ); - c.setAlphaF( 0.5 ); - setBackgroundColor( c ); - - setMargins( QskMargins( 20, 15 ) ); - setSpacing( 20 ); - - setSizePolicy( QskSizePolicy::MinimumExpanding, QskSizePolicy::MinimumExpanding ); -} - -void ButtonBar::addIndicator( const char* name ) -{ - auto label = new IndicatorLabel( this ); - - /* - The label should adjust vertically and be stretched horizontally - according to its aspect ratio. - */ - - label->setSizePolicy( QskSizePolicy::Constrained, QskSizePolicy::Ignored ); - - const QString fileName = QString( ":/qvg/%1.qvg" ).arg( name ); - label->setGraphic( QskGraphicIO::read( fileName ) ); -} - -QSizeF ButtonBar::layoutSizeHint( - Qt::SizeHint which, const QSizeF& ) const -{ - if ( which == Qt::PreferredSize ) - return QSizeF( -1, 20 ); - - return QSizeF(); -} diff --git a/playground/dashboard/ButtonBar.h b/playground/dashboard/ButtonBar.h deleted file mode 100644 index a30f1e9d..00000000 --- a/playground/dashboard/ButtonBar.h +++ /dev/null @@ -1,20 +0,0 @@ -/****************************************************************************** - * QSkinny - Copyright (C) 2016 Uwe Rathmann - * This file may be used under the terms of the 3-clause BSD License - *****************************************************************************/ - -#pragma once - -#include - -class ButtonBar : public QskLinearBox -{ - public: - QSK_SUBCONTROLS( Indicator ) - - ButtonBar( QQuickItem* = nullptr ); - void addIndicator( const char* name ); - - protected: - QSizeF layoutSizeHint( Qt::SizeHint, const QSizeF& ) const override; -}; diff --git a/playground/dashboard/SpeedometerDisplay.cpp b/playground/dashboard/Dashboard.cpp similarity index 77% rename from playground/dashboard/SpeedometerDisplay.cpp rename to playground/dashboard/Dashboard.cpp index e51a4fc0..d90b1ba9 100644 --- a/playground/dashboard/SpeedometerDisplay.cpp +++ b/playground/dashboard/Dashboard.cpp @@ -3,23 +3,20 @@ * This file may be used under the terms of the 3-clause BSD License *****************************************************************************/ -#include "SpeedometerDisplay.h" -#include "Speedometer.h" +#include "Dashboard.h" +#include "Dial.h" #include -#include #include -#include - namespace { - class Dial : public Speedometer + class DashboardDial : public Dial { public: - Dial( const QString& title, QQuickItem* parent = nullptr ) - : Speedometer( parent ) + DashboardDial( const QString& title, QQuickItem* parent = nullptr ) + : Dial( parent ) { setPolishOnResize( true ); m_label = new QskTextLabel( title, this ); @@ -42,11 +39,11 @@ namespace QskTextLabel* m_label; }; - class RevCounter : public Dial + class RevCounter : public DashboardDial { public: RevCounter( QQuickItem* parent = nullptr ) - : Dial( "x 1000 min^-1", parent ) + : DashboardDial( "x 1000 min^-1", parent ) { setMinimum( 145 ); setMaximum( 305 ); @@ -64,11 +61,11 @@ namespace } }; - class Speedo : public Dial + class SpeedoMeter : public DashboardDial { public: - Speedo( QQuickItem* parent = nullptr ) - : Dial( "km/h", parent ) + SpeedoMeter( QQuickItem* parent = nullptr ) + : DashboardDial( "km/h", parent ) { setMinimum( -215 ); setMaximum( 35 ); @@ -91,11 +88,11 @@ namespace } }; - class FuelGauge : public Dial + class FuelGauge : public DashboardDial { public: FuelGauge( QQuickItem* parent = nullptr ) - : Dial( "fuel", parent ) + : DashboardDial( "fuel", parent ) { setMinimum( 195 ); setMaximum( 345 ); @@ -111,13 +108,11 @@ namespace }; } -SpeedometerDisplay::SpeedometerDisplay( QQuickItem* parent ) +Dashboard::Dashboard( QQuickItem* parent ) : QskLinearBox( Qt::Horizontal, parent ) { - std::srand( static_cast< uint >( QTime::currentTime().msec() ) ); - (void ) new RevCounter( this ); - auto speedometer = new Speedo( this ); + auto speedometer = new SpeedoMeter( this ); auto fuelGauge = new FuelGauge( this ); setMargins( 10 ); @@ -125,7 +120,7 @@ SpeedometerDisplay::SpeedometerDisplay( QQuickItem* parent ) auto timer = new QTimer( this ); - connect( timer, &QTimer::timeout, speedometer, &Speedo::updateValue ); + connect( timer, &QTimer::timeout, speedometer, &SpeedoMeter::updateValue ); connect( timer, &QTimer::timeout, fuelGauge, &FuelGauge::updateValue ); timer->setInterval( 16 ); diff --git a/playground/dashboard/SpeedometerDisplay.h b/playground/dashboard/Dashboard.h similarity index 76% rename from playground/dashboard/SpeedometerDisplay.h rename to playground/dashboard/Dashboard.h index 34801b10..afc00340 100644 --- a/playground/dashboard/SpeedometerDisplay.h +++ b/playground/dashboard/Dashboard.h @@ -7,8 +7,8 @@ #include -class SpeedometerDisplay : public QskLinearBox +class Dashboard : public QskLinearBox { public: - SpeedometerDisplay( QQuickItem* parent = nullptr ); + Dashboard( QQuickItem* parent = nullptr ); }; diff --git a/playground/dashboard/Speedometer.cpp b/playground/dashboard/Dial.cpp similarity index 53% rename from playground/dashboard/Speedometer.cpp rename to playground/dashboard/Dial.cpp index 4e8b319c..27c67c2a 100644 --- a/playground/dashboard/Speedometer.cpp +++ b/playground/dashboard/Dial.cpp @@ -3,29 +3,29 @@ * This file may be used under the terms of the 3-clause BSD License *****************************************************************************/ -#include "Speedometer.h" +#include "Dial.h" #include #include -QSK_SUBCONTROL( Speedometer, Panel ) -QSK_SUBCONTROL( Speedometer, TickLabels ) -QSK_SUBCONTROL( Speedometer, Knob ) -QSK_SUBCONTROL( Speedometer, Needle ) +QSK_SUBCONTROL( Dial, Panel ) +QSK_SUBCONTROL( Dial, TickLabels ) +QSK_SUBCONTROL( Dial, Knob ) +QSK_SUBCONTROL( Dial, Needle ) -Speedometer::Speedometer( QQuickItem* parent ) +Dial::Dial( QQuickItem* parent ) : QskBoundedValueInput( parent ) { } -QVector< QString > Speedometer::tickLabels() const +QVector< QString > Dial::tickLabels() const { return m_tickLabels; } -void Speedometer::setTickLabels( const QVector< QString >& labels ) +void Dial::setTickLabels( const QVector< QString >& labels ) { m_tickLabels = labels; } -#include "moc_Speedometer.cpp" +#include "moc_Dial.cpp" diff --git a/playground/dashboard/Speedometer.h b/playground/dashboard/Dial.h similarity index 85% rename from playground/dashboard/Speedometer.h rename to playground/dashboard/Dial.h index b27b8248..ef14261b 100644 --- a/playground/dashboard/Speedometer.h +++ b/playground/dashboard/Dial.h @@ -7,14 +7,14 @@ #include -class Speedometer : public QskBoundedValueInput +class Dial : public QskBoundedValueInput { Q_OBJECT public: QSK_SUBCONTROLS( Panel, TickLabels, Knob, Needle ) - Speedometer( QQuickItem* parent = nullptr ); + Dial( QQuickItem* parent = nullptr ); QVector< QString > tickLabels() const; void setTickLabels( const QVector< QString >& ); diff --git a/playground/dashboard/SpeedometerSkinlet.cpp b/playground/dashboard/DialSkinlet.cpp similarity index 72% rename from playground/dashboard/SpeedometerSkinlet.cpp rename to playground/dashboard/DialSkinlet.cpp index 3b3aa6d7..ffee9a37 100644 --- a/playground/dashboard/SpeedometerSkinlet.cpp +++ b/playground/dashboard/DialSkinlet.cpp @@ -3,8 +3,8 @@ * This file may be used under the terms of the 3-clause BSD License *****************************************************************************/ -#include "SpeedometerSkinlet.h" -#include "Speedometer.h" +#include "DialSkinlet.h" +#include "Dial.h" #include #include @@ -78,20 +78,20 @@ namespace }; } -SpeedometerSkinlet::SpeedometerSkinlet( QskSkin* skin ) +DialSkinlet::DialSkinlet( QskSkin* skin ) : QskSkinlet( skin ) { setNodeRoles( { PanelRole, NeedleRole, KnobRole, LabelsRole } ); } -QRectF SpeedometerSkinlet::subControlRect( const QskSkinnable* skinnable, +QRectF DialSkinlet::subControlRect( const QskSkinnable* skinnable, const QRectF& contentsRect, QskAspect::Subcontrol subcontrol ) const { QRectF r; - if ( subcontrol == Speedometer::Knob ) + if ( subcontrol == Dial::Knob ) { - const auto size = skinnable->strutSizeHint( Speedometer::Knob ); + const auto size = skinnable->strutSizeHint( Dial::Knob ); r.setSize( size ); } else @@ -105,18 +105,18 @@ QRectF SpeedometerSkinlet::subControlRect( const QskSkinnable* skinnable, return r; } -QSGNode* SpeedometerSkinlet::updateSubNode( +QSGNode* DialSkinlet::updateSubNode( const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const { - const auto speedometer = static_cast< const Speedometer* >( skinnable ); + const auto speedometer = static_cast< const Dial* >( skinnable ); switch ( nodeRole ) { case PanelRole: - return updateBoxNode( speedometer, node, Speedometer::Panel ); + return updateBoxNode( speedometer, node, Dial::Panel ); case KnobRole: - return updateBoxNode( speedometer, node, Speedometer::Knob ); + return updateBoxNode( speedometer, node, Dial::Knob ); case NeedleRole: return updateNeedleNode( speedometer, node ); @@ -130,12 +130,12 @@ QSGNode* SpeedometerSkinlet::updateSubNode( } } -QSGNode* SpeedometerSkinlet::updateLabelsNode( - const Speedometer* speedometer, QSGNode* node ) const +QSGNode* DialSkinlet::updateLabelsNode( + const Dial* dial, QSGNode* node ) const { - using Q = Speedometer; + using Q = Dial; - const auto labels = speedometer->tickLabels(); + const auto labels = dial->tickLabels(); // ### actually, we could draw labels with only one entry if ( labels.count() <= 1 ) @@ -145,11 +145,11 @@ QSGNode* SpeedometerSkinlet::updateLabelsNode( if ( ticksNode == nullptr ) ticksNode = new TicksNode(); - const auto color = speedometer->color( Q::TickLabels ); + const auto color = dial->color( Q::TickLabels ); ticksNode->setColor( color ); - const auto startAngle = speedometer->minimum(); - const auto endAngle = speedometer->maximum(); + const auto startAngle = dial->minimum(); + const auto endAngle = dial->maximum(); const auto step = ( endAngle - startAngle ) / ( labels.count() - 1 ); auto geometry = ticksNode->geometry(); @@ -157,19 +157,19 @@ QSGNode* SpeedometerSkinlet::updateLabelsNode( auto vertexData = geometry->vertexDataAsPoint2D(); - auto scaleRect = this->scaleRect( speedometer ); + auto scaleRect = this->scaleRect( dial ); const auto center = scaleRect.center(); const auto radius = 0.5 * scaleRect.width(); - const auto spacing = speedometer->spacingHint( Q::TickLabels ); + const auto spacing = dial->spacingHint( Q::TickLabels ); - const auto font = speedometer->effectiveFont( Q::TickLabels ); + const auto font = dial->effectiveFont( Q::TickLabels ); const QFontMetricsF fontMetrics( font ); auto angle = startAngle; - const auto tickSize = speedometer->strutSizeHint( Q::TickLabels ); + const auto tickSize = dial->strutSizeHint( Q::TickLabels ); const auto needleRadius = radius - tickSize.height(); // Create a series of tickmarks from minimum to maximum @@ -207,7 +207,7 @@ QSGNode* SpeedometerSkinlet::updateLabelsNode( const QRectF numbersRect( numbersX, numbersY, w, h ); labelNode = QskSkinlet::updateTextNode( - speedometer, labelNode, numbersRect, Qt::AlignCenter | Qt::AlignHCenter, + dial, labelNode, numbersRect, Qt::AlignCenter | Qt::AlignHCenter, text, font, QskTextOptions(), QskTextColors( color ), Qsk::Normal ); if ( labelNode ) @@ -228,48 +228,47 @@ QSGNode* SpeedometerSkinlet::updateLabelsNode( return ticksNode; } -QSGNode* SpeedometerSkinlet::updateNeedleNode( - const Speedometer* speedometer, QSGNode* node ) const +QSGNode* DialSkinlet::updateNeedleNode( + const Dial* dial, QSGNode* node ) const { - using Q = Speedometer; + using Q = Dial; auto needleNode = static_cast< NeedleNode* >( node ); if ( needleNode == nullptr ) needleNode = new NeedleNode(); - const auto line = needlePoints( speedometer ); - const auto width = speedometer->metric( Q::Needle | QskAspect::Size ); + const auto line = needlePoints( dial ); + const auto width = dial->metric( Q::Needle | QskAspect::Size ); needleNode->setData( line, width * 2 ); - needleNode->setColor( speedometer->color( Q::Needle ) ); + needleNode->setColor( dial->color( Q::Needle ) ); return needleNode; } -QRectF SpeedometerSkinlet::scaleRect( const Speedometer* speedometer ) const +QRectF DialSkinlet::scaleRect( const Dial* dial ) const { - using Q = Speedometer; + using Q = Dial; - const auto margins = speedometer->marginHint( Q::Panel ); + const auto margins = dial->marginHint( Q::Panel ); - auto r = speedometer->subControlRect( Q::Panel ); + auto r = dial->subControlRect( Q::Panel ); r = r.marginsRemoved( margins ); return r; } -QLineF SpeedometerSkinlet::needlePoints( const Speedometer* speedometer ) const +QLineF DialSkinlet::needlePoints( const Dial* dial ) const { - const auto r = scaleRect( speedometer ); - const auto margin = speedometer->metric( - Speedometer::Needle | QskAspect::Margin ); + const auto r = scaleRect( dial ); + const auto margin = dial->metric( Dial::Needle | QskAspect::Margin ); QLineF line; line.setP1( r.center() ); line.setLength( 0.5 * r.width() - margin ); - line.setAngle( -speedometer->value() ); + line.setAngle( -dial->value() ); return line; } -#include "moc_SpeedometerSkinlet.cpp" +#include "moc_DialSkinlet.cpp" diff --git a/playground/dashboard/SpeedometerSkinlet.h b/playground/dashboard/DialSkinlet.h similarity index 65% rename from playground/dashboard/SpeedometerSkinlet.h rename to playground/dashboard/DialSkinlet.h index caf563b9..31267995 100644 --- a/playground/dashboard/SpeedometerSkinlet.h +++ b/playground/dashboard/DialSkinlet.h @@ -7,9 +7,9 @@ #include -class Speedometer; +class Dial; -class SpeedometerSkinlet : public QskSkinlet +class DialSkinlet : public QskSkinlet { Q_GADGET @@ -22,7 +22,7 @@ class SpeedometerSkinlet : public QskSkinlet NeedleRole }; - Q_INVOKABLE SpeedometerSkinlet( QskSkin* skin = nullptr ); + Q_INVOKABLE DialSkinlet( QskSkin* skin = nullptr ); QRectF subControlRect( const QskSkinnable*, const QRectF&, QskAspect::Subcontrol ) const override; @@ -32,9 +32,9 @@ class SpeedometerSkinlet : public QskSkinlet quint8 nodeRole, QSGNode* node ) const override; private: - QRectF scaleRect( const Speedometer* ) const; - QLineF needlePoints( const Speedometer* ) const; + QRectF scaleRect( const Dial* ) const; + QLineF needlePoints( const Dial* ) const; - QSGNode* updateLabelsNode( const Speedometer*, QSGNode* ) const; - QSGNode* updateNeedleNode( const Speedometer*, QSGNode* ) const; + QSGNode* updateLabelsNode( const Dial*, QSGNode* ) const; + QSGNode* updateNeedleNode( const Dial*, QSGNode* ) const; }; diff --git a/playground/dashboard/MainWindow.cpp b/playground/dashboard/MainWindow.cpp deleted file mode 100644 index e8d7aa21..00000000 --- a/playground/dashboard/MainWindow.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/****************************************************************************** - * QSkinny - Copyright (C) 2016 Uwe Rathmann - * This file may be used under the terms of the 3-clause BSD License - *****************************************************************************/ - -#include "MainWindow.h" -#include "ButtonBar.h" -#include "SkinFactory.h" -#include "SpeedometerDisplay.h" - -#include -#include -#include -#include -#include - -#include -#include - -namespace -{ - class Header : public ButtonBar - { - public: - Header() - { - addIndicator( "bluetooth" ); - addIndicator( "location" ); - addIndicator( "phone" ); - - ( void ) new QskTextLabel( QDate::currentDate().toString(), this ); - - addIndicator( "user" ); - addIndicator( "bookmark" ); - addIndicator( "menu" ); - } - }; - - class Footer : public ButtonBar - { - public: - Footer() - { - addIndicator( "cloud" ); - addIndicator( "man" ); - addIndicator( "bus" ); - addIndicator( "plane" ); - addIndicator( "train" ); - - addStretch( 10 ); - } - }; -} - -MainWindow::MainWindow() -{ - setAutoLayoutChildren( true ); - - const QImage image( QStringLiteral( ":/images/background.jpg" ) ); - - auto backgroundImage = new QskGraphicLabel( contentItem() ); - backgroundImage->setGraphic( QskGraphic::fromImage( image ) ); - backgroundImage->setFillMode( QskGraphicLabel::Stretch ); - - auto header = new Header(); - auto speedoDisplay = new SpeedometerDisplay(); - auto footer = new Footer(); - - auto layout = new QskLinearBox( Qt::Vertical, contentItem() ); - - layout->addItem( header ); - layout->setStretchFactor( header, 1 ); - - layout->addItem( speedoDisplay ); - layout->setStretchFactor( speedoDisplay, 8 ); - - layout->addItem( footer ); - layout->setStretchFactor( footer, 1 ); -} diff --git a/playground/dashboard/README.images b/playground/dashboard/README.images deleted file mode 100644 index 5e0c06e3..00000000 --- a/playground/dashboard/README.images +++ /dev/null @@ -1,3 +0,0 @@ -* background image: http://7-themes.com/collections/green-wallpapers/4440155/ , license unknown -* car image: https://openclipart.org/detail/234440/white-blank-racing-car-top-view , unlimited commercial use -* icons: https://www.flaticon.com/packs/material-design, made by Material Design from www.flaticon.com diff --git a/playground/dashboard/SkinFactory.cpp b/playground/dashboard/SkinFactory.cpp index a44bcf62..22a3e8d8 100644 --- a/playground/dashboard/SkinFactory.cpp +++ b/playground/dashboard/SkinFactory.cpp @@ -5,24 +5,15 @@ #include "SkinFactory.h" -#include "ButtonBar.h" -#include "Speedometer.h" -#include "SpeedometerSkinlet.h" +#include "Dial.h" +#include "DialSkinlet.h" #include -#include -#include -#include -#include #include -#include -#include -#include #include #include #include - -#include +#include namespace { @@ -38,102 +29,43 @@ namespace public: Skin() { - declareSkinlet< Speedometer, SpeedometerSkinlet >(); + using namespace QskRgb; + + declareSkinlet< Dial, DialSkinlet >(); setFont( QskSkin::DefaultFont, qskFont( 13 ) ); setFont( QskSkin::LargeFont, qskFont( 20 ) ); - setSkinHint( ButtonBar::Indicator | QskAspect::GraphicRole, SkinFactory::Indicator ); - } - }; - - class Skin1 : public Skin - { - public: - Skin1() - { - const QColor color1( "#363636" ); // Jet - const QColor color2( "#242F40" ); // Yankees blue - const QColor color3( "#CCA43B" ); // Satin sheet gold - const QColor color4( "#E5E5E5" ); // Platinum - const QColor color5( "#FFFFFF" ); // white + const auto rgb1 = qRgb( 1, 16, 27 ); // Maastricht blue + const auto rgb2 = qRgb( 255, 0, 22 ); // Ruddy + const auto rgb3 = qRgb( 41, 234, 212 ); // Turquoise + const auto rgb4 = qRgb( 253, 255, 252 ); // baby powder QskSkinHintTableEditor ed( &hintTable() ); - ed.setColor( QskTextLabel::Text, color3 ); + ed.setColor( QskTextLabel::Text, rgb4 ); { - using Q = Speedometer; - - ed.setBoxBorderMetrics( Q::Panel, 5 ); - ed.setBoxShape( Q::Panel, 30, Qt::RelativeSize ); - ed.setGradient( Q::Panel, - QskGradient( QskGradient::Vertical, color2, color4 ) ); - ed.setBoxBorderColors( Q::Panel, color3 ); - - ed.setBoxBorderMetrics( Q::Knob, 5 ); - ed.setStrutSize( Q::Knob, 20, 20 ); - ed.setBoxShape( Q::Knob, 100, Qt::RelativeSize ); - ed.setGradient( Q::Knob, color2 ); - ed.setBoxBorderColors( Q::Knob, color4 ); - - ed.setMetric( Q::Needle | QskAspect::Size, 4 ); - ed.setMetric( Q::Needle | QskAspect::Margin, 15 ); - ed.setColor( Q::Needle, color4 ); - - ed.setSpacing( Q::TickLabels, 3 ); - ed.setStrutSize( Q::TickLabels, 3, 25 ); - ed.setColor( Q::TickLabels, color4 ); - ed.setFontRole( Q::TickLabels, QskSkin::SmallFont ); - } - - { - // all SVGs on the header/footer are plain white - - QskColorFilter filter; - filter.addColorSubstitution( Qt::white, color3.rgb() ); - - setGraphicFilter( SkinFactory::Indicator, filter ); - } - } - }; - - class Skin2 : public Skin - { - public: - Skin2() - { - const QColor color1( "#011627" ); // Maastricht blue - const QColor color2( "#FF0022" ); // ruddy - const QColor color3( "#41EAD4" ); // Turquoise - const QColor color4( "#FDFFFC" ); // baby powder - const QColor color5( "#B91372" ); // red violet - - QskSkinHintTableEditor ed( &hintTable() ); - - ed.setColor( QskTextLabel::Text, color4 ); - - { - using Q = Speedometer; + using Q = Dial; ed.setBoxBorderMetrics( Q::Panel, 2 ); ed.setBoxShape( Q::Panel, 100, Qt::RelativeSize ); - ed.setGradient( Q::Panel, color1 ); - ed.setBoxBorderColors( Q::Panel, color3 ); + ed.setGradient( Q::Panel, rgb1 ); + ed.setBoxBorderColors( Q::Panel, rgb3 ); ed.setBoxBorderMetrics( Q::Knob, 2 ); ed.setStrutSize( Q::Knob, 30, 30 ); ed.setBoxShape( Q::Knob, 100, Qt::RelativeSize ); ed.setGradient( Q::Knob, - QskGradient( QskGradient::Diagonal, color2, color1 ) ); + QskGradient( QskGradient::Diagonal, rgb2, rgb1 ) ); ed.setMetric( Q::Needle | QskAspect::Size, 2 ); ed.setMetric( Q::Needle | QskAspect::Margin, 10 ); - ed.setColor( Q::Needle, color2 ); + ed.setColor( Q::Needle, rgb2 ); ed.setSpacing( Q::TickLabels, 4 ); ed.setStrutSize( Q::TickLabels, 2, 15 ); - ed.setColor( Q::TickLabels, color4 ); + ed.setColor( Q::TickLabels, rgb4 ); ed.setFontRole( Q::TickLabels, QskSkin::SmallFont ); } } @@ -143,43 +75,15 @@ namespace QStringList SkinFactory::skinNames() const { - return { "Skin1", "Skin2" }; + return { "Skin" }; } QskSkin* SkinFactory::createSkin( const QString& skinName ) { - if ( skinName == "Skin1" ) - return new Skin1(); - - if ( skinName == "Skin2" ) - return new Skin2(); + if ( skinName == "Skin" ) + return new Skin(); return nullptr; } -void SkinFactory::rotateSkin() -{ - const auto names = skinNames(); - - int index = names.indexOf( qskSetup->skinName() ); - index = ( index + 1 ) % names.size(); - - auto oldSkin = qskSetup->skin(); - if ( oldSkin->parent() == qskSetup ) - oldSkin->setParent( nullptr ); // otherwise setSkin deletes it - - auto newSkin = qskSetup->setSkin( names[ index ] ); - - QskSkinTransition transition; - - transition.setSourceSkin( oldSkin ); - transition.setTargetSkin( newSkin ); - transition.setAnimation( 600 ); - - transition.process(); - - if ( oldSkin->parent() == nullptr ) - delete oldSkin; -} - #include "moc_SkinFactory.cpp" diff --git a/playground/dashboard/SkinFactory.h b/playground/dashboard/SkinFactory.h index 00d63dce..4ae1da7a 100644 --- a/playground/dashboard/SkinFactory.h +++ b/playground/dashboard/SkinFactory.h @@ -12,15 +12,6 @@ class SkinFactory : public QskSkinFactory Q_OBJECT public: - enum GraphicRoles - { - // to be visible on header/footer - Indicator, - }; - QStringList skinNames() const override; QskSkin* createSkin( const QString& ) override; - - public Q_SLOTS: - void rotateSkin(); }; diff --git a/playground/dashboard/dashboard.pro b/playground/dashboard/dashboard.pro index 3f57407a..c982f184 100644 --- a/playground/dashboard/dashboard.pro +++ b/playground/dashboard/dashboard.pro @@ -1,22 +1,17 @@ CONFIG += qskexample qskqvg HEADERS += \ - ButtonBar.h \ SkinFactory.h \ - MainWindow.h \ - Speedometer.h \ - SpeedometerSkinlet.h \ - SpeedometerDisplay.h + Dial.h \ + DialSkinlet.h \ + Dashboard.h SOURCES += \ - ButtonBar.cpp \ SkinFactory.cpp \ - MainWindow.cpp \ - Speedometer.cpp \ - SpeedometerSkinlet.cpp \ - SpeedometerDisplay.cpp \ + Dial.cpp \ + DialSkinlet.cpp \ + Dashboard.cpp \ main.cpp \ RESOURCES += \ - images.qrc \ - qvgfiles.qrc + images.qrc diff --git a/playground/dashboard/images/bluetooth.svg b/playground/dashboard/images/bluetooth.svg deleted file mode 100644 index 90dd0265..00000000 --- a/playground/dashboard/images/bluetooth.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/playground/dashboard/images/bookmark.svg b/playground/dashboard/images/bookmark.svg deleted file mode 100644 index 543bb07f..00000000 --- a/playground/dashboard/images/bookmark.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/playground/dashboard/images/bus.svg b/playground/dashboard/images/bus.svg deleted file mode 100644 index 83997da9..00000000 --- a/playground/dashboard/images/bus.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/playground/dashboard/images/car.svg b/playground/dashboard/images/car.svg deleted file mode 100644 index 4beb2aab..00000000 --- a/playground/dashboard/images/car.svg +++ /dev/null @@ -1,410 +0,0 @@ - - - - - - Red Car - Top View - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - Openclipart - - - Red Car - Top View - 2010-05-19T15:02:12 - I was thinking of Trophy ( http://trophy.sourceforge.net/index.php?body=screenshots ) when remixing this one :) - https://openclipart.org/detail/61201/red-racing-car-top-view-by-qubodup - - - qubodup - - - - - car - game - game sprite - racing - racing car - red - red car - simple - simple car - sprite - transport - transportation - travel - video game - video game art - video game sprite - - - - - - - - - - - diff --git a/playground/dashboard/images/cloud.svg b/playground/dashboard/images/cloud.svg deleted file mode 100644 index 4423f38a..00000000 --- a/playground/dashboard/images/cloud.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/playground/dashboard/images/compass.svg b/playground/dashboard/images/compass.svg deleted file mode 100644 index c94138f2..00000000 --- a/playground/dashboard/images/compass.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/playground/dashboard/images/down.svg b/playground/dashboard/images/down.svg deleted file mode 100644 index 0e2fbc13..00000000 --- a/playground/dashboard/images/down.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/playground/dashboard/images/left.svg b/playground/dashboard/images/left.svg deleted file mode 100644 index 6e47594e..00000000 --- a/playground/dashboard/images/left.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/playground/dashboard/images/location.svg b/playground/dashboard/images/location.svg deleted file mode 100644 index 23d7f7ff..00000000 --- a/playground/dashboard/images/location.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/playground/dashboard/images/man.svg b/playground/dashboard/images/man.svg deleted file mode 100644 index 27c3d066..00000000 --- a/playground/dashboard/images/man.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/playground/dashboard/images/menu.svg b/playground/dashboard/images/menu.svg deleted file mode 100644 index 8f6b932f..00000000 --- a/playground/dashboard/images/menu.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/playground/dashboard/images/phone.svg b/playground/dashboard/images/phone.svg deleted file mode 100644 index a4469c14..00000000 --- a/playground/dashboard/images/phone.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/playground/dashboard/images/plane.svg b/playground/dashboard/images/plane.svg deleted file mode 100644 index 14113600..00000000 --- a/playground/dashboard/images/plane.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/playground/dashboard/images/right.svg b/playground/dashboard/images/right.svg deleted file mode 100644 index 879abe7f..00000000 --- a/playground/dashboard/images/right.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/playground/dashboard/images/train.svg b/playground/dashboard/images/train.svg deleted file mode 100644 index 701f418b..00000000 --- a/playground/dashboard/images/train.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/playground/dashboard/images/up.svg b/playground/dashboard/images/up.svg deleted file mode 100644 index d0ac978c..00000000 --- a/playground/dashboard/images/up.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/playground/dashboard/images/user.svg b/playground/dashboard/images/user.svg deleted file mode 100644 index bd66d1f4..00000000 --- a/playground/dashboard/images/user.svg +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - diff --git a/playground/dashboard/main.cpp b/playground/dashboard/main.cpp index d4fd90f2..760b958b 100644 --- a/playground/dashboard/main.cpp +++ b/playground/dashboard/main.cpp @@ -3,18 +3,41 @@ * This file may be used under the terms of the 3-clause BSD License *****************************************************************************/ -#include "MainWindow.h" +#include "Dashboard.h" #include "SkinFactory.h" #include -#include +#include #include #include -#include +#include +#include +#include + #include +namespace +{ + class Window : public QskWindow + { + public: + Window() + { + setAutoLayoutChildren( true ); + + const QImage image( QStringLiteral( ":/images/background.jpg" ) ); + + auto backgroundImage = new QskGraphicLabel( contentItem() ); + backgroundImage->setGraphic( QskGraphic::fromImage( image ) ); + backgroundImage->setFillMode( QskGraphicLabel::Stretch ); + + (void ) new Dashboard( contentItem() ); + } + }; +} + int main( int argc, char** argv ) { #ifdef ITEM_STATISTICS @@ -26,15 +49,9 @@ int main( int argc, char** argv ) QGuiApplication app( argc, argv ); - /* - When going over QPainter for the SVGs we prefer the raster paint - engine, simply showing better results. - */ - qskSetup->setItemUpdateFlag( QskQuickItem::PreferRasterForTextures, true ); - SkinnyShortcut::enable( SkinnyShortcut::AllShortcuts ); - MainWindow window; + Window window; window.show(); return app.exec(); diff --git a/playground/dashboard/qvg/bluetooth.qvg b/playground/dashboard/qvg/bluetooth.qvg deleted file mode 100644 index 7c6522c1..00000000 Binary files a/playground/dashboard/qvg/bluetooth.qvg and /dev/null differ diff --git a/playground/dashboard/qvg/bookmark.qvg b/playground/dashboard/qvg/bookmark.qvg deleted file mode 100644 index 320ba4bf..00000000 Binary files a/playground/dashboard/qvg/bookmark.qvg and /dev/null differ diff --git a/playground/dashboard/qvg/bus.qvg b/playground/dashboard/qvg/bus.qvg deleted file mode 100644 index 7c16b72c..00000000 Binary files a/playground/dashboard/qvg/bus.qvg and /dev/null differ diff --git a/playground/dashboard/qvg/car.qvg b/playground/dashboard/qvg/car.qvg deleted file mode 100644 index 21f343f3..00000000 Binary files a/playground/dashboard/qvg/car.qvg and /dev/null differ diff --git a/playground/dashboard/qvg/cloud.qvg b/playground/dashboard/qvg/cloud.qvg deleted file mode 100644 index 6b5833b4..00000000 Binary files a/playground/dashboard/qvg/cloud.qvg and /dev/null differ diff --git a/playground/dashboard/qvg/down.qvg b/playground/dashboard/qvg/down.qvg deleted file mode 100644 index 32b8742b..00000000 Binary files a/playground/dashboard/qvg/down.qvg and /dev/null differ diff --git a/playground/dashboard/qvg/left.qvg b/playground/dashboard/qvg/left.qvg deleted file mode 100644 index fd20b405..00000000 Binary files a/playground/dashboard/qvg/left.qvg and /dev/null differ diff --git a/playground/dashboard/qvg/location.qvg b/playground/dashboard/qvg/location.qvg deleted file mode 100644 index 149a61e1..00000000 Binary files a/playground/dashboard/qvg/location.qvg and /dev/null differ diff --git a/playground/dashboard/qvg/man.qvg b/playground/dashboard/qvg/man.qvg deleted file mode 100644 index f82443f8..00000000 Binary files a/playground/dashboard/qvg/man.qvg and /dev/null differ diff --git a/playground/dashboard/qvg/menu.qvg b/playground/dashboard/qvg/menu.qvg deleted file mode 100644 index 963c0424..00000000 Binary files a/playground/dashboard/qvg/menu.qvg and /dev/null differ diff --git a/playground/dashboard/qvg/phone.qvg b/playground/dashboard/qvg/phone.qvg deleted file mode 100644 index 9da2226c..00000000 Binary files a/playground/dashboard/qvg/phone.qvg and /dev/null differ diff --git a/playground/dashboard/qvg/plane.qvg b/playground/dashboard/qvg/plane.qvg deleted file mode 100644 index a4cfc813..00000000 Binary files a/playground/dashboard/qvg/plane.qvg and /dev/null differ diff --git a/playground/dashboard/qvg/right.qvg b/playground/dashboard/qvg/right.qvg deleted file mode 100644 index a295d50a..00000000 Binary files a/playground/dashboard/qvg/right.qvg and /dev/null differ diff --git a/playground/dashboard/qvg/train.qvg b/playground/dashboard/qvg/train.qvg deleted file mode 100644 index d74c9ee8..00000000 Binary files a/playground/dashboard/qvg/train.qvg and /dev/null differ diff --git a/playground/dashboard/qvg/up.qvg b/playground/dashboard/qvg/up.qvg deleted file mode 100644 index 07be25f6..00000000 Binary files a/playground/dashboard/qvg/up.qvg and /dev/null differ diff --git a/playground/dashboard/qvg/user.qvg b/playground/dashboard/qvg/user.qvg deleted file mode 100644 index 53bbe233..00000000 Binary files a/playground/dashboard/qvg/user.qvg and /dev/null differ diff --git a/playground/dashboard/qvgfiles.qrc b/playground/dashboard/qvgfiles.qrc deleted file mode 100644 index bedafe89..00000000 --- a/playground/dashboard/qvgfiles.qrc +++ /dev/null @@ -1,24 +0,0 @@ - - - - - qvg/car.qvg - qvg/bluetooth.qvg - qvg/bookmark.qvg - qvg/bus.qvg - qvg/cloud.qvg - qvg/location.qvg - qvg/man.qvg - qvg/menu.qvg - qvg/phone.qvg - qvg/plane.qvg - qvg/train.qvg - qvg/user.qvg - qvg/down.qvg - qvg/left.qvg - qvg/right.qvg - qvg/up.qvg - - - -