qskinny/examples/gallery/progressbar/ProgressBarPage.cpp

114 lines
2.8 KiB
C++
Raw Normal View History

2020-08-11 17:56:53 +02:00
/******************************************************************************
* QSkinny - Copyright (C) 2016 Uwe Rathmann
* This file may be used under the terms of the 3-clause BSD License
*****************************************************************************/
#include "ProgressBarPage.h"
#include <QskProgressBar.h>
#include <QskGraphicProvider.h>
#include <QskGraphic.h>
#include <QskGradient.h>
2022-06-25 16:14:08 +02:00
#include <QskHctColor.h>
2020-08-11 17:56:53 +02:00
#include <QskRgbValue.h>
namespace
{
class ProgressBar : public QskProgressBar
2020-12-05 15:09:31 +01:00
{
public:
ProgressBar( QskLinearBox* box )
: QskProgressBar( box )
{
setOrientation( ( box->orientation() == Qt::Horizontal )
? Qt::Vertical : Qt::Horizontal );
setBoundaries( 0, 100 );
}
2022-06-25 16:14:08 +02:00
void setTheme( const QRgb base )
2020-12-05 15:09:31 +01:00
{
const QskHctColor hctColor( base );
2020-12-05 15:09:31 +01:00
2022-10-24 16:40:47 +02:00
QVector< QRgb > colors;
colors += hctColor.toned( 75 ).rgb();
colors += hctColor.toned( 60 ).rgb();
colors += hctColor.toned( 45 ).rgb();
colors += hctColor.toned( 30 ).rgb();
2020-12-05 15:09:31 +01:00
2022-10-31 14:42:08 +01:00
setBarGradient( qskBuildGradientStops( colors, true ) );
2020-12-05 15:09:31 +01:00
}
2020-08-11 17:56:53 +02:00
};
}
ProgressBarPage::ProgressBarPage( QQuickItem* parent )
: Page( Qt::Horizontal, parent )
{
setSpacing( 40 );
populate();
}
void ProgressBarPage::populate()
{
auto hBox = new QskLinearBox( Qt::Horizontal, this );
hBox->setSizePolicy( Qt::Horizontal, QskSizePolicy::Fixed );
hBox->setSpacing( 20 );
{
auto bar = new ProgressBar( hBox );
bar->setValue( 35 );
}
{
auto bar = new ProgressBar( hBox );
2022-06-25 16:14:08 +02:00
bar->setTheme( QskRgb::LightSteelBlue );
2020-08-11 17:56:53 +02:00
bar->setValue( 100 );
}
{
auto bar = new ProgressBar( hBox );
2022-06-25 16:14:08 +02:00
bar->setTheme( QskRgb::DodgerBlue );
2020-08-11 17:56:53 +02:00
bar->setValue( 75 );
}
{
auto bar = new ProgressBar( hBox );
2022-06-25 16:14:08 +02:00
bar->setTheme( QskRgb::DodgerBlue );
2020-08-11 17:56:53 +02:00
bar->setOrigin( 60 );
bar->setValue( 25 );
}
{
auto bar = new ProgressBar( hBox );
bar->setIndeterminate( true );
}
auto vBox = new QskLinearBox( Qt::Vertical, this );
vBox->setSpacing( 20 );
vBox->setExtraSpacingAt( Qt::BottomEdge );
{
auto bar = new ProgressBar( vBox );
2022-06-25 16:14:08 +02:00
bar->setTheme( QskRgb::OrangeRed );
2020-08-11 17:56:53 +02:00
bar->setValue( 100 );
}
{
auto bar = new ProgressBar( vBox );
2022-06-25 16:14:08 +02:00
bar->setTheme( QskRgb::DeepPink );
2020-08-11 17:56:53 +02:00
bar->setMaximum( 40 );
bar->setValue( 25 );
}
{
auto bar = new ProgressBar( vBox );
2022-06-25 16:14:08 +02:00
bar->setTheme( QskRgb::DeepPink );
2020-08-11 17:56:53 +02:00
bar->setOrigin( 40 );
bar->setValue( 10 );
}
{
auto bar = new ProgressBar( vBox );
bar->setIndeterminate( true );
}
}