Skip to content

Commit 6222f72

Browse files
committed
use QTaskbarControl for progress bars
1 parent 3bd394a commit 6222f72

File tree

7 files changed

+38
-75
lines changed

7 files changed

+38
-75
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,11 @@ There are multiple ways to install the Qt module, sorted by preference:
5151
3. You can install either all of my modules, or select the one you need: `Qt Auto Updater`
5252
4. Continue the setup and thats it! you can now use the module for all of your installed Kits for that Qt
5353
2. Download the compiled modules from the release page. **Note:** You will have to add the correct ones yourself and may need to adjust some paths to fit your installation!
54-
3. Build it yourself! **Note:** This requires perl, [qpmx](https://github.com/Skycoder42/qpmx) and [qpm](https://github.com/Cutehacks/qpm) to be installed. If you don't have/need cmake, you can ignore the related warnings. To automatically build and install to your Qt installation, run:
54+
3. Build it yourself! **Note:** This requires perl to be installed. If you don't have/need cmake, you can ignore the related warnings. To automatically build and install to your Qt installation, run:
55+
- Install and prepare [qdep](https://github.com/Skycoder42/qdep#installation)
5556
- `qmake`
56-
- `make qmake_all`
57-
- `make`
57+
- `make` (If you want the tests/examples/etc. run `make all`)
58+
- Optional step: `make doxygen` to generate the documentation
5859
- `make install`
5960

6061
## Usage

src/autoupdatercore/updater_p.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ namespace QtAutoUpdater
1515

1616
class Q_AUTOUPDATERCORE_EXPORT UpdaterPrivate : public QObject
1717
{
18+
Q_DISABLE_COPY(UpdaterPrivate)
1819
public:
1920
class Q_AUTOUPDATERCORE_EXPORT NoUpdatesXmlException : public QExceptionBase {
2021
public:

src/autoupdatergui/autoupdatergui.pro

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,9 @@ win32 {
6161
QMAKE_TARGET_BUNDLE_PREFIX = "de.skycoder42."
6262
}
6363

64-
QDEP_DEPENDS += Skycoder42/DialogMaster@1.4.0
64+
QDEP_DEPENDS += \
65+
Skycoder42/DialogMaster@1.4.0 \
66+
Skycoder42/QTaskbarControl@1.2.1
6567
QDEP_LINK_DEPENDS += ../autoupdatercore
6668

6769
!load(qdep):error("Failed to load qdep feature! Run 'qdep prfgen --qmake $$QMAKE_QMAKE' to create it.")

src/autoupdatergui/progressdialog.cpp

Lines changed: 25 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -3,34 +3,23 @@
33

44
#include <QtGui/QCloseEvent>
55
#include <dialogmaster.h>
6-
#ifdef Q_OS_WIN
7-
#include <QtWinExtras/QWinTaskbarProgress>
8-
#endif
96

107
using namespace QtAutoUpdater;
118

129
ProgressDialog::ProgressDialog(QWidget *parent) :
13-
QDialog(parent),
14-
ui(new Ui::ProgressDialog)
15-
#ifdef Q_OS_WIN
16-
,tButton(new QWinTaskbarButton(this))
17-
#endif
10+
QDialog{parent},
11+
ui{new Ui::ProgressDialog},
12+
taskbar{new QTaskbarControl{this}}
1813
{
1914
ui->setupUi(this);
2015
DialogMaster::masterDialog(this, true, Qt::CustomizeWindowHint | Qt::WindowTitleHint | Qt::WindowCloseButtonHint | Qt::WindowMinimizeButtonHint);
21-
#ifdef Q_OS_WIN
22-
if(parent)
23-
setupTaskbar(parent);
24-
#endif
25-
}
2616

27-
ProgressDialog::~ProgressDialog()
28-
{
29-
#ifdef Q_OS_WIN
30-
tButton->progress()->hide();
31-
#endif
17+
taskbar->setProgress(-1.0);
18+
taskbar->setProgressVisible(true);
3219
}
3320

21+
ProgressDialog::~ProgressDialog() = default;
22+
3423
void ProgressDialog::setCanceled()
3524
{
3625
ui->label->setText(tr("Canceling update check…"));
@@ -39,29 +28,25 @@ void ProgressDialog::setCanceled()
3928

4029
void ProgressDialog::hide(QMessageBox::Icon hideType)
4130
{
42-
#ifdef Q_OS_WIN
43-
if(tButton->window()) {
44-
QWinTaskbarProgress *progress = tButton->progress();
45-
progress->setRange(0, 1);
46-
progress->setValue(1);
47-
switch (hideType) {
48-
case QMessageBox::Information:
49-
progress->resume();
50-
break;
51-
case QMessageBox::Warning:
52-
progress->pause();
53-
break;
54-
case QMessageBox::Critical:
55-
progress->stop();
56-
break;
57-
default:
58-
progress->hide();
59-
break;
60-
}
31+
taskbar->setProgress(1.0);
32+
switch (hideType) {
33+
case QMessageBox::Information:
34+
taskbar->setAttribute(QTaskbarControl::WindowsProgressState, QTaskbarControl::Running);
35+
taskbar->setProgressVisible(true);
36+
break;
37+
case QMessageBox::Warning:
38+
taskbar->setAttribute(QTaskbarControl::WindowsProgressState, QTaskbarControl::Paused);
39+
taskbar->setProgressVisible(true);
40+
break;
41+
case QMessageBox::Critical:
42+
taskbar->setAttribute(QTaskbarControl::WindowsProgressState, QTaskbarControl::Stopped);
43+
taskbar->setProgressVisible(true);
44+
break;
45+
default:
46+
taskbar->setProgressVisible(false);
47+
break;
6148
}
62-
#else
63-
Q_UNUSED(hideType)
64-
#endif
49+
6550
QDialog::hide();
6651
}
6752

@@ -74,22 +59,3 @@ void ProgressDialog::closeEvent(QCloseEvent *event)
7459
}
7560
}
7661

77-
#ifdef Q_OS_WIN
78-
void ProgressDialog::showEvent(QShowEvent *event)
79-
{
80-
event->accept();
81-
setupTaskbar(this);
82-
}
83-
84-
void ProgressDialog::setupTaskbar(QWidget *window)
85-
{
86-
if(!tButton->window()) {
87-
tButton->setWindow(window->windowHandle());
88-
QWinTaskbarProgress *progress = tButton->progress();
89-
progress->setRange(0, 0);
90-
progress->resume();
91-
progress->show();
92-
}
93-
}
94-
#endif
95-

src/autoupdatergui/progressdialog_p.h

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,10 @@
88
#include <QtWidgets/QDialog>
99
#include <QtWidgets/QMessageBox>
1010

11-
#ifdef Q_OS_WIN
12-
#include <QtWinExtras/QWinTaskbarButton>
13-
#endif
14-
1511
#include <functional>
1612

13+
#include <qtaskbarcontrol.h>
14+
1715
namespace Ui {
1816
class ProgressDialog;
1917
}
@@ -49,18 +47,11 @@ public Q_SLOTS:
4947
void canceled();
5048

5149
protected:
52-
#ifdef Q_OS_WIN
53-
void showEvent(QShowEvent *event) override;
54-
#endif
5550
void closeEvent(QCloseEvent *event) override;
5651

5752
private:
5853
QScopedPointer<Ui::ProgressDialog> ui;
59-
#ifdef Q_OS_WIN
60-
QWinTaskbarButton *tButton;
61-
62-
void setupTaskbar(QWidget *window);
63-
#endif
54+
QTaskbarControl *taskbar;
6455
};
6556

6657
}

src/autoupdatergui/updatebutton_p.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ namespace QtAutoUpdater
1818

1919
class Q_AUTOUPDATERGUI_EXPORT UpdateButtonPrivate
2020
{
21+
Q_DISABLE_COPY(UpdateButtonPrivate)
2122
public:
2223
UpdateButton *q;
2324

src/autoupdatergui/updatecontroller_p.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ namespace QtAutoUpdater
1616

1717
class Q_AUTOUPDATERGUI_EXPORT UpdateControllerPrivate
1818
{
19+
Q_DISABLE_COPY(UpdateControllerPrivate)
1920
public:
2021
using UpdateTask = QPair<UpdateController::DisplayLevel, bool>;
2122

0 commit comments

Comments
 (0)