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