aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@digia.com>2013-09-05 00:19:51 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-09-10 13:29:27 +0200
commit105d6758d96e2c723c885efa4dc82938f2cc2d1f (patch)
treeabd6f5d20469e8a1d86167a63ccd6a16f34b1b25 /src
parent5f4df5a39be121ca60cac2b06cf94bead76d74d9 (diff)
Introduce TaskbarProgress::stop()
Change-Id: Id37e6c5e41ab196cd72148b3242332796b1c54ef Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Ivan Vizir <define-true-false@yandex.com> Reviewed-by: Caroline Chao <caroline.chao@digia.com> Reviewed-by: Laszlo Papp <lpapp@kde.org>
Diffstat (limited to 'src')
-rw-r--r--src/winextras/qwintaskbarbutton.cpp35
-rw-r--r--src/winextras/qwintaskbarprogress.cpp81
-rw-r--r--src/winextras/qwintaskbarprogress.h14
3 files changed, 56 insertions, 74 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)