diff options
Diffstat (limited to 'demos')
-rw-r--r-- | demos/widgetsgallery/progressbarpage.cpp | 35 | ||||
-rw-r--r-- | demos/widgetsgallery/progressbarpage.h | 6 |
2 files changed, 28 insertions, 13 deletions
diff --git a/demos/widgetsgallery/progressbarpage.cpp b/demos/widgetsgallery/progressbarpage.cpp index c8f429ee..85d0e6fb 100644 --- a/demos/widgetsgallery/progressbarpage.cpp +++ b/demos/widgetsgallery/progressbarpage.cpp @@ -26,11 +26,13 @@ #include <MLinearLayoutPolicy> #include <MGridLayoutPolicy> #include <MProgressIndicator> -#include <MSceneManager> #include <QPropertyAnimation> +#include <MSceneManager> ProgressBarPage::ProgressBarPage() : TemplatePage(TemplatePage::SimpleWidgets), + button1(0), + bar1ValueAnimation(0), bar1(0), bar2(0), label1(0), @@ -61,6 +63,14 @@ void ProgressBarPage::createContent() bar1->setValue(0); containerPolicy->addItem(bar1); + bar1ValueAnimation = new QPropertyAnimation(bar1, "value", this); + bar1ValueAnimation->setEasingCurve(QEasingCurve::OutInQuad); + + button1 = new MButton(); + button1->setIconID("icon-m-common-play"); + containerPolicy->addItem(button1, Qt::AlignHCenter); + containerPolicy->setVerticalSpacing(10); + label2 = new MLabel(); containerPolicy->addItem(label2); @@ -69,15 +79,7 @@ void ProgressBarPage::createContent() bar2->setUnknownDuration(true); containerPolicy->addItem(bar2); - QPropertyAnimation* animation = new QPropertyAnimation(bar1, "value", this); - // loop forever - animation->setLoopCount(-1); - // start and end value should match bar1's range - animation->setStartValue(0); - animation->setEndValue(1000); - // 10 seconds to fill the bar - animation->setDuration(10000); - animation->start(); + connect(button1, SIGNAL(clicked()), this, SLOT(animateProgressBar1())); retranslateUi(); } @@ -97,5 +99,14 @@ void ProgressBarPage::retranslateUi() label2->setText(qtTrId("xx_progressindicator_unknown_duration_bar")); } - - +void ProgressBarPage::animateProgressBar1() +{ + if (bar1ValueAnimation->state() != QAbstractAnimation::Running) { + // start and end value should match bar1's range + bar1ValueAnimation->setStartValue(bar1->minimum()); + bar1ValueAnimation->setEndValue(bar1->maximum()); + // 10 seconds to fill the bar + bar1ValueAnimation->setDuration(10000); + bar1ValueAnimation->start(); + } +} diff --git a/demos/widgetsgallery/progressbarpage.h b/demos/widgetsgallery/progressbarpage.h index 223c8a84..91921115 100644 --- a/demos/widgetsgallery/progressbarpage.h +++ b/demos/widgetsgallery/progressbarpage.h @@ -22,11 +22,11 @@ #include "templatepage.h" - class MGridLayoutPolicy; class MProgressIndicator; class MButton; class MLabel; +class QPropertyAnimation; class ProgressBarPage : public TemplatePage { @@ -39,11 +39,15 @@ public: protected: virtual void retranslateUi(); private: + MButton* button1; + QPropertyAnimation* bar1ValueAnimation; MProgressIndicator *bar1; MProgressIndicator *bar2; MLabel *label1; MLabel *label2; int position; +private Q_SLOTS: + void animateProgressBar1(); }; #endif // PROGRESSBARPAGE_H |