diff options
author | Robert Griebl <robert.griebl@qt.io> | 2024-02-06 18:58:22 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2024-02-07 18:24:56 +0000 |
commit | 563b91d2b310f4ef56909f50ce8eede9bed0b8e4 (patch) | |
tree | 5a72b4a850c7f3132354a0eff8a6e64f93e68e70 | |
parent | 1481c336a68dce798a77f48b3bb30e4e47af3540 (diff) |
Examples: make the package-installation cope with external acknowledge
In case of an installation via the Creator integration, installations
get automatically acknowledged and we can close the acknowledge dialog
in this situation.
Change-Id: I6478fdb820a3d675862d971999d4840638f9d1b7
Reviewed-by: Bernd Weimer <bernd.weimer@qt.io>
(cherry picked from commit 9a8c91ff758add71e4bbe025ab349e01d36c0e09)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
-rw-r--r-- | examples/applicationmanager/package-installation/system-ui/AcknowledgeDialog.qml | 18 |
1 files changed, 16 insertions, 2 deletions
diff --git a/examples/applicationmanager/package-installation/system-ui/AcknowledgeDialog.qml b/examples/applicationmanager/package-installation/system-ui/AcknowledgeDialog.qml index 26cdb15f..1a3ef458 100644 --- a/examples/applicationmanager/package-installation/system-ui/AcknowledgeDialog.qml +++ b/examples/applicationmanager/package-installation/system-ui/AcknowledgeDialog.qml @@ -40,18 +40,32 @@ QtObject { property Component acknowledgeDialog: Component { QD.MessageDialog { + id: dialog required property string taskId required property string packageName required property list<string> capabilities + property bool acknowledged: false text: "Install <b>" + packageName + "</b>?" informativeText: capabilities.length ? "This package requests the following capabilities: " + capabilities.join(", ") : "This package does not request any capabilities." buttons: QD.MessageDialog.Yes | QD.MessageDialog.No - onAccepted: PackageManager.acknowledgePackageInstallation(taskId) - onRejected: PackageManager.cancelTask(taskId) + onAccepted: if (!acknowledged) PackageManager.acknowledgePackageInstallation(taskId) + onRejected: if (!acknowledged) PackageManager.cancelTask(taskId) onVisibleChanged: if (!visible) { destroy() } + + Connections { + target: PackageManager + function onTaskStateChanged(taskId, state) { + // if somebody else (e.g. appman-controller) acknowledged already, just close + if (visible && (taskId === dialog.taskId) + && (state !== PackageManager.AwaitingAcknowledge)) { + acknowledged = true + close() + } + } + } } } } |