diff --git a/examples/automotive/ButtonBar.cpp b/examples/automotive/ButtonBar.cpp index 93839a7a..abc2a823 100644 --- a/examples/automotive/ButtonBar.cpp +++ b/examples/automotive/ButtonBar.cpp @@ -12,6 +12,8 @@ public: IndicatorLabel( QQuickItem* parentItem = nullptr ): QskGraphicLabel( parentItem ) { + // so the skins are able to colorize them + setGraphicRole( SkinFactory::Indicator ); } virtual QskAspect::Subcontrol effectiveSubcontrol( @@ -43,9 +45,6 @@ void ButtonBar::addIndicator( const char* name ) { auto* label = new IndicatorLabel( this ); - // so the skins are able to colorize them - label->setGraphicRole( QskGraphicLabel::Graphic, SkinFactory::Indicator ); - /* The label should adjust vertically and be stretched horizontally according to its aspect ratio. diff --git a/examples/layouts/main.cpp b/examples/layouts/main.cpp index ea7583c7..b280b211 100644 --- a/examples/layouts/main.cpp +++ b/examples/layouts/main.cpp @@ -30,9 +30,8 @@ public: QskTextLabel( text, parent ) { setBackgroundColor( Qt::black ); - setColor( QskTextLabel::Text, Qt::white ); - - setFontRole( Text, QskSkin::MediumFont ); + setTextColor( Qt::white ); + setFontRole( QskSkin::MediumFont ); QskTextOptions textOptions; textOptions.setWrapMode( QskTextOptions::WordWrap ); diff --git a/examples/qvgviewer/MainWindow.cpp b/examples/qvgviewer/MainWindow.cpp index aca62300..0a74e04d 100644 --- a/examples/qvgviewer/MainWindow.cpp +++ b/examples/qvgviewer/MainWindow.cpp @@ -42,19 +42,18 @@ public: { using namespace QskAspect; - const QskAspect::Aspect aspectRole = QskGraphicLabel::Graphic | GraphicRole; - const int oldRole = graphicRole( aspectRole ); + const int oldRole = graphicRole(); QColor color; if ( on ) { color.setRgb( 40, 40, 40 ); - setGraphicRole( aspectRole, Inverted ); + setGraphicRole( Inverted ); } else { color.setRgb( 255, 228, 181 ); - setGraphicRole( aspectRole, Normal ); + setGraphicRole( Normal ); } const int duration = 500; @@ -68,7 +67,8 @@ public: startTransition( aspectColor, duration, oldColor, color ); } - startTransition( aspectRole, duration, oldRole, graphicRole( aspectRole ) ); + const QskAspect::Aspect aspectRole = QskGraphicLabel::Graphic | GraphicRole; + startTransition( aspectRole, duration, oldRole, graphicRole() ); } }; diff --git a/examples/tabview/main.cpp b/examples/tabview/main.cpp index 7de20068..8e26d8eb 100644 --- a/examples/tabview/main.cpp +++ b/examples/tabview/main.cpp @@ -25,9 +25,8 @@ public: Label( const QString& text, QQuickItem* parent = nullptr ): QskTextLabel( text, parent ) { - setColor( Text, Qt::darkRed ); - - setFontRole( Text, QskSkin::LargeFont ); + setTextColor( Qt::darkRed ); + setFontRole( QskSkin::LargeFont ); setAlignment( Qt::AlignCenter ); } }; diff --git a/examples/thumbnails/main.cpp b/examples/thumbnails/main.cpp index 9182b11f..ee9ba895 100644 --- a/examples/thumbnails/main.cpp +++ b/examples/thumbnails/main.cpp @@ -101,6 +101,23 @@ public: } }; +class ScrollArea : public QskScrollArea +{ +public: + ScrollArea( QQuickItem* parentItem = nullptr ) : + QskScrollArea( parentItem ) + { + using namespace QskAspect; + + // settings usually done in the skins + setMetric( Viewport | Radius, 20 ); + setMetric( VerticalScrollBar | Size, 20 ); + setMetric( VerticalScrollHandle | Radius, 8 ); + setMetric( HorizontalScrollBar | Size, 20 ); + setMetric( HorizontalScrollHandle | Radius, 0 ); + } +}; + int main( int argc, char* argv[] ) { #ifdef ITEM_STATISTICS @@ -123,20 +140,10 @@ int main( int argc, char* argv[] ) But here we only want to demonstrate how QskScrollArea works. */ - auto scrollArea = new QskScrollArea(); + auto scrollArea = new ScrollArea(); scrollArea->setMargins( QMarginsF( 25, 25, 5, 5 ) ); scrollArea->setScrolledItem( new IconGrid() ); -#if 1 - // settings that are usually done in the skins - scrollArea->setMetric( QskScrollView::Viewport | QskAspect::Radius, 20 ); - scrollArea->setMetric( QskScrollView::VerticalScrollBar | QskAspect::Size, 20 ); - scrollArea->setMetric( QskScrollView::VerticalScrollHandle | QskAspect::Radius, 8 ); - scrollArea->setMetric( QskScrollView::HorizontalScrollBar | QskAspect::Size, 20 ); - scrollArea->setMetric( QskScrollView::HorizontalScrollHandle | QskAspect::Radius, 0 ); -#endif - - QskWindow window; window.resize( 600, 600 ); window.setColor( "SteelBlue" ); diff --git a/examples/tlabels/main.cpp b/examples/tlabels/main.cpp index 3ecdfbbf..f420a040 100644 --- a/examples/tlabels/main.cpp +++ b/examples/tlabels/main.cpp @@ -6,16 +6,12 @@ #include #include -#include -#include #include -#include #include #include #include #include -#include class TextBox: public QskLinearBox { @@ -29,7 +25,7 @@ public: for ( int i = 0; i < texts.size(); i++ ) { auto label = new QskTextLabel( texts[i] + " Font", this ); - label->setFontRole( QskTextLabel::Text, i ); + label->setFontRole( i ); } } }; diff --git a/src/controls/QskGraphicLabel.cpp b/src/controls/QskGraphicLabel.cpp index 39a207bf..db038ba2 100644 --- a/src/controls/QskGraphicLabel.cpp +++ b/src/controls/QskGraphicLabel.cpp @@ -121,6 +121,24 @@ void QskGraphicLabel::setGraphic( const QskGraphic& graphic ) } } +void QskGraphicLabel::setGraphicRole( int role ) +{ + const int oldRole = graphicRole(); + + QskSkinnable::setGraphicRole( effectiveSubcontrol( Graphic ), role ); + + if ( role != oldRole ) + { + update(); + Q_EMIT graphicRoleChanged(); + } +} + +int QskGraphicLabel::graphicRole() const +{ + return QskSkinnable::graphicRole( Graphic ); +} + QskColorFilter QskGraphicLabel::graphicFilter() const { // can be removed once we can store a filter inidividually diff --git a/src/controls/QskGraphicLabel.h b/src/controls/QskGraphicLabel.h index fa02695d..041b3e54 100644 --- a/src/controls/QskGraphicLabel.h +++ b/src/controls/QskGraphicLabel.h @@ -22,6 +22,9 @@ class QSK_EXPORT QskGraphicLabel : public QskControl Q_PROPERTY( QSize sourceSize READ sourceSize WRITE setSourceSize RESET resetSourceSize NOTIFY sourceSizeChanged ) + Q_PROPERTY( int graphicRole READ graphicRole + WRITE setGraphicRole NOTIFY graphicRoleChanged ) + Q_PROPERTY( Qt::Alignment alignment READ alignment WRITE setAlignment NOTIFY alignmentChanged ) @@ -80,10 +83,14 @@ public: bool isEmpty() const; + void setGraphicRole( int role ); + int graphicRole() const; + Q_SIGNALS: void sourceChanged(); void mirrorChanged(); void sourceSizeChanged(); + void graphicRoleChanged(); void alignmentChanged(); void fillModeChanged(); diff --git a/src/controls/QskSkin.cpp b/src/controls/QskSkin.cpp index 439ec414..f5da57b0 100644 --- a/src/controls/QskSkin.cpp +++ b/src/controls/QskSkin.cpp @@ -173,11 +173,6 @@ QColor QskSkin::color( QskAspect::Aspect aspect ) const return skinHint( aspect | QskAspect::Color ).value(); } -QColor QskSkin::baseColor() const -{ - return color( QskAspect::Control | QskAspect::Color ); -} - void QskSkin::setMetric( QskAspect::Aspect aspect, qreal metric ) { setSkinHint( aspect | QskAspect::Metric, metric ); diff --git a/src/controls/QskSkin.h b/src/controls/QskSkin.h index 0efec70f..6f918b12 100644 --- a/src/controls/QskSkin.h +++ b/src/controls/QskSkin.h @@ -61,7 +61,6 @@ public: void setColor( QskAspect::Aspect, const QColor& ); QColor color( QskAspect::Aspect ) const; - QColor baseColor() const; void setMetric( QskAspect::Aspect, qreal metric ); qreal metric( QskAspect::Aspect ) const; diff --git a/src/controls/QskTextLabel.cpp b/src/controls/QskTextLabel.cpp index 58875267..8c39932f 100644 --- a/src/controls/QskTextLabel.cpp +++ b/src/controls/QskTextLabel.cpp @@ -93,6 +93,44 @@ QskTextOptions QskTextLabel::textOptions() const return m_data->textOptions; } +void QskTextLabel::setFontRole( int role ) +{ + const int oldRole = fontRole(); + + QskSkinnable::setFontRole( effectiveSubcontrol( Text ), role ); + + if ( oldRole != role ) + { + resetImplicitSize(); + update(); + + Q_EMIT fontRoleChanged(); + } +} + +int QskTextLabel::fontRole() const +{ + return QskSkinnable::fontRole( Text ); +} + +void QskTextLabel::setTextColor( const QColor& color ) +{ + const QColor oldColor = textColor(); + + QskSkinnable::setColor( effectiveSubcontrol( Text ), color ); + + if ( oldColor != color ) + { + update(); + Q_EMIT textColorChanged(); + } +} + +QColor QskTextLabel::textColor() const +{ + return QskSkinnable::color( Text ); +} + Qt::Alignment QskTextLabel::alignment() const { return flagHint< Qt::Alignment >( diff --git a/src/controls/QskTextLabel.h b/src/controls/QskTextLabel.h index 942dc929..e3f9d24a 100644 --- a/src/controls/QskTextLabel.h +++ b/src/controls/QskTextLabel.h @@ -16,6 +16,12 @@ class QSK_EXPORT QskTextLabel : public QskControl Q_PROPERTY( QString text READ text WRITE setText NOTIFY textChanged ) + Q_PROPERTY( int fontRole READ fontRole + WRITE setFontRole NOTIFY fontRoleChanged ) + + Q_PROPERTY( QColor textColor READ textColor + WRITE setTextColor NOTIFY textColorChanged ) + Q_PROPERTY( QskTextOptions textOptions READ textOptions WRITE setTextOptions NOTIFY textOptionsChanged ) @@ -34,6 +40,12 @@ public: QString text() const; + void setFontRole( int role ); + int fontRole() const; + + void setTextColor( const QColor& ); + QColor textColor() const; + void setTextOptions( const QskTextOptions& ); QskTextOptions textOptions() const; @@ -51,7 +63,9 @@ public: Q_SIGNALS: void textChanged( const QString& ); + void textColorChanged(); void textOptionsChanged(); + void fontRoleChanged(); void alignmentChanged(); public Q_SLOTS: