QskValueBar -> QskProgressBar

This commit is contained in:
Uwe Rathmann 2020-08-01 17:51:45 +02:00
parent 7cd4b940aa
commit cad27956e6
10 changed files with 92 additions and 92 deletions

View File

@ -13,6 +13,7 @@
#include <QskListView.h>
#include <QskPageIndicator.h>
#include <QskPushButton.h>
#include <QskProgressBar.h>
#include <QskScrollView.h>
#include <QskSeparator.h>
#include <QskSlider.h>
@ -22,7 +23,6 @@
#include <QskTabView.h>
#include <QskTextInput.h>
#include <QskTextLabel.h>
#include <QskValueBar.h>
#include <QskVirtualKeyboard.h>
#include <QskSkinlet.h>
@ -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;

View File

@ -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;

View File

@ -13,6 +13,7 @@
#include <QskInputPredictionBar.h>
#include <QskListView.h>
#include <QskPageIndicator.h>
#include <QskProgressBar.h>
#include <QskPushButton.h>
#include <QskScrollView.h>
#include <QskSeparator.h>
@ -23,7 +24,6 @@
#include <QskTabView.h>
#include <QskTextInput.h>
#include <QskTextLabel.h>
#include <QskValueBar.h>
#include <QskVirtualKeyboard.h>
#include <QskSkinlet.h>
@ -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;

View File

@ -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
{

View File

@ -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"

View File

@ -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 );

View File

@ -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 <cmath>
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"

View File

@ -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

View File

@ -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() );

View File

@ -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