@@ -114,11 +114,24 @@ bool UpdateController::isDetailedUpdateInfo() const
114
114
return d->detailedInfo ;
115
115
}
116
116
117
+ QString UpdateController::desktopFileName () const
118
+ {
119
+ return d->taskbar ?
120
+ d->taskbar ->attribute (QTaskbarControl::LinuxDesktopFile).toString () :
121
+ QString{};
122
+ }
123
+
117
124
void UpdateController::setDetailedUpdateInfo (bool detailedUpdateInfo)
118
125
{
119
126
d->detailedInfo = detailedUpdateInfo;
120
127
}
121
128
129
+ void UpdateController::setDesktopFileName (const QString &desktopFileName)
130
+ {
131
+ if (d->taskbar )
132
+ d->taskbar ->setAttribute (QTaskbarControl::LinuxDesktopFile, desktopFileName);
133
+ }
134
+
122
135
Updater *UpdateController::updater () const
123
136
{
124
137
return d->mainUpdater ;
@@ -155,8 +168,10 @@ bool UpdateController::start(DisplayLevel displayLevel)
155
168
return false ;
156
169
} else {
157
170
if (d->displayLevel >= ExtendedInfoLevel) {
158
- d->checkUpdatesProgress = new ProgressDialog (d->window );
159
171
if (d->displayLevel >= ProgressLevel) {
172
+ d->taskbar ->setProgress (-1.0 );
173
+ d->taskbar ->setProgressVisible (true );
174
+ d->checkUpdatesProgress = new ProgressDialog{d->window };
160
175
connect (d->checkUpdatesProgress .data (), &ProgressDialog::canceled, this , [this ](){
161
176
d->wasCanceled = true ;
162
177
});
@@ -202,61 +217,65 @@ void UpdateController::cancelScheduledUpdate(int taskId)
202
217
void UpdateController::checkUpdatesDone (bool hasUpdates, bool hasError)
203
218
{
204
219
if (d->displayLevel >= ExtendedInfoLevel) {
205
- auto iconType = QMessageBox::NoIcon;
206
- if (hasUpdates)
207
- iconType = QMessageBox::Information;
208
- else {
209
- if (d->wasCanceled || !d->mainUpdater ->exitedNormally ())
210
- iconType = QMessageBox::Warning;
211
- else
212
- iconType = QMessageBox::Critical;
213
- }
214
-
215
220
if (d->checkUpdatesProgress ) {
216
- d->checkUpdatesProgress ->hide (iconType );
221
+ d->checkUpdatesProgress ->hide ();
217
222
d->checkUpdatesProgress ->deleteLater ();
218
223
d->checkUpdatesProgress = nullptr ;
219
224
}
220
225
}
221
226
222
227
if (d->wasCanceled ) {
223
228
if (d->displayLevel >= ExtendedInfoLevel) {
229
+ d->setTaskbarState (QTaskbarControl::Paused);
224
230
DialogMaster::warningT (d->window ,
225
231
tr (" Check for Updates" ),
226
232
tr (" Checking for updates was canceled!" ));
227
233
}
228
234
} else {
229
235
if (hasUpdates) {
230
236
if (d->displayLevel >= InfoLevel) {
237
+ const auto updateInfos = d->mainUpdater ->updateInfo ();
238
+ d->setTaskbarState (QTaskbarControl::Running);
239
+ if (d->taskbar ) {
240
+ if (updateInfos.size () > 0 ) {
241
+ d->taskbar ->setCounter (updateInfos.size ());
242
+ d->taskbar ->setCounterVisible (true );
243
+ } else
244
+ d->taskbar ->setCounterVisible (false );
245
+ }
246
+
247
+
231
248
auto shouldShutDown = false ;
232
249
const auto oldRunAdmin = d->runAdmin ;
233
- const auto res = UpdateInfoDialog::showUpdateInfo (d-> mainUpdater -> updateInfo () ,
250
+ const auto res = UpdateInfoDialog::showUpdateInfo (updateInfos ,
234
251
d->runAdmin ,
235
252
d->adminUserEdit ,
236
253
d->detailedInfo ,
237
254
d->window );
255
+ d->clearTaskbar ();
256
+
238
257
if (d->runAdmin != oldRunAdmin)
239
258
emit runAsAdminChanged (d->runAdmin );
240
259
241
- QT_WARNING_PUSH
242
- QT_WARNING_DISABLE_GCC (" -Wimplicit-fallthrough" )
243
260
switch (res) {
244
261
case UpdateInfoDialog::InstallNow:
245
262
shouldShutDown = true ;
263
+ Q_FALLTHROUGH ();
246
264
case UpdateInfoDialog::InstallLater:
247
265
d->mainUpdater ->runUpdaterOnExit (d->runAdmin ? new AdminAuthorization () : nullptr );
248
266
if (shouldShutDown)
249
267
qApp->quit ();
268
+ break ;
250
269
case UpdateInfoDialog::NoInstall:
251
270
break ;
252
271
default :
253
272
Q_UNREACHABLE ();
254
273
}
255
- QT_WARNING_POP
256
274
257
275
} else {
258
276
d->mainUpdater ->runUpdaterOnExit (d->runAdmin ? new AdminAuthorization () : nullptr );
259
277
if (d->displayLevel == ExitLevel) {
278
+ d->setTaskbarState (QTaskbarControl::Running);
260
279
DialogMaster::informationT (d->window ,
261
280
tr (" Install Updates" ),
262
281
tr (" New updates are available. The maintenance tool will be "
@@ -274,10 +293,12 @@ void UpdateController::checkUpdatesDone(bool hasUpdates, bool hasError)
274
293
275
294
if (d->displayLevel >= ExtendedInfoLevel) {
276
295
if (d->mainUpdater ->exitedNormally ()) {
296
+ d->setTaskbarState (QTaskbarControl::Stopped);
277
297
DialogMaster::criticalT (d->window ,
278
298
tr (" Check for Updates" ),
279
299
tr (" No new updates available!" ));
280
300
} else {
301
+ d->setTaskbarState (QTaskbarControl::Paused);
281
302
DialogMaster::warningT (d->window ,
282
303
tr (" Check for Updates" ),
283
304
tr (" The update process crashed!" ));
@@ -286,6 +307,7 @@ void UpdateController::checkUpdatesDone(bool hasUpdates, bool hasError)
286
307
}
287
308
}
288
309
310
+ d->clearTaskbar ();
289
311
d->running = false ;
290
312
emit runningChanged (false );
291
313
}
@@ -311,7 +333,8 @@ UpdateControllerPrivate::UpdateControllerPrivate(UpdateController *q_ptr, const
311
333
q{q_ptr},
312
334
window{window},
313
335
mainUpdater{toolPath.isEmpty () ? new Updater{q_ptr} : new Updater{toolPath, q_ptr}},
314
- scheduler{new SimpleScheduler{q_ptr}}
336
+ taskbar{window ? new QTaskbarControl{window} : nullptr },
337
+ scheduler{new SimpleScheduler{q_ptr}}
315
338
{
316
339
QObject::connect (mainUpdater, &Updater::checkUpdatesDone,
317
340
q, &UpdateController::checkUpdatesDone,
@@ -333,4 +356,29 @@ UpdateControllerPrivate::~UpdateControllerPrivate()
333
356
334
357
if (checkUpdatesProgress)
335
358
checkUpdatesProgress->deleteLater ();
359
+
360
+ clearTaskbar ();
361
+ }
362
+
363
+ void UpdateControllerPrivate::setTaskbarState (QTaskbarControl::WinProgressState state)
364
+ {
365
+ if (taskbar) {
366
+ taskbar->setProgress (1.0 );
367
+ taskbar->setAttribute (QTaskbarControl::WindowsProgressState, state);
368
+ #ifdef Q_OS_WIN
369
+ taskbar->setProgressVisible (true );
370
+ #else
371
+ taskbar->setProgressVisible (false );
372
+ #endif
373
+ }
374
+ }
375
+
376
+
377
+ void UpdateControllerPrivate::clearTaskbar ()
378
+ {
379
+ if (taskbar) {
380
+ taskbar->setCounterVisible (false );
381
+ taskbar->setProgressVisible (false );
382
+ taskbar->deleteLater ();
383
+ }
336
384
}
0 commit comments