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 );
|
||||
ring->setSize( size );
|
||||
ring->setLayoutAlignmentHint( Qt::AlignCenter );
|
||||
|
||||
QQuickItem* parentItem;
|
||||
|
||||
|
@ -6,8 +6,6 @@
|
||||
set(SOURCES
|
||||
Box.h Box.cpp
|
||||
BoxWithButtons.h BoxWithButtons.cpp
|
||||
CircularProgressBar.h CircularProgressBar.cpp
|
||||
CircularProgressBarSkinlet.h CircularProgressBarSkinlet.cpp
|
||||
Diagram.h Diagram.cpp
|
||||
DiagramSkinlet.h DiagramSkinlet.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 "CircularProgressBar.h"
|
||||
|
||||
#include <QskProgressRing.h>
|
||||
#include <QskTextLabel.h>
|
||||
#include <QskFontRole.h>
|
||||
|
||||
@ -35,8 +35,10 @@ EnergyMeter::EnergyMeter( const QColor& textColor,
|
||||
{
|
||||
setAutoLayoutChildren( true );
|
||||
|
||||
auto valueBar = new CircularProgressBar( this );
|
||||
valueBar->setGradientHint( CircularProgressBar::Fill, gradient );
|
||||
auto valueBar = new QskProgressRing( this );
|
||||
valueBar->setSizePolicy(
|
||||
QskSizePolicy::MinimumExpanding, QskSizePolicy::Constrained );
|
||||
valueBar->setFillGradient( gradient );
|
||||
valueBar->setValue( value );
|
||||
|
||||
auto valueLabel = new ValueLabel( this );
|
||||
|
@ -7,8 +7,6 @@
|
||||
|
||||
#include "Box.h"
|
||||
#include "BoxWithButtons.h"
|
||||
#include "CircularProgressBar.h"
|
||||
#include "CircularProgressBarSkinlet.h"
|
||||
#include "DashboardPage.h"
|
||||
#include "Diagram.h"
|
||||
#include "DiagramSkinlet.h"
|
||||
@ -56,7 +54,6 @@ Skin::Skin( QObject* parent )
|
||||
{
|
||||
setObjectName( "iot" );
|
||||
|
||||
declareSkinlet< CircularProgressBar, CircularProgressBarSkinlet >();
|
||||
declareSkinlet< Diagram, DiagramSkinlet >();
|
||||
declareSkinlet< LightDisplay, LightDisplaySkinlet >();
|
||||
declareSkinlet< StorageBar, StorageBarSkinlet >();
|
||||
@ -127,10 +124,10 @@ void Skin::initHints()
|
||||
ed.setGradient( TopBarItem::Item4, 0xff6776ff, 0xff6100ff );
|
||||
|
||||
// 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
|
||||
// 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 } );
|
||||
|
||||
@ -282,8 +279,8 @@ void Skin::initHints()
|
||||
ed.setColor( QskTextLabel::Text, palette.text );
|
||||
ed.setColor( UsageDiagramBox::DayText, palette.text );
|
||||
|
||||
ed.setMetric( CircularProgressBar::Groove | QskAspect::Border, 2 );
|
||||
ed.setColor( CircularProgressBar::Groove | QskAspect::Border,
|
||||
ed.setMetric( QskProgressRing::Groove | QskAspect::Border, 2 );
|
||||
ed.setColor( QskProgressRing::Groove | QskAspect::Border,
|
||||
palette.circularProgressBarGroove );
|
||||
|
||||
// storage bar
|
||||
|
@ -4,44 +4,47 @@
|
||||
*****************************************************************************/
|
||||
|
||||
#include "StorageMeter.h"
|
||||
#include "CircularProgressBar.h"
|
||||
|
||||
#include <QskFontRole.h>
|
||||
#include <QskTextLabel.h>
|
||||
|
||||
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
|
||||
: CircularProgressBar( parent )
|
||||
, label( new QskTextLabel( this ) )
|
||||
: QskProgressRing( parent )
|
||||
{
|
||||
setAutoLayoutChildren( true );
|
||||
setSizePolicy( QskSizePolicy::Preferred, QskSizePolicy::Constrained );
|
||||
initSizePolicy( QskSizePolicy::MinimumExpanding, QskSizePolicy::Constrained );
|
||||
|
||||
label->setText( make_text( locale(), value() ) );
|
||||
label->setSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed );
|
||||
label->setLayoutAlignmentHint( Qt::AlignCenter );
|
||||
label->setFontRole( QskFontRole::Caption );
|
||||
m_label = new QskTextLabel( this );
|
||||
m_label->setSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed );
|
||||
m_label->setLayoutAlignmentHint( Qt::AlignCenter );
|
||||
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 = gradient.extracted( value / 100.0, value / 100.0 ).startColor();
|
||||
setGradientHint( StorageMeter::Fill, { color, color.lighter() } );
|
||||
CircularProgressBar::setValue( value );
|
||||
label->setTextColor( color );
|
||||
label->setText( make_text( locale(), value ) );
|
||||
const auto color = qskInterpolatedColorAt(
|
||||
gradientHint( Status ).stops(), value / 100.0 );
|
||||
|
||||
setFillGradient( { color, color.lighter() } );
|
||||
|
||||
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 )
|
||||
return QSizeF();
|
||||
|
@ -5,18 +5,20 @@
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CircularProgressBar.h"
|
||||
#include <QskControl.h>
|
||||
#include <QskProgressRing.h>
|
||||
|
||||
class StorageMeter final : public CircularProgressBar
|
||||
class QskTextLabel;
|
||||
|
||||
class StorageMeter final : public QskProgressRing
|
||||
{
|
||||
public:
|
||||
QSK_SUBCONTROLS( Status )
|
||||
explicit StorageMeter( QQuickItem* parent = nullptr ) noexcept;
|
||||
public Q_SLOTS:
|
||||
void setValue( qreal value );
|
||||
|
||||
StorageMeter( QQuickItem* parent = nullptr ) noexcept;
|
||||
|
||||
private:
|
||||
QSizeF contentsSizeHint( Qt::SizeHint which, const QSizeF& constraint ) const override;
|
||||
class QskTextLabel* label = nullptr;
|
||||
void updateMeter( qreal value );
|
||||
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 )
|
||||
, m_data( new PrivateData )
|
||||
{
|
||||
initSizePolicy( QskSizePolicy::Fixed, QskSizePolicy::Fixed );
|
||||
|
||||
m_data->size = NormalSize;
|
||||
|
||||
setSubcontrolProxy( Inherited::Groove, Groove );
|
||||
|
@ -24,22 +24,7 @@ QRectF QskProgressRingSkinlet::subControlRect(
|
||||
QskAspect::Subcontrol subControl ) const
|
||||
{
|
||||
if( subControl == Q::Groove || subControl == Q::Fill )
|
||||
{
|
||||
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 contentsRect;
|
||||
|
||||
return Inherited::subControlRect( skinnable, contentsRect, subControl );
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user