aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/winextras/qwintaskbarbutton.cpp35
-rw-r--r--src/winextras/qwintaskbarprogress.cpp81
-rw-r--r--src/winextras/qwintaskbarprogress.h14
-rw-r--r--tests/auto/qwintaskbarprogress/tst_qwintaskbarprogress.cpp32
-rw-r--r--tests/manual/taskbar/main.qml43
5 files changed, 115 insertions, 90 deletions
diff --git a/src/winextras/qwintaskbarbutton.cpp b/src/winextras/qwintaskbarbutton.cpp
index 6440b63..3f49f14 100644
--- a/src/winextras/qwintaskbarbutton.cpp
+++ b/src/winextras/qwintaskbarbutton.cpp
@@ -68,15 +68,17 @@ QT_BEGIN_NAMESPACE
window thumbnail popup.
*/
-static TBPFLAG nativeProgressState(QWinTaskbarProgress::ProgressState state)
+static TBPFLAG nativeProgressState(QWinTaskbarProgress *progress)
{
- TBPFLAG flag;
- switch (state) {
- default :
- case QWinTaskbarProgress::NormalState: flag = TBPF_NORMAL; break;
- case QWinTaskbarProgress::ErrorState: flag = TBPF_ERROR; break;
- }
- return flag;
+ if (!progress || !progress->isVisible())
+ return TBPF_NOPROGRESS;
+ if (progress->isStopped())
+ return TBPF_ERROR;
+ if (progress->isPaused())
+ return TBPF_PAUSED;
+ if (progress->minimum() == 0 && progress->maximum() == 0)
+ return TBPF_INDETERMINATE;
+ return TBPF_NORMAL;
}
QWinTaskbarButtonPrivate::QWinTaskbarButtonPrivate() : progressBar(0), pTbList(0), window(0)
@@ -141,23 +143,16 @@ void QWinTaskbarButtonPrivate::_q_updateProgress()
if (!pTbList || !window)
return;
- if (!progressBar || !progressBar->isVisible()) {
- pTbList->SetProgressState(handle(), TBPF_NOPROGRESS);
- return;
- }
-
- const int min = progressBar->minimum();
- const int max = progressBar->maximum();
- if (min == 0 && max == 0) {
- pTbList->SetProgressState(handle(), TBPF_INDETERMINATE);
- } else {
+ if (progressBar) {
+ const int min = progressBar->minimum();
+ const int max = progressBar->maximum();
const int range = max - min;
if (range > 0) {
const int value = 100.0 * (progressBar->value() - min) / range;
pTbList->SetProgressValue(handle(), value, 100);
}
- pTbList->SetProgressState(handle(), progressBar->isPaused() ? TBPF_PAUSED : nativeProgressState(progressBar->state()));
}
+ pTbList->SetProgressState(handle(), nativeProgressState(progressBar));
}
/*!
@@ -264,7 +259,7 @@ QWinTaskbarProgress *QWinTaskbarButton::progress() const
connect(pbar, SIGNAL(maximumChanged(int)), this, SLOT(_q_updateProgress()));
connect(pbar, SIGNAL(visibilityChanged(bool)), this, SLOT(_q_updateProgress()));
connect(pbar, SIGNAL(pausedChanged(bool)), this, SLOT(_q_updateProgress()));
- connect(pbar, SIGNAL(stateChanged(QWinTaskbarProgress::ProgressState)), this, SLOT(_q_updateProgress()));
+ connect(pbar, SIGNAL(stoppedChanged(bool)), this, SLOT(_q_updateProgress()));
that->d_func()->progressBar = pbar;
that->d_func()->_q_updateProgress();
}
diff --git a/src/winextras/qwintaskbarprogress.cpp b/src/winextras/qwintaskbarprogress.cpp
index a851aee..93bae9d 100644
--- a/src/winextras/qwintaskbarprogress.cpp
+++ b/src/winextras/qwintaskbarprogress.cpp
@@ -55,27 +55,14 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn void QWinTaskbarProgress::stateChanged(ProgressState state)
-
- This signal is emitted when the \c state property changes its value.
- The \a state argument contains the new value.
- */
-
-/*!
\fn void QWinTaskbarProgress::valueChanged(int value)
This signal is emitted when the progress indicator \a value changes.
*/
/*!
- \enum QWinTaskbarProgress::ProgressState
-
- This enum type specifies the state of the progress indicator.
-
- \value NormalState
- The progress indicator is green.
- \value ErrorState
- The progress indicator turns red.
+ \fn void QWinTaskbarProgress::stoppedChanged(bool stopped)
+ \internal (for QWinTaskbarButton and QML compatibility)
*/
class QWinTaskbarProgressPrivate
@@ -88,11 +75,11 @@ public:
int maximum;
bool visible;
bool paused;
- QWinTaskbarProgress::ProgressState state;
+ bool stopped;
};
QWinTaskbarProgressPrivate::QWinTaskbarProgressPrivate() :
- value(0), minimum(0), maximum(100), visible(false), paused(false), state(QWinTaskbarProgress::NormalState)
+ value(0), minimum(0), maximum(100), visible(false), paused(false), stopped(false)
{
}
@@ -112,28 +99,6 @@ QWinTaskbarProgress::~QWinTaskbarProgress()
}
/*!
- \property QWinTaskbarProgress::state
- \brief the state of the progress indicator
-
- The default value is \c NormalState.
- */
-QWinTaskbarProgress::ProgressState QWinTaskbarProgress::state() const
-{
- Q_D(const QWinTaskbarProgress);
- return d->state;
-}
-
-void QWinTaskbarProgress::setState(QWinTaskbarProgress::ProgressState state)
-{
- Q_D(QWinTaskbarProgress);
- if (state == d->state)
- return;
-
- d->state = state;
- emit stateChanged(d->state);
-}
-
-/*!
\property QWinTaskbarProgress::value
\brief the current value of the progress indicator
@@ -254,13 +219,11 @@ void QWinTaskbarProgress::setRange(int minimum, int maximum)
/*!
Resets the progress indicator.
- This function sets the state to \c NormalState and rewinds the
- value to the minimum value.
+ This function rewinds the value to the minimum value.
*/
void QWinTaskbarProgress::reset()
{
setValue(minimum());
- setState(NormalState);
}
/*!
@@ -278,7 +241,7 @@ bool QWinTaskbarProgress::isPaused() const
void QWinTaskbarProgress::setPaused(bool paused)
{
Q_D(QWinTaskbarProgress);
- if (paused == d->paused)
+ if (paused == d->paused || d->stopped)
return;
d->paused = paused;
@@ -294,11 +257,41 @@ void QWinTaskbarProgress::pause()
}
/*!
- Resume the progress indicator.
+ Resume a paused or stopped progress indicator.
*/
void QWinTaskbarProgress::resume()
{
+ Q_D(QWinTaskbarProgress);
+ setPaused(false);
+ if (d->stopped) {
+ d->stopped = false;
+ emit stoppedChanged(false);
+ }
+}
+
+/*!
+ \property QWinTaskbarProgress::stopped
+ \brief the progress indicator is stopped.
+
+ The default value is \c false.
+ */
+bool QWinTaskbarProgress::isStopped() const
+{
+ Q_D(const QWinTaskbarProgress);
+ return d->stopped;
+}
+
+/*!
+ Stop the progress indicator.
+ */
+void QWinTaskbarProgress::stop()
+{
+ Q_D(QWinTaskbarProgress);
setPaused(false);
+ if (!d->stopped) {
+ d->stopped = true;
+ emit stoppedChanged(true);
+ }
}
QT_END_NAMESPACE
diff --git a/src/winextras/qwintaskbarprogress.h b/src/winextras/qwintaskbarprogress.h
index fb8ff1d..9d7698d 100644
--- a/src/winextras/qwintaskbarprogress.h
+++ b/src/winextras/qwintaskbarprogress.h
@@ -56,29 +56,22 @@ class Q_WINEXTRAS_EXPORT QWinTaskbarProgress : public QObject
Q_PROPERTY(int value READ value WRITE setValue NOTIFY valueChanged)
Q_PROPERTY(int minimum READ minimum WRITE setMinimum NOTIFY minimumChanged)
Q_PROPERTY(int maximum READ maximum WRITE setMaximum NOTIFY maximumChanged)
- Q_PROPERTY(ProgressState state READ state WRITE setState NOTIFY stateChanged)
Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibilityChanged)
Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged)
- Q_ENUMS(ProgressState)
+ Q_PROPERTY(bool stopped READ isStopped NOTIFY stoppedChanged)
public:
- enum ProgressState {
- NormalState,
- ErrorState
- };
-
explicit QWinTaskbarProgress(QObject *parent = 0);
~QWinTaskbarProgress();
- ProgressState state() const;
int value() const;
int minimum() const;
int maximum() const;
bool isVisible() const;
bool isPaused() const;
+ bool isStopped() const;
public Q_SLOTS:
- void setState(ProgressState state);
void setValue(int value);
void setMinimum(int minimum);
void setMaximum(int maximum);
@@ -90,14 +83,15 @@ public Q_SLOTS:
void pause();
void resume();
void setPaused(bool paused);
+ void stop();
Q_SIGNALS:
void valueChanged(int value);
void minimumChanged(int minimum);
void maximumChanged(int maximum);
- void stateChanged(QWinTaskbarProgress::ProgressState state);
void visibilityChanged(bool visible);
void pausedChanged(bool paused);
+ void stoppedChanged(bool stopped);
private:
Q_DISABLE_COPY(QWinTaskbarProgress)
diff --git a/tests/auto/qwintaskbarprogress/tst_qwintaskbarprogress.cpp b/tests/auto/qwintaskbarprogress/tst_qwintaskbarprogress.cpp
index aa88276..e5e1a63 100644
--- a/tests/auto/qwintaskbarprogress/tst_qwintaskbarprogress.cpp
+++ b/tests/auto/qwintaskbarprogress/tst_qwintaskbarprogress.cpp
@@ -52,6 +52,7 @@ private slots:
void testRange();
void testPause();
void testVisibility();
+ void testStop();
};
void tst_QWinTaskbarProgress::testValue()
@@ -162,6 +163,12 @@ void tst_QWinTaskbarProgress::testPause()
QCOMPARE(pausedSpy.count(), 2);
QCOMPARE(pausedSpy.last().at(0).toBool(), false);
+ progress->stop();
+ progress->pause();
+ QVERIFY(!progress->isPaused());
+ QCOMPARE(pausedSpy.count(), 2);
+
+ progress->resume();
progress->pause();
QVERIFY(progress->isPaused());
QCOMPARE(pausedSpy.count(), 3);
@@ -194,6 +201,31 @@ void tst_QWinTaskbarProgress::testVisibility()
QCOMPARE(visibleSpy.last().at(0).toBool(), false);
}
+void tst_QWinTaskbarProgress::testStop()
+{
+ QWinTaskbarButton btn;
+ QWinTaskbarProgress *progress = btn.progress();
+ QVERIFY(progress);
+ QVERIFY(!progress->isStopped());
+
+ QSignalSpy stoppedSpy(progress, SIGNAL(stoppedChanged(bool)));
+ QVERIFY(stoppedSpy.isValid());
+
+ progress->pause();
+ QVERIFY(progress->isPaused());
+ QVERIFY(!progress->isStopped());
+ progress->stop();
+ QVERIFY(!progress->isPaused());
+ QVERIFY(progress->isStopped());
+ QCOMPARE(stoppedSpy.count(), 1);
+ QCOMPARE(stoppedSpy.last().at(0).toBool(), true);
+
+ progress->resume();
+ QVERIFY(!progress->isStopped());
+ QCOMPARE(stoppedSpy.count(), 2);
+ QCOMPARE(stoppedSpy.last().at(0).toBool(), false);
+}
+
QTEST_MAIN(tst_QWinTaskbarProgress)
#include "tst_qwintaskbarprogress.moc"
diff --git a/tests/manual/taskbar/main.qml b/tests/manual/taskbar/main.qml
index 539b827..7c7af2a 100644
--- a/tests/manual/taskbar/main.qml
+++ b/tests/manual/taskbar/main.qml
@@ -57,9 +57,9 @@ ApplicationWindow {
id: taskbar
progress.visible: progressBox.checked
- progress.minimum: minSpinBox.value
- progress.maximum: maxSpinBox.value
- progress.value: valueSlider.value
+ progress.minimum: indeterminateBox.checked ? 0 : minSpinBox.value
+ progress.maximum: indeterminateBox.checked ? 0 : maxSpinBox.value
+ progress.value: indeterminateBox.checked ? 0 : valueSlider.value
overlayIcon: overlayBox.checked && overlayCombo.currentIndex >= 0 ? overlayModel.get(overlayCombo.currentIndex).source : ""
}
@@ -107,7 +107,7 @@ ApplicationWindow {
Layout.fillWidth: true
GridLayout {
- columns: 5
+ columns: 3
rowSpacing: 10
columnSpacing: 20
anchors.fill: parent
@@ -117,21 +117,12 @@ ApplicationWindow {
Slider {
id: valueSlider
- value: 50
+ value: 82
stepSize: 1
minimumValue: minSpinBox.value
maximumValue: maxSpinBox.value
- Layout.columnSpan: 3
- }
-
- Button {
- readonly property string playText: "\u25BA" // BLACK RIGHT-POINTING POINTER
- readonly property string pauseText: "\u25AE\u25AE" // BLACK VERTICAL RECTANGLE
-
- text: taskbar.progress.paused ? playText : pauseText
- onClicked: taskbar.progress.paused ? taskbar.progress.resume() : taskbar.progress.pause()
- Layout.fillHeight: true
- Layout.rowSpan: 2
+ enabled: !indeterminateBox.checked
+ Layout.columnSpan: 2
}
Label { text: "Minimum:" }
@@ -142,9 +133,21 @@ ApplicationWindow {
stepSize: 1
minimumValue: -1000
maximumValue: 1000
+ enabled: !indeterminateBox.checked
Layout.fillWidth: true
}
+ Button {
+ readonly property string playSymbol: "\u25BA" // BLACK RIGHT-POINTING POINTER
+ readonly property string pauseSymbol: "\u25AE\u25AE" // BLACK VERTICAL RECTANGLE
+ readonly property string stopSymbol: "\u2587" // BLACK SQUARE
+
+ text: taskbar.progress.stopped ? playSymbol : taskbar.progress.paused ? stopSymbol : pauseSymbol
+ onClicked: taskbar.progress.stopped ? taskbar.progress.resume() : taskbar.progress.paused ? taskbar.progress.stop() : taskbar.progress.pause()
+ Layout.fillHeight: true
+ Layout.rowSpan: 3
+ }
+
Label { text: "Maximum:" }
SpinBox {
id: maxSpinBox
@@ -153,8 +156,16 @@ ApplicationWindow {
stepSize: 1
minimumValue: -1000
maximumValue: 1000
+ enabled: !indeterminateBox.checked
Layout.fillWidth: true
}
+
+ Item { Layout.fillWidth: true }
+
+ CheckBox {
+ id: indeterminateBox
+ text: "Indeterminate"
+ }
}
}
}