PieChartPainted renamed to EnergyMeter. Name was misleading as it is

more of a decorated arc progressbar than a pie or a doughnut chart.
This commit is contained in:
Uwe Rathmann 2022-10-26 16:47:42 +02:00
parent 70664a2f67
commit 4aeea2d6f8
4 changed files with 19 additions and 24 deletions

View File

@ -3,23 +3,18 @@
* This file may be used under the terms of the 3-clause BSD License * This file may be used under the terms of the 3-clause BSD License
*****************************************************************************/ *****************************************************************************/
#include "PieChartPainted.h" #include "EnergyMeter.h"
#include "CircularProgressBar.h" #include "CircularProgressBar.h"
#include <QskAnimator.h>
#include <QskBox.h>
#include <QskRgbValue.h>
#include <QskSetup.h>
#include <QskSkin.h>
#include <QskTextLabel.h> #include <QskTextLabel.h>
#include <QskFunctions.h> #include <QskSkin.h>
namespace namespace
{ {
class ProgressLabel : public QskTextLabel class ValueLabel : public QskTextLabel
{ {
public: public:
ProgressLabel( QQuickItem* parent ) ValueLabel( QQuickItem* parent )
: QskTextLabel( parent ) : QskTextLabel( parent )
{ {
initSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed ); initSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed );
@ -34,22 +29,22 @@ namespace
}; };
} }
PieChartPainted::PieChartPainted( const QColor& textColor, const QskGradient& gradient, EnergyMeter::EnergyMeter( const QColor& textColor,
int progress, QQuickItem* parent ) const QskGradient& gradient, int value, QQuickItem* parent )
: QskControl( parent ) : QskControl( parent )
{ {
setAutoLayoutChildren( true ); setAutoLayoutChildren( true );
auto progressBar = new CircularProgressBar( this ); auto valueBar = new CircularProgressBar( this );
progressBar->setGradientHint( CircularProgressBar::Bar, gradient ); valueBar->setGradientHint( CircularProgressBar::Bar, gradient );
progressBar->setValue( progress ); valueBar->setValue( value );
auto progressLabel = new ProgressLabel( this ); auto valueLabel = new ValueLabel( this );
progressLabel->setTextColor( textColor ); valueLabel->setTextColor( textColor );
progressLabel->setValue( progress ); valueLabel->setValue( value );
} }
QSizeF PieChartPainted::contentsSizeHint( QSizeF EnergyMeter::contentsSizeHint(
Qt::SizeHint which, const QSizeF& constraint ) const Qt::SizeHint which, const QSizeF& constraint ) const
{ {
if ( which != Qt::PreferredSize ) if ( which != Qt::PreferredSize )

View File

@ -7,10 +7,10 @@
#include <QskControl.h> #include <QskControl.h>
class PieChartPainted : public QskControl class EnergyMeter : public QskControl
{ {
public: public:
PieChartPainted( const QColor&, const QskGradient&, EnergyMeter( const QColor&, const QskGradient&,
int progress, QQuickItem* parent = nullptr ); int progress, QQuickItem* parent = nullptr );
protected: protected:

View File

@ -4,7 +4,7 @@
*****************************************************************************/ *****************************************************************************/
#include "TopBar.h" #include "TopBar.h"
#include "PieChartPainted.h" #include "EnergyMeter.h"
#include <QskSkin.h> #include <QskSkin.h>
#include <QskTextLabel.h> #include <QskTextLabel.h>
@ -62,7 +62,7 @@ TopBarItem::TopBarItem(
const auto subcontrol = subcontrolForIndex( index ); const auto subcontrol = subcontrolForIndex( index );
const auto textColor = color( subcontrol | QskAspect::TextColor ); const auto textColor = color( subcontrol | QskAspect::TextColor );
auto pieChart = new PieChartPainted( auto pieChart = new EnergyMeter(
textColor, gradient, progress, pieChartAndDisplay ); textColor, gradient, progress, pieChartAndDisplay );
pieChart->setSizePolicy( Qt::Horizontal, QskSizePolicy::Constrained ); pieChart->setSizePolicy( Qt::Horizontal, QskSizePolicy::Constrained );

View File

@ -11,6 +11,7 @@ SOURCES += \
DashboardPage.cpp \ DashboardPage.cpp \
Diagram.cpp \ Diagram.cpp \
DiagramSkinlet.cpp \ DiagramSkinlet.cpp \
EnergyMeter.cpp \
GraphicProvider.cpp \ GraphicProvider.cpp \
GridBox.cpp \ GridBox.cpp \
LightDisplaySkinlet.cpp \ LightDisplaySkinlet.cpp \
@ -18,7 +19,6 @@ SOURCES += \
MainItem.cpp \ MainItem.cpp \
MenuBar.cpp \ MenuBar.cpp \
MyDevices.cpp \ MyDevices.cpp \
PieChartPainted.cpp \
RoomsPage.cpp \ RoomsPage.cpp \
RoundedIcon.cpp \ RoundedIcon.cpp \
Skin.cpp \ Skin.cpp \
@ -41,6 +41,7 @@ HEADERS += \
CircularProgressBarSkinlet.h \ CircularProgressBarSkinlet.h \
Diagram.h \ Diagram.h \
DiagramSkinlet.h \ DiagramSkinlet.h \
EnergyMeter.h \
GraphicProvider.h \ GraphicProvider.h \
GridBox.h \ GridBox.h \
LightDisplaySkinlet.h \ LightDisplaySkinlet.h \
@ -50,7 +51,6 @@ HEADERS += \
MainWindow.h \ MainWindow.h \
MenuBar.h \ MenuBar.h \
MyDevices.h \ MyDevices.h \
PieChartPainted.h \
RoomsPage.h \ RoomsPage.h \
RoundedIcon.h \ RoundedIcon.h \
Skin.h \ Skin.h \