ProgressBar moved.
This commit is contained in:
parent
1788acd81c
commit
ff93c8e77a
|
@ -5,26 +5,28 @@
|
||||||
#include <QPainterPath>
|
#include <QPainterPath>
|
||||||
#include "qtmaterialprogress_internal.h"
|
#include "qtmaterialprogress_internal.h"
|
||||||
#include "lib/qtmaterialstyle.h"
|
#include "lib/qtmaterialstyle.h"
|
||||||
|
namespace md
|
||||||
|
{
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \class QtMaterialProgressPrivate
|
* \class ProgressBarPrivate
|
||||||
* \internal
|
* \internal
|
||||||
*/
|
*/
|
||||||
|
|
||||||
QtMaterialProgressPrivate::QtMaterialProgressPrivate(QtMaterialProgress *q)
|
ProgressBarPrivate::ProgressBarPrivate(ProgressBar *q)
|
||||||
: q_ptr(q)
|
: q_ptr(q)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QtMaterialProgressPrivate::~QtMaterialProgressPrivate()
|
ProgressBarPrivate::~ProgressBarPrivate()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtMaterialProgressPrivate::init()
|
void ProgressBarPrivate::init()
|
||||||
{
|
{
|
||||||
Q_Q(QtMaterialProgress);
|
Q_Q(ProgressBar);
|
||||||
|
|
||||||
delegate = new QtMaterialProgressDelegate(q);
|
delegate = new ProgressBarDelegate(q);
|
||||||
progressType = Material::IndeterminateProgress;
|
progressType = Material::IndeterminateProgress;
|
||||||
useThemeColors = true;
|
useThemeColors = true;
|
||||||
|
|
||||||
|
@ -46,35 +48,35 @@ void QtMaterialProgressPrivate::init()
|
||||||
* \class QtMaterialProgress
|
* \class QtMaterialProgress
|
||||||
*/
|
*/
|
||||||
|
|
||||||
QtMaterialProgress::QtMaterialProgress(QWidget *parent)
|
ProgressBar::ProgressBar(QWidget *parent)
|
||||||
: QProgressBar(parent),
|
: QProgressBar(parent),
|
||||||
d_ptr(new QtMaterialProgressPrivate(this))
|
d_ptr(new ProgressBarPrivate(this))
|
||||||
{
|
{
|
||||||
d_func()->init();
|
d_func()->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
QtMaterialProgress::~QtMaterialProgress()
|
ProgressBar::~ProgressBar()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtMaterialProgress::setProgressType(Material::ProgressType type)
|
void ProgressBar::setProgressType(Material::ProgressType type)
|
||||||
{
|
{
|
||||||
Q_D(QtMaterialProgress);
|
Q_D(ProgressBar);
|
||||||
|
|
||||||
d->progressType = type;
|
d->progressType = type;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
Material::ProgressType QtMaterialProgress::progressType() const
|
Material::ProgressType ProgressBar::progressType() const
|
||||||
{
|
{
|
||||||
Q_D(const QtMaterialProgress);
|
Q_D(const ProgressBar);
|
||||||
|
|
||||||
return d->progressType;
|
return d->progressType;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtMaterialProgress::setUseThemeColors(bool state)
|
void ProgressBar::setUseThemeColors(bool state)
|
||||||
{
|
{
|
||||||
Q_D(QtMaterialProgress);
|
Q_D(ProgressBar);
|
||||||
|
|
||||||
if (d->useThemeColors == state) {
|
if (d->useThemeColors == state) {
|
||||||
return;
|
return;
|
||||||
|
@ -84,16 +86,16 @@ void QtMaterialProgress::setUseThemeColors(bool state)
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QtMaterialProgress::useThemeColors() const
|
bool ProgressBar::useThemeColors() const
|
||||||
{
|
{
|
||||||
Q_D(const QtMaterialProgress);
|
Q_D(const ProgressBar);
|
||||||
|
|
||||||
return d->useThemeColors;
|
return d->useThemeColors;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtMaterialProgress::setProgressColor(const QColor &color)
|
void ProgressBar::setProgressColor(const QColor &color)
|
||||||
{
|
{
|
||||||
Q_D(QtMaterialProgress);
|
Q_D(ProgressBar);
|
||||||
|
|
||||||
d->progressColor = color;
|
d->progressColor = color;
|
||||||
|
|
||||||
|
@ -101,20 +103,20 @@ void QtMaterialProgress::setProgressColor(const QColor &color)
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor QtMaterialProgress::progressColor() const
|
QColor ProgressBar::progressColor() const
|
||||||
{
|
{
|
||||||
Q_D(const QtMaterialProgress);
|
Q_D(const ProgressBar);
|
||||||
|
|
||||||
if (d->useThemeColors || !d->progressColor.isValid()) {
|
if (d->useThemeColors || !d->progressColor.isValid()) {
|
||||||
return QtMaterialStyle::instance().themeColor("primary1");
|
return Style::instance().themeColor("primary1");
|
||||||
} else {
|
} else {
|
||||||
return d->progressColor;
|
return d->progressColor;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtMaterialProgress::setBackgroundColor(const QColor &color)
|
void ProgressBar::setBackgroundColor(const QColor &color)
|
||||||
{
|
{
|
||||||
Q_D(QtMaterialProgress);
|
Q_D(ProgressBar);
|
||||||
|
|
||||||
d->backgroundColor = color;
|
d->backgroundColor = color;
|
||||||
|
|
||||||
|
@ -122,12 +124,12 @@ void QtMaterialProgress::setBackgroundColor(const QColor &color)
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor QtMaterialProgress::backgroundColor() const
|
QColor ProgressBar::backgroundColor() const
|
||||||
{
|
{
|
||||||
Q_D(const QtMaterialProgress);
|
Q_D(const ProgressBar);
|
||||||
|
|
||||||
if (d->useThemeColors || !d->backgroundColor.isValid()) {
|
if (d->useThemeColors || !d->backgroundColor.isValid()) {
|
||||||
return QtMaterialStyle::instance().themeColor("border");
|
return Style::instance().themeColor("border");
|
||||||
} else {
|
} else {
|
||||||
return d->backgroundColor;
|
return d->backgroundColor;
|
||||||
}
|
}
|
||||||
|
@ -136,11 +138,11 @@ QColor QtMaterialProgress::backgroundColor() const
|
||||||
/*!
|
/*!
|
||||||
* \reimp
|
* \reimp
|
||||||
*/
|
*/
|
||||||
void QtMaterialProgress::paintEvent(QPaintEvent *event)
|
void ProgressBar::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event)
|
Q_UNUSED(event)
|
||||||
|
|
||||||
Q_D(QtMaterialProgress);
|
Q_D(ProgressBar);
|
||||||
|
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
painter.setRenderHint(QPainter::Antialiasing);
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
|
@ -148,7 +150,7 @@ void QtMaterialProgress::paintEvent(QPaintEvent *event)
|
||||||
QBrush brush;
|
QBrush brush;
|
||||||
brush.setStyle(Qt::SolidPattern);
|
brush.setStyle(Qt::SolidPattern);
|
||||||
brush.setColor(isEnabled() ? backgroundColor()
|
brush.setColor(isEnabled() ? backgroundColor()
|
||||||
: QtMaterialStyle::instance().themeColor("disabled"));
|
: Style::instance().themeColor("disabled"));
|
||||||
painter.setBrush(brush);
|
painter.setBrush(brush);
|
||||||
painter.setPen(Qt::NoPen);
|
painter.setPen(Qt::NoPen);
|
||||||
|
|
||||||
|
@ -171,3 +173,4 @@ void QtMaterialProgress::paintEvent(QPaintEvent *event)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
* \internal
|
* \internal
|
||||||
*/
|
*/
|
||||||
|
|
||||||
QtMaterialProgressDelegate::QtMaterialProgressDelegate(QtMaterialProgress *parent)
|
ProgressBarDelegate::ProgressBarDelegate(ProgressBar *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
m_progress(parent),
|
m_progress(parent),
|
||||||
m_offset(0)
|
m_offset(0)
|
||||||
|
@ -13,6 +13,6 @@ QtMaterialProgressDelegate::QtMaterialProgressDelegate(QtMaterialProgress *paren
|
||||||
Q_ASSERT(parent);
|
Q_ASSERT(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
QtMaterialProgressDelegate::~QtMaterialProgressDelegate()
|
ProgressBarDelegate::~ProgressBarDelegate()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,36 +3,38 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include "qtmaterialprogress.h"
|
#include "qtmaterialprogress.h"
|
||||||
|
namespace md
|
||||||
|
{
|
||||||
|
|
||||||
class QtMaterialProgressDelegate : public QObject
|
class ProgressBarDelegate : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
Q_PROPERTY(qreal offset WRITE setOffset READ offset)
|
Q_PROPERTY(qreal offset WRITE setOffset READ offset)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QtMaterialProgressDelegate(QtMaterialProgress *parent);
|
ProgressBarDelegate(ProgressBar *parent);
|
||||||
~QtMaterialProgressDelegate();
|
~ProgressBarDelegate();
|
||||||
|
|
||||||
inline void setOffset(qreal offset);
|
inline void setOffset(qreal offset);
|
||||||
inline qreal offset() const;
|
inline qreal offset() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(QtMaterialProgressDelegate)
|
Q_DISABLE_COPY(ProgressBarDelegate)
|
||||||
|
|
||||||
QtMaterialProgress *const m_progress;
|
ProgressBar *const m_progress;
|
||||||
qreal m_offset;
|
qreal m_offset;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void QtMaterialProgressDelegate::setOffset(qreal offset)
|
inline void ProgressBarDelegate::setOffset(qreal offset)
|
||||||
{
|
{
|
||||||
m_offset = offset;
|
m_offset = offset;
|
||||||
m_progress->update();
|
m_progress->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline qreal QtMaterialProgressDelegate::offset() const
|
inline qreal ProgressBarDelegate::offset() const
|
||||||
{
|
{
|
||||||
return m_offset;
|
return m_offset;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
#endif // QTMATERIALPROGRESS_INTERNAL_H
|
#endif // QTMATERIALPROGRESS_INTERNAL_H
|
||||||
|
|
|
@ -4,27 +4,29 @@
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include <QColor>
|
#include <QColor>
|
||||||
#include "lib/qtmaterialtheme.h"
|
#include "lib/qtmaterialtheme.h"
|
||||||
|
namespace md
|
||||||
class QtMaterialProgress;
|
|
||||||
class QtMaterialProgressDelegate;
|
|
||||||
|
|
||||||
class QtMaterialProgressPrivate
|
|
||||||
{
|
{
|
||||||
Q_DISABLE_COPY(QtMaterialProgressPrivate)
|
|
||||||
Q_DECLARE_PUBLIC(QtMaterialProgress)
|
class ProgressBar;
|
||||||
|
class ProgressBarDelegate;
|
||||||
|
|
||||||
|
class ProgressBarPrivate
|
||||||
|
{
|
||||||
|
Q_DISABLE_COPY(ProgressBarPrivate)
|
||||||
|
Q_DECLARE_PUBLIC(ProgressBar)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QtMaterialProgressPrivate(QtMaterialProgress *q);
|
ProgressBarPrivate(ProgressBar *q);
|
||||||
~QtMaterialProgressPrivate();
|
~ProgressBarPrivate();
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
QtMaterialProgress *const q_ptr;
|
ProgressBar *const q_ptr;
|
||||||
QtMaterialProgressDelegate *delegate;
|
ProgressBarDelegate *delegate;
|
||||||
Material::ProgressType progressType;
|
Material::ProgressType progressType;
|
||||||
QColor progressColor;
|
QColor progressColor;
|
||||||
QColor backgroundColor;
|
QColor backgroundColor;
|
||||||
bool useThemeColors;
|
bool useThemeColors;
|
||||||
};
|
};
|
||||||
|
}
|
||||||
#endif // QTMATERIALPROGRESS_P_H
|
#endif // QTMATERIALPROGRESS_P_H
|
||||||
|
|
Loading…
Reference in New Issue