From cc0566dfb49e59a58508193a87cfcccbc4549aa4 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Fri, 27 Oct 2017 12:59:26 +0200 Subject: [PATCH] set applets as expanded after clicking on them --- .../panel/package/contents/ui/main.qml | 3 +- .../contents/ui/quicksettings/Delegate.qml | 4 +- .../ui/quicksettings/QuickSettings.qml | 102 +++++++----------- 3 files changed, 43 insertions(+), 66 deletions(-) diff --git a/containments/panel/package/contents/ui/main.qml b/containments/panel/package/contents/ui/main.qml index 0c72d49f..cc6421c9 100644 --- a/containments/panel/package/contents/ui/main.qml +++ b/containments/panel/package/contents/ui/main.qml @@ -63,7 +63,7 @@ PlasmaCore.ColorScope { } else if (applet.pluginName != "org.kde.phone.quicksettings") { applet.expanded = true applet.expanded = false - quickSettings.addPlasmoid(applet.icon, applet.title, fullRepsLayout.count); + quickSettings.addPlasmoid(applet, fullRepsLayout.count); applet.fullRepresentationItem.parent = fullRepsLayout; fullRepsLayout.currentIndex = 0 applet.fullRepresentationItem.anchors.fill = fullRepsLayout; @@ -229,6 +229,7 @@ PlasmaCore.ColorScope { id: quickSettings anchors.fill: parent onPlasmoidTriggered: { + applet.expanded = true; fullRepsLayout.currentIndex = id; slidingPanel.expanded = true; } diff --git a/containments/panel/package/contents/ui/quicksettings/Delegate.qml b/containments/panel/package/contents/ui/quicksettings/Delegate.qml index 3db8a7f6..30ebf0c4 100644 --- a/containments/panel/package/contents/ui/quicksettings/Delegate.qml +++ b/containments/panel/package/contents/ui/quicksettings/Delegate.qml @@ -46,7 +46,7 @@ RowLayout { anchors.fill: parent onClicked: { if (model.plasmoidId > -1) { - root.plasmoidTriggered(model.plasmoidId); + root.plasmoidTriggered(model.applet, model.plasmoidId); } else if (delegateRoot.toggle) { delegateRoot.toggle(); } else if (model.toggleFunction) { @@ -75,7 +75,7 @@ RowLayout { anchors.fill: parent onClicked: { if (model.plasmoidId > -1) { - root.plasmoidTriggered(model.plasmoidId); + root.plasmoidTriggered(model.applet, model.plasmoidId); } else if (model.settingsCommand) { plasmoid.nativeInterface.executeCommand(model.settingsCommand); } else if (model.toggleFunction) { diff --git a/containments/panel/package/contents/ui/quicksettings/QuickSettings.qml b/containments/panel/package/contents/ui/quicksettings/QuickSettings.qml index 41f2e48a..03fea5d1 100644 --- a/containments/panel/package/contents/ui/quicksettings/QuickSettings.qml +++ b/containments/panel/package/contents/ui/quicksettings/QuickSettings.qml @@ -30,75 +30,51 @@ Item { print("toggle airplane mode") } - function addPlasmoid(icon, text, id) { - settingsModel.append({"icon": icon, "text": text, "plasmoidId": id, "enabled": false}) + function addPlasmoid(applet, id) { + settingsModel.append({"icon": applet.icon, "text": applet.text, "plasmoidId": id, "enabled": false, "applet": applet}) } - signal plasmoidTriggered(var id) + signal plasmoidTriggered(var applet, var id) Layout.minimumHeight: flow.implicitHeight + units.largeSpacing*2 + //HACK: make the list know about the applet delegate which is a qtobject + QtObject { + id: nullApplet + } + Component.onCompleted: { + //NOTE: add all in javascript as the static decl of listelements can't have scripts + settingsModel.append({ + "text": i18n("Settings"), + "icon": "configure", + "enabled": false, + "settingsCommand": "plasma-settings", + "toggleFunction": "", + "delegate": "", + "plasmoidId": -1, + "enabled": false, + "applet": nullApplet + }); + + settingsModel.append({ + "text": i18n("Flashlight"), + "icon": "package_games_puzzle", + "enabled": false, + "settingsCommand": "", + "plasmoidId": -1, + "applet": null + }); + settingsModel.append({ + "text": i18n("Location"), + "icon": "plasmaapplet-location", + "enabled": false, + "settingsCommand": "", + "plasmoidId": -1, + "applet": null + }); + } + ListModel { id: settingsModel - - ListElement { - text: "Settings" - icon: "configure" - enabled: false - settingsCommand: "plasma-settings" - toggleFunction: "" - delegate: "" - plasmoidId: -1 - } - /* ListElement { - text: "Mobile network" - icon: "network-mobile-80" - enabled: true - settingsCommand: "" - plasmoidId: -1 - } - ListElement { - text: "Airplane mode" - icon: "flightmode-on" - enabled: false - settingsCommand: "" - toggleFunction: "toggleAirplane" - plasmoidId: -1 - } - ListElement { - text: "Bluetooth" - icon: "preferences-system-bluetooth" - enabled: false - settingsCommand: "" - plasmoidId: -1 - } - ListElement { - text: "Wireless" - icon: "network-wireless-on" - enabled: true - settingsCommand: "plasmawindowed org.kde.plasma.networkmanagement" - plasmoidId: -1 - } - ListElement { - text: "Alarms" - icon: "korgac" - enabled: false - settingsCommand: "ktimer" - plasmoidId: -1 - }*/ - ListElement { - text: "Flashlight" - icon: "package_games_puzzle" - enabled: false - settingsCommand: "" - plasmoidId: -1 - } - ListElement { - text: "Location" - icon: "plasmaapplet-location" - enabled: false - settingsCommand: "" - plasmoidId: -1 - } } Flow {