From b28ea53b351c9871ecc6ce8a4d3c19806254b9d1 Mon Sep 17 00:00:00 2001 From: Kai Uwe Broulik Date: Wed, 21 Sep 2016 10:49:55 +0200 Subject: [PATCH] [Device Notifier] Only ever pop up if device is visible in the list When a device notification arrives, such as "you can now safely unmount" or "failed to unmount" device notifier would unconditionally open showing an empty list. Since we now show device notifications only connected to the device they're about, it makes no sense to expand it for invisible devices. Applications where mounting or unmounting can fail for non-removable devices, like Dolphin, already show the error message within the UI anyway, making the popup redundant. BUG: 368894 FIXED-IN: 5.8.0 Differential Revision: https://phabricator.kde.org/D2823 --- .../package/contents/ui/devicenotifier.qml | 25 +++++++++++++------ 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/applets/devicenotifier/package/contents/ui/devicenotifier.qml b/applets/devicenotifier/package/contents/ui/devicenotifier.qml index 9e01df91d..946a18758 100644 --- a/applets/devicenotifier/package/contents/ui/devicenotifier.qml +++ b/applets/devicenotifier/package/contents/ui/devicenotifier.qml @@ -134,13 +134,21 @@ Item { processLastDevice(false); } + function isViableDevice(udi) { + if (devicesType === "all") { + return true; + } + + var device = data[udi]; + return (devicesType === "removable" && device.Removable) + || (devicesType === "nonRemovable" && !device.Removable); + } + function processLastDevice(expand) { - if (last != "") { - if (devicesType == "all" || - (devicesType == "removable" && data[last] && data[last]["Removable"] == true) || - (devicesType == "nonRemovable" && data[last] && data[last]["Removable"] == false)) { - if (expand && hpSource.data[last]["added"]) { - expandDevice(last) + if (last) { + if (isViableDevice(last)) { + if (expand && hpSource.data[last].added) { + expandDevice(last); } last = ""; } @@ -181,7 +189,10 @@ Item { onDataChanged: { if (last) { lastUdi = data[last].udi - plasmoid.expanded = true + + if (sdSource.isViableDevice(lastUdi)) { + plasmoid.expanded = true + } } }