![Peter Hartmann](/assets/img/avatar_default.png)
* IOT example, circular progress bar: Use a pen instead of a brush That way we don't have to draw two circles, and we can in addition use a conical gradient. * IOT example: Make circular progress bar a QskControl ... and internally use a QskPaintedNode for now. By doing this we already have the API ready (similar to QskProgressBar) and can swap the QskPaintedNode with an arc renderer at a later point in time.
64 lines
1.7 KiB
C++
64 lines
1.7 KiB
C++
/******************************************************************************
|
|
* Copyright (C) 2021 Edelhirsch Software GmbH
|
|
* This file may be used under the terms of the 3-clause BSD License
|
|
*****************************************************************************/
|
|
|
|
#pragma once
|
|
|
|
#include <QskBoundedControl.h>
|
|
#include <QskGradient.h>
|
|
|
|
#include <QGradient>
|
|
|
|
class CircularProgressBar : public QskBoundedControl
|
|
{
|
|
Q_OBJECT
|
|
|
|
Q_PROPERTY( bool indeterminate READ isIndeterminate
|
|
WRITE setIndeterminate NOTIFY indeterminateChanged )
|
|
|
|
Q_PROPERTY( qreal origin READ origin
|
|
WRITE setOrigin RESET resetOrigin NOTIFY originChanged )
|
|
|
|
Q_PROPERTY( qreal value READ value WRITE setValue NOTIFY valueChanged )
|
|
Q_PROPERTY( qreal valueAsRatio READ valueAsRatio
|
|
WRITE setValueAsRatio NOTIFY valueChanged )
|
|
|
|
using Inherited = QskBoundedControl;
|
|
|
|
public:
|
|
QSK_SUBCONTROLS( Groove, Bar )
|
|
|
|
CircularProgressBar( qreal min, qreal max, QQuickItem* parent = nullptr );
|
|
CircularProgressBar( QQuickItem* parent = nullptr );
|
|
|
|
bool isIndeterminate() const;
|
|
void setIndeterminate( bool on = true );
|
|
|
|
void resetOrigin();
|
|
qreal origin() const;
|
|
|
|
qreal value() const;
|
|
qreal valueAsRatio() const; // [0.0, 1.0]
|
|
|
|
public Q_SLOTS:
|
|
void setValue( qreal );
|
|
void setValueAsRatio( qreal );
|
|
void setOrigin( qreal );
|
|
|
|
Q_SIGNALS:
|
|
void indeterminateChanged( bool );
|
|
void valueChanged( qreal );
|
|
void originChanged( qreal );
|
|
|
|
protected:
|
|
void componentComplete() override;
|
|
|
|
private:
|
|
void setValueInternal( qreal value );
|
|
void adjustValue();
|
|
|
|
class PrivateData;
|
|
std::unique_ptr< PrivateData > m_data;
|
|
};
|