qskinny/examples/iotdashboard/LightIntensity.h
Uwe Rathmann d947920abe Squashed commit of the following:
commit f429d3ab4e82ab06bfd40577aef8e2d5fdfd59fd
Author: Uwe Rathmann <Uwe.Rathmann@tigertal.de>
Date:   Wed Aug 4 14:40:36 2021 +0200

    subcontrolProxy introduced
2021-08-04 15:06:04 +02:00

107 lines
2.1 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 "Box.h"
#include <QskTextLabel.h>
#include <QQuickPaintedItem>
#include <QRadialGradient>
class DimmerAnimator;
class QskTextLabel;
class LightIntensityValueLabel : public QskTextLabel
{
Q_OBJECT
public:
QSK_SUBCONTROLS( Text )
LightIntensityValueLabel( const QString& text, QQuickItem* parent )
: QskTextLabel( text, parent )
{
setSubcontrolProxy( QskTextLabel::Text, Text );
}
};
class LightDimmer : public QQuickPaintedItem
{
Q_OBJECT
public:
LightDimmer( const QskGradient& coldGradient,
const QskGradient& warmGradient, QQuickItem* parent );
double thickness() const
{
return m_thickness;
}
void setThickness( double thickness )
{
m_thickness = thickness;
}
QColor backgroundColor() const
{
return m_backgroundColor;
}
void setBackgroundColor( const QColor& color )
{
m_backgroundColor = color;
}
QRadialGradient ringGradient() const
{
return m_ringGradient;
}
void setRingGradient( const QRadialGradient& gradient )
{
m_ringGradient = gradient;
}
private:
virtual void paint( QPainter* painter ) override;
double m_thickness = 17.57;
QColor m_backgroundColor;
QRadialGradient m_ringGradient;
QskGradient m_coldGradient;
QskGradient m_warmGradient;
};
class LightDisplay : public QskControl
{
Q_OBJECT
public:
QSK_SUBCONTROLS( Panel, ColdPart, WarmPart )
LightDisplay( QQuickItem* parent );
protected:
void updateLayout() override;
private:
QskTextLabel* m_leftLabel;
LightIntensityValueLabel* m_centreLabel;
QskTextLabel* m_rightLabel;
LightDimmer* m_dimmer;
DimmerAnimator* m_animator;
};
class LightIntensity : public Box
{
Q_OBJECT
public:
LightIntensity( QQuickItem* parent );
};