From cad27956e6574a723339c2513efb437e8e1ae39f Mon Sep 17 00:00:00 2001 From: Uwe Rathmann Date: Sat, 1 Aug 2020 17:51:45 +0200 Subject: [PATCH] QskValueBar -> QskProgressBar --- skins/material/QskMaterialSkin.cpp | 8 +- skins/material/QskMaterialSkin.h | 2 +- skins/squiek/QskSquiekSkin.cpp | 8 +- skins/squiek/QskSquiekSkin.h | 2 +- .../{QskValueBar.cpp => QskProgressBar.cpp} | 76 +++++++++---------- .../{QskValueBar.h => QskProgressBar.h} | 18 ++--- ...rSkinlet.cpp => QskProgressBarSkinlet.cpp} | 38 +++++----- ...ueBarSkinlet.h => QskProgressBarSkinlet.h} | 16 ++-- src/controls/QskSkin.cpp | 8 +- src/src.pro | 8 +- 10 files changed, 92 insertions(+), 92 deletions(-) rename src/controls/{QskValueBar.cpp => QskProgressBar.cpp} (60%) rename src/controls/{QskValueBar.h => QskProgressBar.h} (79%) rename src/controls/{QskValueBarSkinlet.cpp => QskProgressBarSkinlet.cpp} (71%) rename src/controls/{QskValueBarSkinlet.h => QskProgressBarSkinlet.h} (65%) diff --git a/skins/material/QskMaterialSkin.cpp b/skins/material/QskMaterialSkin.cpp index 3986bebf..4f83d50e 100644 --- a/skins/material/QskMaterialSkin.cpp +++ b/skins/material/QskMaterialSkin.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -22,7 +23,6 @@ #include #include #include -#include #include #include @@ -135,6 +135,7 @@ void QskMaterialSkin::initHints() initListViewHints(); initPageIndicatorHints(); initPopupHints(); + initProgressBarHints(); initPushButtonHints(); initScrollViewHints(); initSeparatorHints(); @@ -145,7 +146,6 @@ void QskMaterialSkin::initHints() initTabViewHints(); initTextLabelHints(); initTextInputHints(); - initValueBarHints(); } void QskMaterialSkin::resetColors( const QColor& accent ) @@ -236,10 +236,10 @@ void QskMaterialSkin::initTextInputHints() setGradient( Q::Panel, pal.baseColor ); } -void QskMaterialSkin::initValueBarHints() +void QskMaterialSkin::initProgressBarHints() { using namespace QskAspect; - using Q = QskValueBar; + using Q = QskProgressBar; const ColorPalette& pal = m_data->palette; diff --git a/skins/material/QskMaterialSkin.h b/skins/material/QskMaterialSkin.h index 1b6ffe44..01a30bc7 100644 --- a/skins/material/QskMaterialSkin.h +++ b/skins/material/QskMaterialSkin.h @@ -36,6 +36,7 @@ class QSK_MATERIAL_EXPORT QskMaterialSkin : public QskSkin void initListViewHints(); void initPageIndicatorHints(); void initPopupHints(); + void initProgressBarHints(); void initPushButtonHints(); void initScrollViewHints(); void initSeparatorHints(); @@ -46,7 +47,6 @@ class QSK_MATERIAL_EXPORT QskMaterialSkin : public QskSkin void initTabViewHints(); void initTextInputHints(); void initTextLabelHints(); - void initValueBarHints(); class PrivateData; std::unique_ptr< PrivateData > m_data; diff --git a/skins/squiek/QskSquiekSkin.cpp b/skins/squiek/QskSquiekSkin.cpp index 5e347be9..d160bd1e 100644 --- a/skins/squiek/QskSquiekSkin.cpp +++ b/skins/squiek/QskSquiekSkin.cpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include @@ -23,7 +24,6 @@ #include #include #include -#include #include #include @@ -263,6 +263,7 @@ void QskSquiekSkin::initHints() initListViewHints(); initPageIndicatorHints(); initPopupHints(); + initProgressBarHints(); initPushButtonHints(); initScrollViewHints(); initSeparatorHints(); @@ -273,7 +274,6 @@ void QskSquiekSkin::initHints() initTabViewHints(); initTextLabelHints(); initTextInputHints(); - initValueBarInputHints(); } void QskSquiekSkin::resetColors( const QColor& accent ) @@ -382,10 +382,10 @@ void QskSquiekSkin::initTextInputHints() setAnimation( Q::Panel | Color, qskDuration ); } -void QskSquiekSkin::initValueBarInputHints() +void QskSquiekSkin::initProgressBarHints() { using namespace QskAspect; - using Q = QskValueBar; + using Q = QskProgressBar; const ColorPalette& pal = m_data->palette; diff --git a/skins/squiek/QskSquiekSkin.h b/skins/squiek/QskSquiekSkin.h index 1f1e85cd..be40a88b 100644 --- a/skins/squiek/QskSquiekSkin.h +++ b/skins/squiek/QskSquiekSkin.h @@ -37,6 +37,7 @@ class QSK_SQUIEK_EXPORT QskSquiekSkin : public QskSkin void initListViewHints(); void initPageIndicatorHints(); void initPopupHints(); + void initProgressBarHints(); void initPushButtonHints(); void initScrollViewHints(); void initSeparatorHints(); @@ -47,7 +48,6 @@ class QSK_SQUIEK_EXPORT QskSquiekSkin : public QskSkin void initTabViewHints(); void initTextLabelHints(); void initTextInputHints(); - void initValueBarInputHints(); enum PanelStyle { diff --git a/src/controls/QskValueBar.cpp b/src/controls/QskProgressBar.cpp similarity index 60% rename from src/controls/QskValueBar.cpp rename to src/controls/QskProgressBar.cpp index 30231407..aeb8d04e 100644 --- a/src/controls/QskValueBar.cpp +++ b/src/controls/QskProgressBar.cpp @@ -3,17 +3,17 @@ * This file may be used under the terms of the QSkinny License, Version 1.0 *****************************************************************************/ -#include "QskValueBar.h" +#include "QskProgressBar.h" #include "QskIntervalF.h" #include "QskGradient.h" #include "QskFunctions.h" #include "QskAspect.h" -QSK_SUBCONTROL( QskValueBar, Groove ) -QSK_SUBCONTROL( QskValueBar, ValueFill ) +QSK_SUBCONTROL( QskProgressBar, Groove ) +QSK_SUBCONTROL( QskProgressBar, ValueFill ) -class QskValueBar::PrivateData +class QskProgressBar::PrivateData { public: qreal value = 0.0; @@ -24,7 +24,7 @@ class QskValueBar::PrivateData Qt::Orientation orientation; }; -QskValueBar::QskValueBar( Qt::Orientation orientation, +QskProgressBar::QskProgressBar( Qt::Orientation orientation, qreal min, qreal max, QQuickItem* parent ) : QskBoundedControl( min, max, parent ) , m_data( new PrivateData ) @@ -38,39 +38,39 @@ QskValueBar::QskValueBar( Qt::Orientation orientation, initSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::MinimumExpanding ); connect( this, &QskBoundedControl::boundariesChanged, - this, &QskValueBar::adjustValue ); + this, &QskProgressBar::adjustValue ); } -QskValueBar::QskValueBar( Qt::Orientation orientation, QQuickItem* parent ) - : QskValueBar( orientation, 0.0, 100.0, parent ) +QskProgressBar::QskProgressBar( Qt::Orientation orientation, QQuickItem* parent ) + : QskProgressBar( orientation, 0.0, 100.0, parent ) { } -QskValueBar::QskValueBar( const QskIntervalF& boundaries, QQuickItem* parent ) - : QskValueBar( boundaries.lowerBound(), boundaries.upperBound(), parent ) +QskProgressBar::QskProgressBar( const QskIntervalF& boundaries, QQuickItem* parent ) + : QskProgressBar( boundaries.lowerBound(), boundaries.upperBound(), parent ) { } -QskValueBar::QskValueBar( qreal min, qreal max, QQuickItem* parent ) - : QskValueBar( Qt::Horizontal, min, max, parent ) +QskProgressBar::QskProgressBar( qreal min, qreal max, QQuickItem* parent ) + : QskProgressBar( Qt::Horizontal, min, max, parent ) { } -QskValueBar::QskValueBar( QQuickItem* parent ) - : QskValueBar( Qt::Horizontal, parent ) +QskProgressBar::QskProgressBar( QQuickItem* parent ) + : QskProgressBar( Qt::Horizontal, parent ) { } -QskValueBar::~QskValueBar() +QskProgressBar::~QskProgressBar() { } -Qt::Orientation QskValueBar::orientation() const +Qt::Orientation QskProgressBar::orientation() const { return m_data->orientation; } -void QskValueBar::setOrientation( Qt::Orientation orientation ) +void QskProgressBar::setOrientation( Qt::Orientation orientation ) { if ( orientation != m_data->orientation ) { @@ -84,26 +84,26 @@ void QskValueBar::setOrientation( Qt::Orientation orientation ) } } -QskAspect::Placement QskValueBar::effectivePlacement() const +QskAspect::Placement QskProgressBar::effectivePlacement() const { // so you can define different hints depending on the orientation return static_cast< QskAspect::Placement >( m_data->orientation ); } -void QskValueBar::setFillGradient( const QskGradient& gradient ) +void QskProgressBar::setFillGradient( const QskGradient& gradient ) { - setGradientHint( QskValueBar::ValueFill, gradient ); + setGradientHint( QskProgressBar::ValueFill, gradient ); } -QskGradient QskValueBar::fillGradient() const +QskGradient QskProgressBar::fillGradient() const { - return gradientHint( QskValueBar::ValueFill ); + return gradientHint( QskProgressBar::ValueFill ); } -void QskValueBar::setThickness( qreal thickness ) +void QskProgressBar::setThickness( qreal thickness ) { - // effectiveSubcontrol( QskValueBar::Groove ) ??? - const auto aspect = QskValueBar::Groove | QskAspect::Size; + // effectiveSubcontrol( QskProgressBar::Groove ) ??? + const auto aspect = QskProgressBar::Groove | QskAspect::Size; if ( thickness != metric( aspect ) ) { @@ -114,12 +114,12 @@ void QskValueBar::setThickness( qreal thickness ) } } -qreal QskValueBar::thickness() const +qreal QskProgressBar::thickness() const { return metric( Groove | QskAspect::Size ); } -void QskValueBar::setOrigin( qreal origin ) +void QskProgressBar::setOrigin( qreal origin ) { if ( isComponentComplete() ) origin = boundedValue( origin ); @@ -134,7 +134,7 @@ void QskValueBar::setOrigin( qreal origin ) } } -void QskValueBar::resetOrigin() +void QskProgressBar::resetOrigin() { if ( m_data->hasOrigin ) { @@ -144,7 +144,7 @@ void QskValueBar::resetOrigin() } } -qreal QskValueBar::origin() const +qreal QskProgressBar::origin() const { if ( m_data->hasOrigin ) { @@ -154,7 +154,7 @@ qreal QskValueBar::origin() const return minimum(); } -void QskValueBar::setValue( qreal value ) +void QskProgressBar::setValue( qreal value ) { if ( isComponentComplete() ) value = boundedValue( value ); @@ -162,23 +162,23 @@ void QskValueBar::setValue( qreal value ) setValueInternal( value ); } -qreal QskValueBar::value() const +qreal QskProgressBar::value() const { return m_data->value; } -void QskValueBar::setValueAsRatio( qreal ratio ) +void QskProgressBar::setValueAsRatio( qreal ratio ) { ratio = qBound( 0.0, ratio, 1.0 ); setValue( minimum() + ratio * boundaryLength() ); } -qreal QskValueBar::valueAsRatio() const +qreal QskProgressBar::valueAsRatio() const { return valueAsRatio( m_data->value ); } -QSizeF QskValueBar::contentsSizeHint( Qt::SizeHint which, const QSizeF& ) const +QSizeF QskProgressBar::contentsSizeHint( Qt::SizeHint which, const QSizeF& ) const { if ( which != Qt::PreferredSize ) return QSizeF(); @@ -189,19 +189,19 @@ QSizeF QskValueBar::contentsSizeHint( Qt::SizeHint which, const QSizeF& ) const return QSizeF( thickness(), -1 ); } -void QskValueBar::componentComplete() +void QskProgressBar::componentComplete() { Inherited::componentComplete(); adjustValue(); } -void QskValueBar::adjustValue() +void QskProgressBar::adjustValue() { if ( isComponentComplete() ) setValueInternal( boundedValue( m_data->value ) ); } -void QskValueBar::setValueInternal( qreal value ) +void QskProgressBar::setValueInternal( qreal value ) { if ( !qskFuzzyCompare( value, m_data->value ) ) { @@ -212,4 +212,4 @@ void QskValueBar::setValueInternal( qreal value ) } } -#include "moc_QskValueBar.cpp" +#include "moc_QskProgressBar.cpp" diff --git a/src/controls/QskValueBar.h b/src/controls/QskProgressBar.h similarity index 79% rename from src/controls/QskValueBar.h rename to src/controls/QskProgressBar.h index 124b2d44..2f9a2414 100644 --- a/src/controls/QskValueBar.h +++ b/src/controls/QskProgressBar.h @@ -3,14 +3,14 @@ * This file may be used under the terms of the QSkinny License, Version 1.0 *****************************************************************************/ -#ifndef QSK_VALUE_BAR_H -#define QSK_VALUE_BAR_H +#ifndef QSK_PROGRESS_BAR_H +#define QSK_PROGRESS_BAR_H #include "QskBoundedControl.h" class QskIntervalF; -class QSK_EXPORT QskValueBar : public QskBoundedControl +class QSK_EXPORT QskProgressBar : public QskBoundedControl { Q_OBJECT @@ -29,13 +29,13 @@ class QSK_EXPORT QskValueBar : public QskBoundedControl public: QSK_SUBCONTROLS( Groove, ValueFill ) - QskValueBar( Qt::Orientation, QQuickItem* parent = nullptr ); - QskValueBar( Qt::Orientation, qreal min, qreal max, QQuickItem* parent = nullptr ); - QskValueBar( const QskIntervalF&, QQuickItem* parent = nullptr ); - QskValueBar( qreal min, qreal max, QQuickItem* parent = nullptr ); - QskValueBar( QQuickItem* parent = nullptr ); + QskProgressBar( Qt::Orientation, QQuickItem* parent = nullptr ); + QskProgressBar( Qt::Orientation, qreal min, qreal max, QQuickItem* parent = nullptr ); + QskProgressBar( const QskIntervalF&, QQuickItem* parent = nullptr ); + QskProgressBar( qreal min, qreal max, QQuickItem* parent = nullptr ); + QskProgressBar( QQuickItem* parent = nullptr ); - ~QskValueBar() override; + ~QskProgressBar() override; Qt::Orientation orientation() const; void setOrientation( Qt::Orientation orientation ); diff --git a/src/controls/QskValueBarSkinlet.cpp b/src/controls/QskProgressBarSkinlet.cpp similarity index 71% rename from src/controls/QskValueBarSkinlet.cpp rename to src/controls/QskProgressBarSkinlet.cpp index 303245b8..e2cb5c86 100644 --- a/src/controls/QskValueBarSkinlet.cpp +++ b/src/controls/QskProgressBarSkinlet.cpp @@ -3,28 +3,28 @@ * This file may be used under the terms of the QSkinny License, Version 1.0 *****************************************************************************/ -#include "QskValueBarSkinlet.h" -#include "QskValueBar.h" +#include "QskProgressBarSkinlet.h" +#include "QskProgressBar.h" #include -QskValueBarSkinlet::QskValueBarSkinlet( QskSkin* skin ) +QskProgressBarSkinlet::QskProgressBarSkinlet( QskSkin* skin ) : QskSkinlet( skin ) { setNodeRoles( { GrooveRole, ValueFillRole } ); } -QskValueBarSkinlet::~QskValueBarSkinlet() +QskProgressBarSkinlet::~QskProgressBarSkinlet() { } -QRectF QskValueBarSkinlet::subControlRect( +QRectF QskProgressBarSkinlet::subControlRect( const QskSkinnable* skinnable, const QRectF& contentsRect, QskAspect::Subcontrol subControl ) const { - const auto bar = static_cast< const QskValueBar* >( skinnable ); + const auto bar = static_cast< const QskProgressBar* >( skinnable ); - if( ( subControl == QskValueBar::Groove ) ) + if( ( subControl == QskProgressBar::Groove ) ) { const auto dim = bar->thickness(); @@ -43,28 +43,28 @@ QRectF QskValueBarSkinlet::subControlRect( return rect; } - if( subControl == QskValueBar::ValueFill ) + if( subControl == QskProgressBar::ValueFill ) { - const auto bar = static_cast< const QskValueBar* >( skinnable ); + const auto bar = static_cast< const QskProgressBar* >( skinnable ); return fillRect( bar ); } return Inherited::subControlRect( skinnable, contentsRect, subControl ); } -QSGNode* QskValueBarSkinlet::updateSubNode( +QSGNode* QskProgressBarSkinlet::updateSubNode( const QskSkinnable* skinnable, quint8 nodeRole, QSGNode* node ) const { switch( nodeRole ) { case GrooveRole: { - return updateBoxNode( skinnable, node, QskValueBar::Groove ); + return updateBoxNode( skinnable, node, QskProgressBar::Groove ); } case ValueFillRole: { - const auto bar = static_cast< const QskValueBar* >( skinnable ); + const auto bar = static_cast< const QskProgressBar* >( skinnable ); return updateFillNode( bar, node ); } } @@ -72,10 +72,10 @@ QSGNode* QskValueBarSkinlet::updateSubNode( return Inherited::updateSubNode( skinnable, nodeRole, node ); } -QSGNode* QskValueBarSkinlet::updateFillNode( - const QskValueBar* bar, QSGNode* node ) const +QSGNode* QskProgressBarSkinlet::updateFillNode( + const QskProgressBar* bar, QSGNode* node ) const { - const auto subControl = QskValueBar::ValueFill; + const auto subControl = QskProgressBar::ValueFill; const auto rect = bar->subControlRect( subControl ); if ( rect.isEmpty() ) @@ -104,10 +104,10 @@ QSGNode* QskValueBarSkinlet::updateFillNode( return updateBoxNode( bar, node, rect, gradient, subControl ); } -QRectF QskValueBarSkinlet::fillRect( const QskValueBar* bar ) const +QRectF QskProgressBarSkinlet::fillRect( const QskProgressBar* bar ) const { - auto rect = bar->subControlRect( QskValueBar::Groove ); - rect = bar->innerBox( QskValueBar::Groove, rect ); + auto rect = bar->subControlRect( QskProgressBar::Groove ); + rect = bar->innerBox( QskProgressBar::Groove, rect ); auto pos1 = bar->valueAsRatio( bar->origin() ); auto pos2 = bar->valueAsRatio( bar->value() ); @@ -133,4 +133,4 @@ QRectF QskValueBarSkinlet::fillRect( const QskValueBar* bar ) const return rect; } -#include "moc_QskValueBarSkinlet.cpp" +#include "moc_QskProgressBarSkinlet.cpp" diff --git a/src/controls/QskValueBarSkinlet.h b/src/controls/QskProgressBarSkinlet.h similarity index 65% rename from src/controls/QskValueBarSkinlet.h rename to src/controls/QskProgressBarSkinlet.h index bf3f336e..c8fbd837 100644 --- a/src/controls/QskValueBarSkinlet.h +++ b/src/controls/QskProgressBarSkinlet.h @@ -3,14 +3,14 @@ * This file may be used under the terms of the QSkinny License, Version 1.0 *****************************************************************************/ -#ifndef QSK_VALUE_BAR_SKINLET_H -#define QSK_VALUE_BAR_SKINLET_H +#ifndef QSK_PROGRESS_BAR_SKINLET_H +#define QSK_PROGRESS_BAR_SKINLET_H #include "QskSkinlet.h" -class QskValueBar; +class QskProgressBar; -class QSK_EXPORT QskValueBarSkinlet : public QskSkinlet +class QSK_EXPORT QskProgressBarSkinlet : public QskSkinlet { Q_GADGET @@ -25,8 +25,8 @@ class QSK_EXPORT QskValueBarSkinlet : public QskSkinlet RoleCount, }; - Q_INVOKABLE QskValueBarSkinlet( QskSkin* = nullptr ); - ~QskValueBarSkinlet() override; + Q_INVOKABLE QskProgressBarSkinlet( QskSkin* = nullptr ); + ~QskProgressBarSkinlet() override; QRectF subControlRect( const QskSkinnable*, const QRectF&, QskAspect::Subcontrol ) const override; @@ -36,8 +36,8 @@ class QSK_EXPORT QskValueBarSkinlet : public QskSkinlet quint8 nodeRole, QSGNode* ) const override; private: - QSGNode* updateFillNode( const QskValueBar*, QSGNode* ) const; - QRectF fillRect( const QskValueBar* ) const; + QSGNode* updateFillNode( const QskProgressBar*, QSGNode* ) const; + QRectF fillRect( const QskProgressBar* ) const; }; #endif diff --git a/src/controls/QskSkin.cpp b/src/controls/QskSkin.cpp index a241d141..20558b0f 100644 --- a/src/controls/QskSkin.cpp +++ b/src/controls/QskSkin.cpp @@ -71,12 +71,12 @@ QSK_QT_PRIVATE_END #include "QskPageIndicator.h" #include "QskPageIndicatorSkinlet.h" +#include "QskProgressBar.h" +#include "QskProgressBarSkinlet.h" + #include "QskStatusIndicator.h" #include "QskStatusIndicatorSkinlet.h" -#include "QskValueBar.h" -#include "QskValueBarSkinlet.h" - static inline QskSkinlet* qskNewSkinlet( const QMetaObject* metaObject, QskSkin* skin ) { const QByteArray signature = metaObject->className() + QByteArrayLiteral( "(QskSkin*)" ); @@ -151,7 +151,7 @@ QskSkin::QskSkin( QObject* parent ) declareSkinlet< QskTabView, QskTabViewSkinlet >(); declareSkinlet< QskTextLabel, QskTextLabelSkinlet >(); declareSkinlet< QskTextInput, QskTextInputSkinlet >(); - declareSkinlet< QskValueBar, QskValueBarSkinlet >(); + declareSkinlet< QskProgressBar, QskProgressBarSkinlet >(); const QFont font = QGuiApplication::font(); setupFonts( font.family(), font.weight(), font.italic() ); diff --git a/src/src.pro b/src/src.pro index baa0e634..a396b450 100644 --- a/src/src.pro +++ b/src/src.pro @@ -141,6 +141,8 @@ HEADERS += \ controls/QskPopupSkinlet.h \ controls/QskPushButton.h \ controls/QskPushButtonSkinlet.h \ + controls/QskProgressBar.h \ + controls/QskProgressBarSkinlet.h \ controls/QskQuick.h \ controls/QskQuickItem.h \ controls/QskQuickItemPrivate.h \ @@ -177,8 +179,6 @@ HEADERS += \ controls/QskTextInputSkinlet.h \ controls/QskTextLabel.h \ controls/QskTextLabelSkinlet.h \ - controls/QskValueBar.h \ - controls/QskValueBarSkinlet.h \ controls/QskVariantAnimator.h \ controls/QskWindow.h @@ -214,6 +214,8 @@ SOURCES += \ controls/QskPopupSkinlet.cpp \ controls/QskPushButton.cpp \ controls/QskPushButtonSkinlet.cpp \ + controls/QskProgressBar.cpp \ + controls/QskProgressBarSkinlet.cpp \ controls/QskQuick.cpp \ controls/QskQuickItem.cpp \ controls/QskQuickItemPrivate.cpp \ @@ -250,8 +252,6 @@ SOURCES += \ controls/QskTextInputSkinlet.cpp \ controls/QskTextLabel.cpp \ controls/QskTextLabelSkinlet.cpp \ - controls/QskValueBar.cpp \ - controls/QskValueBarSkinlet.cpp \ controls/QskVariantAnimator.cpp \ controls/QskWindow.cpp