CircularProgressBar removed, using QskProgressRing instead
This commit is contained in:
parent
86942d4226
commit
c61e3c7f36
|
@ -159,6 +159,7 @@ void ProgressBarPage::populate()
|
||||||
{
|
{
|
||||||
auto* ring = new QskProgressRing( determinateRingsHBox );
|
auto* ring = new QskProgressRing( determinateRingsHBox );
|
||||||
ring->setSize( size );
|
ring->setSize( size );
|
||||||
|
ring->setLayoutAlignmentHint( Qt::AlignCenter );
|
||||||
|
|
||||||
QQuickItem* parentItem;
|
QQuickItem* parentItem;
|
||||||
|
|
||||||
|
|
|
@ -6,8 +6,6 @@
|
||||||
set(SOURCES
|
set(SOURCES
|
||||||
Box.h Box.cpp
|
Box.h Box.cpp
|
||||||
BoxWithButtons.h BoxWithButtons.cpp
|
BoxWithButtons.h BoxWithButtons.cpp
|
||||||
CircularProgressBar.h CircularProgressBar.cpp
|
|
||||||
CircularProgressBarSkinlet.h CircularProgressBarSkinlet.cpp
|
|
||||||
Diagram.h Diagram.cpp
|
Diagram.h Diagram.cpp
|
||||||
DiagramSkinlet.h DiagramSkinlet.cpp
|
DiagramSkinlet.h DiagramSkinlet.cpp
|
||||||
EnergyMeter.h EnergyMeter.cpp
|
EnergyMeter.h EnergyMeter.cpp
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
/******************************************************************************
|
|
||||||
* Copyright (C) 2021 Edelhirsch Software GmbH
|
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
#include "CircularProgressBar.h"
|
|
||||||
|
|
||||||
CircularProgressBar::CircularProgressBar( qreal min, qreal max, QQuickItem* parent )
|
|
||||||
: Inherited( min, max, parent )
|
|
||||||
{
|
|
||||||
initSizePolicy( QskSizePolicy::MinimumExpanding, QskSizePolicy::MinimumExpanding );
|
|
||||||
}
|
|
||||||
|
|
||||||
CircularProgressBar::CircularProgressBar( QQuickItem* parent )
|
|
||||||
: CircularProgressBar( 0.0, 100.0, parent )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "moc_CircularProgressBar.cpp"
|
|
|
@ -1,21 +0,0 @@
|
||||||
/******************************************************************************
|
|
||||||
* Copyright (C) 2021 Edelhirsch Software GmbH
|
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QskProgressRing.h>
|
|
||||||
|
|
||||||
class CircularProgressBar : public QskProgressRing
|
|
||||||
{
|
|
||||||
Q_OBJECT
|
|
||||||
|
|
||||||
using Inherited = QskProgressRing;
|
|
||||||
|
|
||||||
public:
|
|
||||||
CircularProgressBar( qreal min, qreal max, QQuickItem* parent = nullptr );
|
|
||||||
CircularProgressBar( QQuickItem* parent = nullptr );
|
|
||||||
|
|
||||||
~CircularProgressBar() override = default;
|
|
||||||
};
|
|
|
@ -1,24 +0,0 @@
|
||||||
/******************************************************************************
|
|
||||||
* Copyright (C) 2021 Edelhirsch Software GmbH
|
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
#include "CircularProgressBarSkinlet.h"
|
|
||||||
#include <QskProgressIndicator.h>
|
|
||||||
|
|
||||||
CircularProgressBarSkinlet::CircularProgressBarSkinlet( QskSkin* skin )
|
|
||||||
: Inherited( skin )
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
CircularProgressBarSkinlet::~CircularProgressBarSkinlet()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
QRectF CircularProgressBarSkinlet::subControlRect(
|
|
||||||
const QskSkinnable*, const QRectF& contentsRect, QskAspect::Subcontrol ) const
|
|
||||||
{
|
|
||||||
return contentsRect;
|
|
||||||
}
|
|
||||||
|
|
||||||
#include "moc_CircularProgressBarSkinlet.cpp"
|
|
|
@ -1,23 +0,0 @@
|
||||||
/******************************************************************************
|
|
||||||
* Copyright (C) 2021 Edelhirsch Software GmbH
|
|
||||||
* SPDX-License-Identifier: BSD-3-Clause
|
|
||||||
*****************************************************************************/
|
|
||||||
|
|
||||||
#pragma once
|
|
||||||
|
|
||||||
#include <QskProgressRingSkinlet.h>
|
|
||||||
|
|
||||||
class CircularProgressBarSkinlet : public QskProgressRingSkinlet
|
|
||||||
{
|
|
||||||
Q_GADGET
|
|
||||||
|
|
||||||
using Inherited = QskProgressRingSkinlet;
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
Q_INVOKABLE CircularProgressBarSkinlet( QskSkin* = nullptr );
|
|
||||||
~CircularProgressBarSkinlet() override;
|
|
||||||
|
|
||||||
QRectF subControlRect( const QskSkinnable*,
|
|
||||||
const QRectF&, QskAspect::Subcontrol ) const override;
|
|
||||||
};
|
|
|
@ -4,8 +4,8 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "EnergyMeter.h"
|
#include "EnergyMeter.h"
|
||||||
#include "CircularProgressBar.h"
|
|
||||||
|
|
||||||
|
#include <QskProgressRing.h>
|
||||||
#include <QskTextLabel.h>
|
#include <QskTextLabel.h>
|
||||||
#include <QskFontRole.h>
|
#include <QskFontRole.h>
|
||||||
|
|
||||||
|
@ -35,8 +35,10 @@ EnergyMeter::EnergyMeter( const QColor& textColor,
|
||||||
{
|
{
|
||||||
setAutoLayoutChildren( true );
|
setAutoLayoutChildren( true );
|
||||||
|
|
||||||
auto valueBar = new CircularProgressBar( this );
|
auto valueBar = new QskProgressRing( this );
|
||||||
valueBar->setGradientHint( CircularProgressBar::Fill, gradient );
|
valueBar->setSizePolicy(
|
||||||
|
QskSizePolicy::MinimumExpanding, QskSizePolicy::Constrained );
|
||||||
|
valueBar->setFillGradient( gradient );
|
||||||
valueBar->setValue( value );
|
valueBar->setValue( value );
|
||||||
|
|
||||||
auto valueLabel = new ValueLabel( this );
|
auto valueLabel = new ValueLabel( this );
|
||||||
|
|
|
@ -7,8 +7,6 @@
|
||||||
|
|
||||||
#include "Box.h"
|
#include "Box.h"
|
||||||
#include "BoxWithButtons.h"
|
#include "BoxWithButtons.h"
|
||||||
#include "CircularProgressBar.h"
|
|
||||||
#include "CircularProgressBarSkinlet.h"
|
|
||||||
#include "DashboardPage.h"
|
#include "DashboardPage.h"
|
||||||
#include "Diagram.h"
|
#include "Diagram.h"
|
||||||
#include "DiagramSkinlet.h"
|
#include "DiagramSkinlet.h"
|
||||||
|
@ -56,7 +54,6 @@ Skin::Skin( QObject* parent )
|
||||||
{
|
{
|
||||||
setObjectName( "iot" );
|
setObjectName( "iot" );
|
||||||
|
|
||||||
declareSkinlet< CircularProgressBar, CircularProgressBarSkinlet >();
|
|
||||||
declareSkinlet< Diagram, DiagramSkinlet >();
|
declareSkinlet< Diagram, DiagramSkinlet >();
|
||||||
declareSkinlet< LightDisplay, LightDisplaySkinlet >();
|
declareSkinlet< LightDisplay, LightDisplaySkinlet >();
|
||||||
declareSkinlet< StorageBar, StorageBarSkinlet >();
|
declareSkinlet< StorageBar, StorageBarSkinlet >();
|
||||||
|
@ -127,10 +124,10 @@ void Skin::initHints()
|
||||||
ed.setGradient( TopBarItem::Item4, 0xff6776ff, 0xff6100ff );
|
ed.setGradient( TopBarItem::Item4, 0xff6776ff, 0xff6100ff );
|
||||||
|
|
||||||
// the bar gradient is defined through the top bar items above
|
// the bar gradient is defined through the top bar items above
|
||||||
ed.setArcMetrics( CircularProgressBar::Groove, 90, -360, 8.53 );
|
ed.setArcMetrics( QskProgressRing::Groove, 90, -360, 8.53 );
|
||||||
// the span angle will be set in the progress bar, we just give a dummy
|
// the span angle will be set in the progress bar, we just give a dummy
|
||||||
// value here:
|
// value here:
|
||||||
ed.setArcMetrics( CircularProgressBar::Fill, 90, -360, 8.53 );
|
ed.setArcMetrics( QskProgressRing::Fill, 90, -360, 8.53 );
|
||||||
|
|
||||||
ed.setFontRole( TimeTitleLabel::Text, { QskFontRole::Caption, QskFontRole::High } );
|
ed.setFontRole( TimeTitleLabel::Text, { QskFontRole::Caption, QskFontRole::High } );
|
||||||
|
|
||||||
|
@ -282,8 +279,8 @@ void Skin::initHints()
|
||||||
ed.setColor( QskTextLabel::Text, palette.text );
|
ed.setColor( QskTextLabel::Text, palette.text );
|
||||||
ed.setColor( UsageDiagramBox::DayText, palette.text );
|
ed.setColor( UsageDiagramBox::DayText, palette.text );
|
||||||
|
|
||||||
ed.setMetric( CircularProgressBar::Groove | QskAspect::Border, 2 );
|
ed.setMetric( QskProgressRing::Groove | QskAspect::Border, 2 );
|
||||||
ed.setColor( CircularProgressBar::Groove | QskAspect::Border,
|
ed.setColor( QskProgressRing::Groove | QskAspect::Border,
|
||||||
palette.circularProgressBarGroove );
|
palette.circularProgressBarGroove );
|
||||||
|
|
||||||
// storage bar
|
// storage bar
|
||||||
|
|
|
@ -4,44 +4,47 @@
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
|
||||||
#include "StorageMeter.h"
|
#include "StorageMeter.h"
|
||||||
#include "CircularProgressBar.h"
|
|
||||||
#include <QskFontRole.h>
|
#include <QskFontRole.h>
|
||||||
#include <QskTextLabel.h>
|
#include <QskTextLabel.h>
|
||||||
|
|
||||||
QSK_SUBCONTROL( StorageMeter, Status )
|
QSK_SUBCONTROL( StorageMeter, Status )
|
||||||
|
|
||||||
namespace
|
|
||||||
{
|
|
||||||
inline QString make_text( const QLocale& locale, const qreal value )
|
|
||||||
{
|
|
||||||
return locale.toString( static_cast< int >( value ) ) + " " + locale.percent();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
StorageMeter::StorageMeter( QQuickItem* parent ) noexcept
|
StorageMeter::StorageMeter( QQuickItem* parent ) noexcept
|
||||||
: CircularProgressBar( parent )
|
: QskProgressRing( parent )
|
||||||
, label( new QskTextLabel( this ) )
|
|
||||||
{
|
{
|
||||||
setAutoLayoutChildren( true );
|
setAutoLayoutChildren( true );
|
||||||
setSizePolicy( QskSizePolicy::Preferred, QskSizePolicy::Constrained );
|
initSizePolicy( QskSizePolicy::MinimumExpanding, QskSizePolicy::Constrained );
|
||||||
|
|
||||||
label->setText( make_text( locale(), value() ) );
|
m_label = new QskTextLabel( this );
|
||||||
label->setSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed );
|
m_label->setSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed );
|
||||||
label->setLayoutAlignmentHint( Qt::AlignCenter );
|
m_label->setLayoutAlignmentHint( Qt::AlignCenter );
|
||||||
label->setFontRole( QskFontRole::Caption );
|
m_label->setFontRole( QskFontRole::Caption );
|
||||||
|
|
||||||
|
connect( this, &QskProgressRing::valueChanged,
|
||||||
|
this, &StorageMeter::updateMeter );
|
||||||
|
|
||||||
|
updateMeter( value() );
|
||||||
}
|
}
|
||||||
|
|
||||||
void StorageMeter::setValue( const qreal value )
|
void StorageMeter::updateMeter( const qreal value )
|
||||||
{
|
{
|
||||||
const auto gradient = gradientHint( StorageMeter::Status );
|
const auto color = qskInterpolatedColorAt(
|
||||||
const auto color = gradient.extracted( value / 100.0, value / 100.0 ).startColor();
|
gradientHint( Status ).stops(), value / 100.0 );
|
||||||
setGradientHint( StorageMeter::Fill, { color, color.lighter() } );
|
|
||||||
CircularProgressBar::setValue( value );
|
setFillGradient( { color, color.lighter() } );
|
||||||
label->setTextColor( color );
|
|
||||||
label->setText( make_text( locale(), value ) );
|
m_label->setTextColor( color );
|
||||||
|
|
||||||
|
const auto locale = this->locale();
|
||||||
|
const auto text = locale.toString( static_cast< int >( value ) )
|
||||||
|
+ " " + locale.percent();
|
||||||
|
|
||||||
|
m_label->setText( text );
|
||||||
}
|
}
|
||||||
|
|
||||||
QSizeF StorageMeter::contentsSizeHint( Qt::SizeHint which, const QSizeF& constraint ) const
|
QSizeF StorageMeter::contentsSizeHint(
|
||||||
|
Qt::SizeHint which, const QSizeF& constraint ) const
|
||||||
{
|
{
|
||||||
if ( which != Qt::PreferredSize )
|
if ( which != Qt::PreferredSize )
|
||||||
return QSizeF();
|
return QSizeF();
|
||||||
|
|
|
@ -5,18 +5,20 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "CircularProgressBar.h"
|
#include <QskProgressRing.h>
|
||||||
#include <QskControl.h>
|
|
||||||
|
|
||||||
class StorageMeter final : public CircularProgressBar
|
class QskTextLabel;
|
||||||
|
|
||||||
|
class StorageMeter final : public QskProgressRing
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
QSK_SUBCONTROLS( Status )
|
QSK_SUBCONTROLS( Status )
|
||||||
explicit StorageMeter( QQuickItem* parent = nullptr ) noexcept;
|
|
||||||
public Q_SLOTS:
|
StorageMeter( QQuickItem* parent = nullptr ) noexcept;
|
||||||
void setValue( qreal value );
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QSizeF contentsSizeHint( Qt::SizeHint which, const QSizeF& constraint ) const override;
|
void updateMeter( qreal value );
|
||||||
class QskTextLabel* label = nullptr;
|
QSizeF contentsSizeHint( Qt::SizeHint, const QSizeF& ) const override;
|
||||||
|
|
||||||
|
QskTextLabel* m_label = nullptr;
|
||||||
};
|
};
|
||||||
|
|
|
@ -20,6 +20,8 @@ QskProgressRing::QskProgressRing( qreal min, qreal max, QQuickItem* parent )
|
||||||
: Inherited( min, max, parent )
|
: Inherited( min, max, parent )
|
||||||
, m_data( new PrivateData )
|
, m_data( new PrivateData )
|
||||||
{
|
{
|
||||||
|
initSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed );
|
||||||
|
|
||||||
m_data->size = NormalSize;
|
m_data->size = NormalSize;
|
||||||
|
|
||||||
setSubcontrolProxy( Inherited::Groove, Groove );
|
setSubcontrolProxy( Inherited::Groove, Groove );
|
||||||
|
|
|
@ -24,22 +24,7 @@ QRectF QskProgressRingSkinlet::subControlRect(
|
||||||
QskAspect::Subcontrol subControl ) const
|
QskAspect::Subcontrol subControl ) const
|
||||||
{
|
{
|
||||||
if( subControl == Q::Groove || subControl == Q::Fill )
|
if( subControl == Q::Groove || subControl == Q::Fill )
|
||||||
{
|
return contentsRect;
|
||||||
const auto ring = static_cast< const Q* >( skinnable );
|
|
||||||
|
|
||||||
const auto size = ring->strutSizeHint( Q::Fill );
|
|
||||||
|
|
||||||
auto rect = contentsRect;
|
|
||||||
if( ring->layoutMirroring() )
|
|
||||||
rect.setLeft( rect.right() - size.width() );
|
|
||||||
else
|
|
||||||
rect.setWidth( size.width() );
|
|
||||||
|
|
||||||
rect.setTop( rect.top() + 0.5 * ( rect.height() - size.height() ) );
|
|
||||||
rect.setHeight( size.height() );
|
|
||||||
|
|
||||||
return rect;
|
|
||||||
}
|
|
||||||
|
|
||||||
return Inherited::subControlRect( skinnable, contentsRect, subControl );
|
return Inherited::subControlRect( skinnable, contentsRect, subControl );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue