aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@digia.com>2013-08-29 11:31:27 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-08-29 12:26:30 +0200
commit71e4e00c64b059814d2c41b46018fda645dd0a51 (patch)
tree54051f86a9c0db669c500f079d1a0fe95e2cf383 /src
parent491b83d228a5eecaae3cbb8a63355d8cd2da6996 (diff)
Replace QWinTaskbarProgress::NoProgressState with a visible-property
Calling show()/hide() or setVisible(false) is a bit more intuitive and Qt-stylish than setState(NoProgressState). Change-Id: I12138454299f53a09e37bb82b473163e49ac97b3 Reviewed-by: Ivan Vizir <define-true-false@yandex.com> Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/winextras/qwintaskbarbutton.cpp9
-rw-r--r--src/winextras/qwintaskbarprogress.cpp49
-rw-r--r--src/winextras/qwintaskbarprogress.h7
3 files changed, 56 insertions, 9 deletions
diff --git a/src/winextras/qwintaskbarbutton.cpp b/src/winextras/qwintaskbarbutton.cpp
index 83f6f7d..75dc12e 100644
--- a/src/winextras/qwintaskbarbutton.cpp
+++ b/src/winextras/qwintaskbarbutton.cpp
@@ -73,7 +73,6 @@ static TBPFLAG nativeProgressState(QWinTaskbarProgress::ProgressState state)
TBPFLAG flag;
switch (state) {
default :
- case QWinTaskbarProgress::NoProgressState: flag = TBPF_NOPROGRESS; break;
case QWinTaskbarProgress::NormalState: flag = TBPF_NORMAL; break;
case QWinTaskbarProgress::PausedState: flag = TBPF_PAUSED; break;
case QWinTaskbarProgress::ErrorState: flag = TBPF_ERROR; break;
@@ -138,8 +137,13 @@ void QWinTaskbarButtonPrivate::updateOverlayIcon()
void QWinTaskbarButtonPrivate::_q_updateProgress()
{
- if (!pTbList || !window || !progressBar)
+ if (!pTbList || !window)
+ return;
+
+ if (!progressBar || !progressBar->isVisible()) {
+ pTbList->SetProgressState(handle(), TBPF_NOPROGRESS);
return;
+ }
const int min = progressBar->minimum();
const int max = progressBar->maximum();
@@ -254,6 +258,7 @@ QWinTaskbarProgress *QWinTaskbarButton::progressBar() const
QWinTaskbarButton *that = const_cast<QWinTaskbarButton *>(this);
QWinTaskbarProgress *pbar = new QWinTaskbarProgress(that);
connect(pbar, SIGNAL(valueChanged(int)), this, SLOT(_q_updateProgress()));
+ connect(pbar, SIGNAL(visibilityChanged(bool)), this, SLOT(_q_updateProgress()));
connect(pbar, SIGNAL(stateChanged(QWinTaskbarProgress::ProgressState)), 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 fec4684..0225bf9 100644
--- a/src/winextras/qwintaskbarprogress.cpp
+++ b/src/winextras/qwintaskbarprogress.cpp
@@ -72,8 +72,6 @@ QT_BEGIN_NAMESPACE
This enum type specifies the state of the progress indicator.
- \value NoProgressState
- No progress indicator is displayed.
\value NormalState
The progress indicator is green.
\value PausedState
@@ -91,11 +89,12 @@ public:
int value;
int minimum;
int maximum;
+ bool visible;
QWinTaskbarProgress::ProgressState state;
};
QWinTaskbarProgressPrivate::QWinTaskbarProgressPrivate() :
- value(0), minimum(0), maximum(100), state(QWinTaskbarProgress::NoProgressState)
+ value(0), minimum(0), maximum(100), visible(false), state(QWinTaskbarProgress::NormalState)
{
}
@@ -118,7 +117,7 @@ QWinTaskbarProgress::~QWinTaskbarProgress()
\property QWinTaskbarProgress::state
\brief the state of the progress indicator
- The default value is \c NoProgressState.
+ The default value is \c NormalState.
*/
QWinTaskbarProgress::ProgressState QWinTaskbarProgress::state() const
{
@@ -195,6 +194,44 @@ void QWinTaskbarProgress::setMaximum(int maximum)
}
/*!
+ \property QWinTaskbarProgress::visible
+ \brief the progress indicator is visible.
+
+ The default value is \c false.
+ */
+bool QWinTaskbarProgress::isVisible() const
+{
+ Q_D(const QWinTaskbarProgress);
+ return d->visible;
+}
+
+void QWinTaskbarProgress::setVisible(bool visible)
+{
+ Q_D(QWinTaskbarProgress);
+ if (visible == d->visible)
+ return;
+
+ d->visible = visible;
+ emit visibilityChanged(d->visible);
+}
+
+/*!
+ Shows the progress indicator.
+ */
+void QWinTaskbarProgress::show()
+{
+ setVisible(true);
+}
+
+/*!
+ Hides the progress indicator.
+ */
+void QWinTaskbarProgress::hide()
+{
+ setVisible(false);
+}
+
+/*!
Sets both the \a minimum and \a maximum values.
*/
void QWinTaskbarProgress::setRange(int minimum, int maximum)
@@ -212,13 +249,13 @@ void QWinTaskbarProgress::setRange(int minimum, int maximum)
/*!
Resets the progress indicator.
- This function sets the state to \c NoProgressState and rewinds the
+ This function sets the state to \c NormalState and rewinds the
value to the minimum value.
*/
void QWinTaskbarProgress::reset()
{
setValue(minimum());
- setState(NoProgressState);
+ setState(NormalState);
}
QT_END_NAMESPACE
diff --git a/src/winextras/qwintaskbarprogress.h b/src/winextras/qwintaskbarprogress.h
index ff23bc8..8ee8e3b 100644
--- a/src/winextras/qwintaskbarprogress.h
+++ b/src/winextras/qwintaskbarprogress.h
@@ -57,11 +57,11 @@ class Q_WINEXTRAS_EXPORT QWinTaskbarProgress : public QObject
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_ENUMS(ProgressState)
public:
enum ProgressState {
- NoProgressState,
NormalState,
PausedState,
ErrorState
@@ -74,6 +74,7 @@ public:
int value() const;
int minimum() const;
int maximum() const;
+ bool isVisible() const;
public Q_SLOTS:
void setState(ProgressState state);
@@ -82,12 +83,16 @@ public Q_SLOTS:
void setMaximum(int minimum);
void setRange(int minimum, int maximum);
void reset();
+ void show();
+ void hide();
+ void setVisible(bool visible);
Q_SIGNALS:
void valueChanged(int value);
void minimumChanged(int minimum);
void maximumChanged(int maximum);
void stateChanged(QWinTaskbarProgress::ProgressState state);
+ void visibilityChanged(bool visible);
private:
Q_DISABLE_COPY(QWinTaskbarProgress)