Move CirclarProgress => md namespace.
This commit is contained in:
parent
cce6e6f1cf
commit
410bb72a2d
|
@ -7,25 +7,28 @@
|
||||||
#include "qtmaterialcircularprogress_internal.h"
|
#include "qtmaterialcircularprogress_internal.h"
|
||||||
#include "lib/qtmaterialstyle.h"
|
#include "lib/qtmaterialstyle.h"
|
||||||
|
|
||||||
|
namespace md
|
||||||
|
{
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \class QtMaterialCircularProgressPrivate
|
* \class QtMaterialCircularProgressPrivate
|
||||||
* \internal
|
* \internal
|
||||||
*/
|
*/
|
||||||
|
|
||||||
QtMaterialCircularProgressPrivate::QtMaterialCircularProgressPrivate(QtMaterialCircularProgress *q)
|
CircularProgressPrivate::CircularProgressPrivate(CircularProgress *q)
|
||||||
: q_ptr(q)
|
: q_ptr(q)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
QtMaterialCircularProgressPrivate::~QtMaterialCircularProgressPrivate()
|
CircularProgressPrivate::~CircularProgressPrivate()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtMaterialCircularProgressPrivate::init()
|
void CircularProgressPrivate::init()
|
||||||
{
|
{
|
||||||
Q_Q(QtMaterialCircularProgress);
|
Q_Q(CircularProgress);
|
||||||
|
|
||||||
delegate = new QtMaterialCircularProgressDelegate(q);
|
delegate = new CircularProgressDelegate(q);
|
||||||
progressType = Material::IndeterminateProgress;
|
progressType = Material::IndeterminateProgress;
|
||||||
penWidth = 6.25;
|
penWidth = 6.25;
|
||||||
size = 64;
|
size = 64;
|
||||||
|
@ -81,35 +84,35 @@ void QtMaterialCircularProgressPrivate::init()
|
||||||
* \class QtMaterialCircularProgress
|
* \class QtMaterialCircularProgress
|
||||||
*/
|
*/
|
||||||
|
|
||||||
QtMaterialCircularProgress::QtMaterialCircularProgress(QWidget *parent)
|
CircularProgress::CircularProgress(QWidget *parent)
|
||||||
: QProgressBar(parent),
|
: QProgressBar(parent),
|
||||||
d_ptr(new QtMaterialCircularProgressPrivate(this))
|
d_ptr(new CircularProgressPrivate(this))
|
||||||
{
|
{
|
||||||
d_func()->init();
|
d_func()->init();
|
||||||
}
|
}
|
||||||
|
|
||||||
QtMaterialCircularProgress::~QtMaterialCircularProgress()
|
CircularProgress::~CircularProgress()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtMaterialCircularProgress::setProgressType(Material::ProgressType type)
|
void CircularProgress::setProgressType(Material::ProgressType type)
|
||||||
{
|
{
|
||||||
Q_D(QtMaterialCircularProgress);
|
Q_D(CircularProgress);
|
||||||
|
|
||||||
d->progressType = type;
|
d->progressType = type;
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
Material::ProgressType QtMaterialCircularProgress::progressType() const
|
Material::ProgressType CircularProgress::progressType() const
|
||||||
{
|
{
|
||||||
Q_D(const QtMaterialCircularProgress);
|
Q_D(const CircularProgress);
|
||||||
|
|
||||||
return d->progressType;
|
return d->progressType;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtMaterialCircularProgress::setUseThemeColors(bool value)
|
void CircularProgress::setUseThemeColors(bool value)
|
||||||
{
|
{
|
||||||
Q_D(QtMaterialCircularProgress);
|
Q_D(CircularProgress);
|
||||||
|
|
||||||
if (d->useThemeColors == value) {
|
if (d->useThemeColors == value) {
|
||||||
return;
|
return;
|
||||||
|
@ -119,48 +122,48 @@ void QtMaterialCircularProgress::setUseThemeColors(bool value)
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool QtMaterialCircularProgress::useThemeColors() const
|
bool CircularProgress::useThemeColors() const
|
||||||
{
|
{
|
||||||
Q_D(const QtMaterialCircularProgress);
|
Q_D(const CircularProgress);
|
||||||
|
|
||||||
return d->useThemeColors;
|
return d->useThemeColors;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtMaterialCircularProgress::setLineWidth(qreal width)
|
void CircularProgress::setLineWidth(qreal width)
|
||||||
{
|
{
|
||||||
Q_D(QtMaterialCircularProgress);
|
Q_D(CircularProgress);
|
||||||
|
|
||||||
d->penWidth = width;
|
d->penWidth = width;
|
||||||
update();
|
update();
|
||||||
updateGeometry();
|
updateGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
qreal QtMaterialCircularProgress::lineWidth() const
|
qreal CircularProgress::lineWidth() const
|
||||||
{
|
{
|
||||||
Q_D(const QtMaterialCircularProgress);
|
Q_D(const CircularProgress);
|
||||||
|
|
||||||
return d->penWidth;
|
return d->penWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtMaterialCircularProgress::setSize(int size)
|
void CircularProgress::setSize(int size)
|
||||||
{
|
{
|
||||||
Q_D(QtMaterialCircularProgress);
|
Q_D(CircularProgress);
|
||||||
|
|
||||||
d->size = size;
|
d->size = size;
|
||||||
update();
|
update();
|
||||||
updateGeometry();
|
updateGeometry();
|
||||||
}
|
}
|
||||||
|
|
||||||
int QtMaterialCircularProgress::size() const
|
int CircularProgress::size() const
|
||||||
{
|
{
|
||||||
Q_D(const QtMaterialCircularProgress);
|
Q_D(const CircularProgress);
|
||||||
|
|
||||||
return d->size;
|
return d->size;
|
||||||
}
|
}
|
||||||
|
|
||||||
void QtMaterialCircularProgress::setColor(const QColor &color)
|
void CircularProgress::setColor(const QColor &color)
|
||||||
{
|
{
|
||||||
Q_D(QtMaterialCircularProgress);
|
Q_D(CircularProgress);
|
||||||
|
|
||||||
d->color = color;
|
d->color = color;
|
||||||
|
|
||||||
|
@ -168,9 +171,9 @@ void QtMaterialCircularProgress::setColor(const QColor &color)
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
|
|
||||||
QColor QtMaterialCircularProgress::color() const
|
QColor CircularProgress::color() const
|
||||||
{
|
{
|
||||||
Q_D(const QtMaterialCircularProgress);
|
Q_D(const CircularProgress);
|
||||||
|
|
||||||
if (d->useThemeColors || !d->color.isValid()) {
|
if (d->useThemeColors || !d->color.isValid()) {
|
||||||
return QtMaterialStyle::instance().themeColor("primary1");
|
return QtMaterialStyle::instance().themeColor("primary1");
|
||||||
|
@ -182,9 +185,9 @@ QColor QtMaterialCircularProgress::color() const
|
||||||
/*!
|
/*!
|
||||||
* \reimp
|
* \reimp
|
||||||
*/
|
*/
|
||||||
QSize QtMaterialCircularProgress::sizeHint() const
|
QSize CircularProgress::sizeHint() const
|
||||||
{
|
{
|
||||||
Q_D(const QtMaterialCircularProgress);
|
Q_D(const CircularProgress);
|
||||||
|
|
||||||
const qreal s = d->size+d->penWidth+8;
|
const qreal s = d->size+d->penWidth+8;
|
||||||
return QSize(s, s);
|
return QSize(s, s);
|
||||||
|
@ -193,11 +196,11 @@ QSize QtMaterialCircularProgress::sizeHint() const
|
||||||
/*!
|
/*!
|
||||||
* \reimp
|
* \reimp
|
||||||
*/
|
*/
|
||||||
void QtMaterialCircularProgress::paintEvent(QPaintEvent *event)
|
void CircularProgress::paintEvent(QPaintEvent *event)
|
||||||
{
|
{
|
||||||
Q_UNUSED(event)
|
Q_UNUSED(event)
|
||||||
|
|
||||||
Q_D(QtMaterialCircularProgress);
|
Q_D(CircularProgress);
|
||||||
|
|
||||||
QPainter painter(this);
|
QPainter painter(this);
|
||||||
painter.setRenderHint(QPainter::Antialiasing);
|
painter.setRenderHint(QPainter::Antialiasing);
|
||||||
|
@ -253,3 +256,5 @@ void QtMaterialCircularProgress::paintEvent(QPaintEvent *event)
|
||||||
painter.drawPath(path);
|
painter.drawPath(path);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -4,9 +4,12 @@
|
||||||
#include <QtWidgets/QProgressBar>
|
#include <QtWidgets/QProgressBar>
|
||||||
#include "lib/qtmaterialtheme.h"
|
#include "lib/qtmaterialtheme.h"
|
||||||
|
|
||||||
class QtMaterialCircularProgressPrivate;
|
namespace md
|
||||||
|
{
|
||||||
|
|
||||||
class QtMaterialCircularProgress : public QProgressBar
|
class CircularProgressPrivate;
|
||||||
|
|
||||||
|
class CircularProgress : public QProgressBar
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -15,8 +18,8 @@ class QtMaterialCircularProgress : public QProgressBar
|
||||||
Q_PROPERTY(QColor color WRITE setColor READ color)
|
Q_PROPERTY(QColor color WRITE setColor READ color)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit QtMaterialCircularProgress(QWidget *parent = 0);
|
explicit CircularProgress(QWidget *parent = 0);
|
||||||
~QtMaterialCircularProgress();
|
~CircularProgress();
|
||||||
|
|
||||||
void setProgressType(Material::ProgressType type);
|
void setProgressType(Material::ProgressType type);
|
||||||
Material::ProgressType progressType() const;
|
Material::ProgressType progressType() const;
|
||||||
|
@ -38,11 +41,13 @@ public:
|
||||||
protected:
|
protected:
|
||||||
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
|
void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE;
|
||||||
|
|
||||||
const QScopedPointer<QtMaterialCircularProgressPrivate> d_ptr;
|
const QScopedPointer<CircularProgressPrivate> d_ptr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(QtMaterialCircularProgress)
|
Q_DISABLE_COPY(CircularProgress)
|
||||||
Q_DECLARE_PRIVATE(QtMaterialCircularProgress)
|
Q_DECLARE_PRIVATE(CircularProgress)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif // QTMATERIALCIRCULARPROGRESS_H
|
#endif // QTMATERIALCIRCULARPROGRESS_H
|
||||||
|
|
|
@ -1,11 +1,14 @@
|
||||||
#include "qtmaterialcircularprogress_internal.h"
|
#include "qtmaterialcircularprogress_internal.h"
|
||||||
|
|
||||||
|
namespace md
|
||||||
|
{
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* \class QtMaterialCircularProgressDelegate
|
* \class QtMaterialCircularProgressDelegate
|
||||||
* \internal
|
* \internal
|
||||||
*/
|
*/
|
||||||
|
|
||||||
QtMaterialCircularProgressDelegate::QtMaterialCircularProgressDelegate(QtMaterialCircularProgress *parent)
|
CircularProgressDelegate::CircularProgressDelegate(CircularProgress *parent)
|
||||||
: QObject(parent),
|
: QObject(parent),
|
||||||
m_progress(parent),
|
m_progress(parent),
|
||||||
m_dashOffset(0),
|
m_dashOffset(0),
|
||||||
|
@ -15,6 +18,8 @@ QtMaterialCircularProgressDelegate::QtMaterialCircularProgressDelegate(QtMateria
|
||||||
Q_ASSERT(parent);
|
Q_ASSERT(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
QtMaterialCircularProgressDelegate::~QtMaterialCircularProgressDelegate()
|
CircularProgressDelegate::~CircularProgressDelegate()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
|
@ -3,8 +3,10 @@
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include "qtmaterialcircularprogress.h"
|
#include "qtmaterialcircularprogress.h"
|
||||||
|
namespace md
|
||||||
|
{
|
||||||
|
|
||||||
class QtMaterialCircularProgressDelegate : public QObject
|
class CircularProgressDelegate : public QObject
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
@ -13,8 +15,8 @@ class QtMaterialCircularProgressDelegate : public QObject
|
||||||
Q_PROPERTY(int angle WRITE setAngle READ angle)
|
Q_PROPERTY(int angle WRITE setAngle READ angle)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QtMaterialCircularProgressDelegate(QtMaterialCircularProgress *parent);
|
CircularProgressDelegate(CircularProgress *parent);
|
||||||
~QtMaterialCircularProgressDelegate();
|
~CircularProgressDelegate();
|
||||||
|
|
||||||
inline void setDashOffset(qreal offset);
|
inline void setDashOffset(qreal offset);
|
||||||
inline qreal dashOffset() const;
|
inline qreal dashOffset() const;
|
||||||
|
@ -26,45 +28,47 @@ public:
|
||||||
inline int angle() const;
|
inline int angle() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(QtMaterialCircularProgressDelegate)
|
Q_DISABLE_COPY(CircularProgressDelegate)
|
||||||
|
|
||||||
QtMaterialCircularProgress *const m_progress;
|
CircularProgress *const m_progress;
|
||||||
qreal m_dashOffset;
|
qreal m_dashOffset;
|
||||||
qreal m_dashLength;
|
qreal m_dashLength;
|
||||||
int m_angle;
|
int m_angle;
|
||||||
};
|
};
|
||||||
|
|
||||||
inline void QtMaterialCircularProgressDelegate::setDashOffset(qreal offset)
|
inline void CircularProgressDelegate::setDashOffset(qreal offset)
|
||||||
{
|
{
|
||||||
m_dashOffset = offset;
|
m_dashOffset = offset;
|
||||||
m_progress->update();
|
m_progress->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline qreal QtMaterialCircularProgressDelegate::dashOffset() const
|
inline qreal CircularProgressDelegate::dashOffset() const
|
||||||
{
|
{
|
||||||
return m_dashOffset;
|
return m_dashOffset;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void QtMaterialCircularProgressDelegate::setDashLength(qreal length)
|
inline void CircularProgressDelegate::setDashLength(qreal length)
|
||||||
{
|
{
|
||||||
m_dashLength = length;
|
m_dashLength = length;
|
||||||
m_progress->update();
|
m_progress->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline qreal QtMaterialCircularProgressDelegate::dashLength() const
|
inline qreal CircularProgressDelegate::dashLength() const
|
||||||
{
|
{
|
||||||
return m_dashLength;
|
return m_dashLength;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline void QtMaterialCircularProgressDelegate::setAngle(int angle)
|
inline void CircularProgressDelegate::setAngle(int angle)
|
||||||
{
|
{
|
||||||
m_angle = angle;
|
m_angle = angle;
|
||||||
m_progress->update();
|
m_progress->update();
|
||||||
}
|
}
|
||||||
|
|
||||||
inline int QtMaterialCircularProgressDelegate::angle() const
|
inline int CircularProgressDelegate::angle() const
|
||||||
{
|
{
|
||||||
return m_angle;
|
return m_angle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif // QTMATERIALCIRCULARPROGRESS_INTERNAL_H
|
#endif // QTMATERIALCIRCULARPROGRESS_INTERNAL_H
|
||||||
|
|
|
@ -3,23 +3,25 @@
|
||||||
|
|
||||||
#include <QtGlobal>
|
#include <QtGlobal>
|
||||||
#include "lib/qtmaterialtheme.h"
|
#include "lib/qtmaterialtheme.h"
|
||||||
|
namespace md
|
||||||
class QtMaterialCircularProgress;
|
|
||||||
class QtMaterialCircularProgressDelegate;
|
|
||||||
|
|
||||||
class QtMaterialCircularProgressPrivate
|
|
||||||
{
|
{
|
||||||
Q_DISABLE_COPY(QtMaterialCircularProgressPrivate)
|
|
||||||
Q_DECLARE_PUBLIC(QtMaterialCircularProgress)
|
class CircularProgress;
|
||||||
|
class CircularProgressDelegate;
|
||||||
|
|
||||||
|
class CircularProgressPrivate
|
||||||
|
{
|
||||||
|
Q_DISABLE_COPY(CircularProgressPrivate)
|
||||||
|
Q_DECLARE_PUBLIC(CircularProgress)
|
||||||
|
|
||||||
public:
|
public:
|
||||||
QtMaterialCircularProgressPrivate(QtMaterialCircularProgress *q);
|
CircularProgressPrivate(CircularProgress *q);
|
||||||
~QtMaterialCircularProgressPrivate();
|
~CircularProgressPrivate();
|
||||||
|
|
||||||
void init();
|
void init();
|
||||||
|
|
||||||
QtMaterialCircularProgress *const q_ptr;
|
CircularProgress *const q_ptr;
|
||||||
QtMaterialCircularProgressDelegate *delegate;
|
CircularProgressDelegate *delegate;
|
||||||
Material::ProgressType progressType;
|
Material::ProgressType progressType;
|
||||||
QColor color;
|
QColor color;
|
||||||
qreal penWidth;
|
qreal penWidth;
|
||||||
|
@ -27,4 +29,6 @@ public:
|
||||||
bool useThemeColors;
|
bool useThemeColors;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
#endif // QTMATERIALCIRCULARPROGRESS_P_H
|
#endif // QTMATERIALCIRCULARPROGRESS_P_H
|
||||||
|
|
Loading…
Reference in New Issue