diff --git a/components/progress.cpp b/components/progress.cpp index 647faf6..456bb13 100644 --- a/components/progress.cpp +++ b/components/progress.cpp @@ -16,7 +16,7 @@ void ProgressPrivate::init() } Progress::Progress(QWidget *parent) - : QWidget(parent), + : QProgressBar(parent), d_ptr(new ProgressPrivate(this)) { d_func()->init(); @@ -26,9 +26,49 @@ Progress::~Progress() { } +void Progress::setProgressType(Material::ProgressType type) +{ + Q_D(Progress); + + d->progressType = type; + update(); +} + +Material::ProgressType Progress::progressType() const +{ + Q_D(const Progress); + + return d->progressType; +} + void Progress::paintEvent(QPaintEvent *event) { - QPainter painter(this); + Q_UNUSED(event) - painter.drawRect(rect()); + QPainter painter(this); + painter.setRenderHint(QPainter::Antialiasing); + +// painter.drawRect(rect().adjusted(0, 0, -1, -1)); + + QBrush brush; + brush.setStyle(Qt::SolidPattern); + brush.setColor(Qt::black); + painter.setBrush(brush); + painter.setPen(Qt::NoPen); + + //QRectF r(0, 0, width(), 8); + //r.moveCenter(rect().center()); + + //painter.drawRect(r); + + QPainterPath path; + path.addRoundedRect(0, height()/2-4, width(), 8, 3, 3); + painter.setClipPath(path); + + painter.drawRect(0, 0, width(), height()); + + brush.setColor(Qt::blue); + painter.setBrush(brush); + + painter.drawRect(0, 0, width()/2, height()); } diff --git a/components/progress.h b/components/progress.h index 2915ea0..5466b74 100644 --- a/components/progress.h +++ b/components/progress.h @@ -1,11 +1,12 @@ #ifndef PROGRESS_H #define PROGRESS_H -#include +#include +#include "lib/theme.h" class ProgressPrivate; -class Progress : public QWidget +class Progress : public QProgressBar { Q_OBJECT @@ -13,6 +14,9 @@ public: explicit Progress(QWidget *parent = 0); ~Progress(); + void setProgressType(Material::ProgressType type); + Material::ProgressType progressType() const; + protected: void paintEvent(QPaintEvent *event) Q_DECL_OVERRIDE; diff --git a/components/progress_p.h b/components/progress_p.h index 3b570fa..59a8158 100644 --- a/components/progress_p.h +++ b/components/progress_p.h @@ -2,6 +2,7 @@ #define PROGRESS_P_H #include +#include "lib/theme.h" class Progress; @@ -17,6 +18,7 @@ public: void init(); Progress *const q_ptr; + Material::ProgressType progressType; }; #endif // PROGRESS_P_H diff --git a/qt-material-widgets.pro b/qt-material-widgets.pro index 9da44c7..4838734 100644 --- a/qt-material-widgets.pro +++ b/qt-material-widgets.pro @@ -66,7 +66,8 @@ SOURCES += main.cpp\ components/textfield_internal.cpp \ components/drawer.cpp \ components/snackbar_internal.cpp \ - components/circularprogress.cpp + components/circularprogress.cpp \ + components/circularprogress_internal.cpp HEADERS += mainwindow.h \ components/appbar.h \ @@ -143,7 +144,8 @@ HEADERS += mainwindow.h \ components/snackbar_internal.h \ components/progress_p.h \ components/circularprogress.h \ - components/circularprogress_p.h + components/circularprogress_p.h \ + components/circularprogress_internal.h RESOURCES += \ resources.qrc