From de3b7b4204dad44a272c7e46cef77e1c788050d0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Fri, 27 Apr 2018 08:11:40 +0200 Subject: [PATCH] Force update available to false if an update is running --- snapd/snapdcontrol.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/snapd/snapdcontrol.cpp b/snapd/snapdcontrol.cpp index 8a1d3f76..56ce102b 100644 --- a/snapd/snapdcontrol.cpp +++ b/snapd/snapdcontrol.cpp @@ -243,7 +243,7 @@ void SnapdControl::onLoadRunningChangesFinished() QString changeStatus = changeMap.value("status").toString(); QString changeSummary = changeMap.value("summary").toString(); - // If there is a change kind "doing" or "Do" + // If there is a change kind "Doing" or "Do" if ( (changeStatus == "Doing" || changeStatus == "Do") && m_updateChangeKinds.contains(changeKind)) { // Set the status of the current running change updateRunning = true; @@ -251,10 +251,16 @@ void SnapdControl::onLoadRunningChangesFinished() updateStatus = changeSummary; qCDebug(dcSnapd()).noquote() << "Current change:" << changeId << (changeReady ? "ready" : "not ready") << changeStatus << changeKind << changeSummary; + // TODO: calculate the overall percentage of the update process (Do + Doing / Done) } } } + // If currently an update is running, lets force update available to false if set to true + if (updateRunning && device()->stateValue(snapdControlUpdateAvailableStateTypeId).toBool()) { + device()->setStateValue(snapdControlUpdateAvailableStateTypeId, false); + } + device()->setStateValue(snapdControlUpdateRunningStateTypeId, updateRunning); device()->setStateValue(snapdControlStatusStateTypeId, updateStatus); }