@@ -114,11 +114,24 @@ bool UpdateController::isDetailedUpdateInfo() const
114114 return d->detailedInfo ;
115115}
116116
117+ QString UpdateController::desktopFileName () const
118+ {
119+ return d->taskbar ?
120+ d->taskbar ->attribute (QTaskbarControl::LinuxDesktopFile).toString () :
121+ QString{};
122+ }
123+
117124void UpdateController::setDetailedUpdateInfo (bool detailedUpdateInfo)
118125{
119126 d->detailedInfo = detailedUpdateInfo;
120127}
121128
129+ void UpdateController::setDesktopFileName (const QString &desktopFileName)
130+ {
131+ if (d->taskbar )
132+ d->taskbar ->setAttribute (QTaskbarControl::LinuxDesktopFile, desktopFileName);
133+ }
134+
122135Updater *UpdateController::updater () const
123136{
124137 return d->mainUpdater ;
@@ -155,8 +168,10 @@ bool UpdateController::start(DisplayLevel displayLevel)
155168 return false ;
156169 } else {
157170 if (d->displayLevel >= ExtendedInfoLevel) {
158- d->checkUpdatesProgress = new ProgressDialog (d->window );
159171 if (d->displayLevel >= ProgressLevel) {
172+ d->taskbar ->setProgress (-1.0 );
173+ d->taskbar ->setProgressVisible (true );
174+ d->checkUpdatesProgress = new ProgressDialog{d->window };
160175 connect (d->checkUpdatesProgress .data (), &ProgressDialog::canceled, this , [this ](){
161176 d->wasCanceled = true ;
162177 });
@@ -202,61 +217,65 @@ void UpdateController::cancelScheduledUpdate(int taskId)
202217void UpdateController::checkUpdatesDone (bool hasUpdates, bool hasError)
203218{
204219 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-
215220 if (d->checkUpdatesProgress ) {
216- d->checkUpdatesProgress ->hide (iconType );
221+ d->checkUpdatesProgress ->hide ();
217222 d->checkUpdatesProgress ->deleteLater ();
218223 d->checkUpdatesProgress = nullptr ;
219224 }
220225 }
221226
222227 if (d->wasCanceled ) {
223228 if (d->displayLevel >= ExtendedInfoLevel) {
229+ d->setTaskbarState (QTaskbarControl::Paused);
224230 DialogMaster::warningT (d->window ,
225231 tr (" Check for Updates" ),
226232 tr (" Checking for updates was canceled!" ));
227233 }
228234 } else {
229235 if (hasUpdates) {
230236 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+
231248 auto shouldShutDown = false ;
232249 const auto oldRunAdmin = d->runAdmin ;
233- const auto res = UpdateInfoDialog::showUpdateInfo (d-> mainUpdater -> updateInfo () ,
250+ const auto res = UpdateInfoDialog::showUpdateInfo (updateInfos ,
234251 d->runAdmin ,
235252 d->adminUserEdit ,
236253 d->detailedInfo ,
237254 d->window );
255+ d->clearTaskbar ();
256+
238257 if (d->runAdmin != oldRunAdmin)
239258 emit runAsAdminChanged (d->runAdmin );
240259
241- QT_WARNING_PUSH
242- QT_WARNING_DISABLE_GCC (" -Wimplicit-fallthrough" )
243260 switch (res) {
244261 case UpdateInfoDialog::InstallNow:
245262 shouldShutDown = true ;
263+ Q_FALLTHROUGH ();
246264 case UpdateInfoDialog::InstallLater:
247265 d->mainUpdater ->runUpdaterOnExit (d->runAdmin ? new AdminAuthorization () : nullptr );
248266 if (shouldShutDown)
249267 qApp->quit ();
268+ break ;
250269 case UpdateInfoDialog::NoInstall:
251270 break ;
252271 default :
253272 Q_UNREACHABLE ();
254273 }
255- QT_WARNING_POP
256274
257275 } else {
258276 d->mainUpdater ->runUpdaterOnExit (d->runAdmin ? new AdminAuthorization () : nullptr );
259277 if (d->displayLevel == ExitLevel) {
278+ d->setTaskbarState (QTaskbarControl::Running);
260279 DialogMaster::informationT (d->window ,
261280 tr (" Install Updates" ),
262281 tr (" New updates are available. The maintenance tool will be "
@@ -274,10 +293,12 @@ void UpdateController::checkUpdatesDone(bool hasUpdates, bool hasError)
274293
275294 if (d->displayLevel >= ExtendedInfoLevel) {
276295 if (d->mainUpdater ->exitedNormally ()) {
296+ d->setTaskbarState (QTaskbarControl::Stopped);
277297 DialogMaster::criticalT (d->window ,
278298 tr (" Check for Updates" ),
279299 tr (" No new updates available!" ));
280300 } else {
301+ d->setTaskbarState (QTaskbarControl::Paused);
281302 DialogMaster::warningT (d->window ,
282303 tr (" Check for Updates" ),
283304 tr (" The update process crashed!" ));
@@ -286,6 +307,7 @@ void UpdateController::checkUpdatesDone(bool hasUpdates, bool hasError)
286307 }
287308 }
288309
310+ d->clearTaskbar ();
289311 d->running = false ;
290312 emit runningChanged (false );
291313}
@@ -311,7 +333,8 @@ UpdateControllerPrivate::UpdateControllerPrivate(UpdateController *q_ptr, const
311333 q{q_ptr},
312334 window{window},
313335 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}}
315338{
316339 QObject::connect (mainUpdater, &Updater::checkUpdatesDone,
317340 q, &UpdateController::checkUpdatesDone,
@@ -333,4 +356,29 @@ UpdateControllerPrivate::~UpdateControllerPrivate()
333356
334357 if (checkUpdatesProgress)
335358 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+ }
336384}
0 commit comments