diff options
author | Gerald Combs <gerald@wireshark.org> | 2014-08-13 08:10:44 -0700 |
---|---|---|
committer | Gerald Combs <gerald@wireshark.org> | 2014-08-13 23:00:25 +0000 |
commit | e3978271dfea090e9d2d98b1fa58a5636411e614 (patch) | |
tree | 2eb5e2818e95e1ca48bc03a7a8d4bca0f405e267 /ui | |
parent | a83f67cb85926e42314d25f7ddbbd66dbae5b6ed (diff) |
Windows Qt: Add taskbar progress support
Add support for the taskbar progress indicator on Windows via
QtWinExtras. It is almost as if we're a grown up Windows application.
Change-Id: I378206b49510d4bd08f2437d8e9a1b01bc6f1351
Reviewed-on: https://code.wireshark.org/review/3576
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui')
-rw-r--r-- | ui/qt/QtShark.pro | 4 | ||||
-rw-r--r-- | ui/qt/progress_bar.cpp | 36 | ||||
-rw-r--r-- | ui/qt/progress_bar.h | 11 |
3 files changed, 47 insertions, 4 deletions
diff --git a/ui/qt/QtShark.pro b/ui/qt/QtShark.pro index b08e190aed..f50f94e0ae 100644 --- a/ui/qt/QtShark.pro +++ b/ui/qt/QtShark.pro @@ -27,9 +27,11 @@ isEqual(QT_MAJOR_VERSION, 4) { QT += core gui } else { QT += core widgets printsupport - win: QT += gui-private } +isEqual(QT_MAJOR_VERSION, 5): greaterThan(QT_MINOR_VERSION, 1): win32 { + QT += winextras +} macx { TARGET = Wireshark diff --git a/ui/qt/progress_bar.cpp b/ui/qt/progress_bar.cpp index 6d63ae409d..7c36c1977e 100644 --- a/ui/qt/progress_bar.cpp +++ b/ui/qt/progress_bar.cpp @@ -30,9 +30,8 @@ #include <QGraphicsOpacityEffect> #include <QPropertyAnimation> -// XXX We should probably call ITaskbarList3::SetProgressState and -// ::SetProgressState on Windows and add an NSProgressIndicator to the -// dock icon on OS X. +// XXX We should probably add an NSProgressIndicator to the dock icon +// on OS X. static progdlg_t * common_create_progress_dlg(bool animate, const gpointer top_level_window, @@ -116,6 +115,9 @@ destroy_progress_dlg(progdlg_t *dlg) // into our sibling status message? ProgressBar::ProgressBar(QWidget *parent) : QProgressBar(parent), terminate_is_stop_(false), stop_flag_(NULL) +#ifdef QWINTASKBARPROGRESS_H + , taskbar_progress_(NULL) +#endif { progress_dialog_.progress_bar = this; progress_dialog_.top_level_window = window(); @@ -161,10 +163,38 @@ progdlg_t * ProgressBar::show(bool animate, bool terminate_is_stop, gboolean *st Q_UNUSED(animate); #endif +#ifdef QWINTASKBARPROGRESS_H + // windowHandle() is picky about returning a non-NULL value so we check it + // each time. + if (!taskbar_progress_ && window()->windowHandle()) { + QWinTaskbarButton *taskbar_button = new QWinTaskbarButton(this); + if (taskbar_button) { + taskbar_button->setWindow(window()->windowHandle()); + taskbar_progress_ = taskbar_button->progress(); + connect(this, SIGNAL(valueChanged(int)), taskbar_progress_, SLOT(setValue(int))); + } + } + if (taskbar_progress_) { + taskbar_progress_->show(); + } + taskbar_progress_->resume(); +#endif + QProgressBar::show(); return &progress_dialog_; } +#ifdef QWINTASKBARPROGRESS_H +void ProgressBar::hide() +{ + if (taskbar_progress_) { + taskbar_progress_->reset(); + taskbar_progress_->hide(); + } + QProgressBar::hide(); +} +#endif + /* * Editor modelines * diff --git a/ui/qt/progress_bar.h b/ui/qt/progress_bar.h index 17155700fc..e2c21a3926 100644 --- a/ui/qt/progress_bar.h +++ b/ui/qt/progress_bar.h @@ -28,6 +28,11 @@ #include <QProgressBar> +#if defined(Q_OS_WIN) && QT_VERSION >= QT_VERSION_CHECK(5, 2, 0) +#include <QWinTaskbarButton> +#include <QWinTaskbarProgress> +#endif + class ProgressBar; // Define the structure describing a progress dialog. @@ -43,6 +48,9 @@ class ProgressBar : public QProgressBar public: explicit ProgressBar(QWidget *parent = 0); progdlg_t *show(bool animate, bool terminate_is_stop, gboolean *stop_flag, int value); +#ifdef QWINTASKBARPROGRESS_H + void hide(); +#endif private: progdlg_t progress_dialog_; @@ -50,6 +58,9 @@ private: QString status_; bool terminate_is_stop_; gboolean *stop_flag_; +#ifdef QWINTASKBARPROGRESS_H + QWinTaskbarProgress *taskbar_progress_; +#endif public slots: |