diff --git a/containments/panel/package/contents/ui/main.qml b/containments/panel/package/contents/ui/main.qml index 68d6510..23b94cf 100644 --- a/containments/panel/package/contents/ui/main.qml +++ b/containments/panel/package/contents/ui/main.qml @@ -1,246 +1,245 @@ /* * Copyright 2015 Marco Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 2.010-1301, USA. */ import QtQuick 2.1 import QtQuick.Layouts 1.3 import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents import org.kde.plasma.workspace.components 2.0 as PlasmaWorkspace import "LayoutManager.js" as LayoutManager import "quicksettings" PlasmaCore.ColorScope { id: root width: 480 height: 640 colorGroup: PlasmaCore.Theme.ComplementaryColorGroup property Item toolBox property int buttonHeight: width/4 property bool reorderingApps: false property var layoutManager: LayoutManager Containment.onAppletAdded: { addApplet(applet, x, y); LayoutManager.save(); } function addApplet(applet, x, y) { var container = appletContainerComponent.createObject(appletIconsRow) print("Applet added: " + applet + " " + applet.title) container.width = units.iconSizes.medium container.height = container.height applet.parent = container; container.applet = applet; applet.anchors.fill = container; applet.visible = true; container.visible = true; if (applet.pluginName == "org.kde.phone.notifications") { //FIXME: make a way to instantiate fullRepresentationItem without the open/close dance applet.expanded = true applet.expanded = false applet.fullRepresentationItem.parent = notificationsParent; notificationsParent.applet = applet; applet.fullRepresentationItem.anchors.fill = notificationsParent; } else { applet.preferredRepresentation = applet.compactRepresentation - quickSettings.addPlasmoid(applet); } } Component.onCompleted: { LayoutManager.plasmoid = plasmoid; LayoutManager.root = root; LayoutManager.layout = appletsLayout; LayoutManager.restore(); } PlasmaCore.DataSource { id: statusNotifierSource engine: "statusnotifieritem" interval: 0 onSourceAdded: { connectSource(source) } Component.onCompleted: { connectedSources = sources } } RowLayout { id: appletsLayout Layout.minimumHeight: Math.max(root.height, Math.round(Layout.preferredHeight / root.height) * root.height) } Component { id: appletContainerComponent Item { //not used yet property bool animationsEnabled: false property Item applet Layout.fillHeight: true Layout.minimumWidth: applet && applet.compactRepresentationItem ? Math.max(applet.compactRepresentationItem.Layout.minimumWidth, appletIconsRow.height) : appletIconsRow.height Layout.maximumWidth: Layout.minimumWidth } } PlasmaCore.DataSource { id: timeSource engine: "time" connectedSources: ["Local"] interval: 60 * 1000 } Rectangle { z: 1 parent: slidingPanel.visible ? panelContents : root anchors { left: parent.left right: parent.right bottom: parent.bottom } height: root.height color: PlasmaCore.ColorScope.backgroundColor Loader { id: strengthLoader height: parent.height width: item ? item.width : 0 source: Qt.resolvedUrl("SignalStrength.qml") } Row { id: sniRow anchors.left: strengthLoader.right height: parent.height Repeater { id: statusNotifierRepeater model: PlasmaCore.SortFilterModel { id: filteredStatusNotifiers filterRole: "Title" sourceModel: PlasmaCore.DataModel { dataSource: statusNotifierSource } } delegate: TaskWidget { } } } PlasmaComponents.Label { id: clock anchors.fill: parent text: Qt.formatTime(timeSource.data.Local.DateTime, "hh:mm") color: PlasmaCore.ColorScope.textColor horizontalAlignment: Qt.AlignHCenter verticalAlignment: Qt.AlignVCenter font.pixelSize: height / 2 } RowLayout { id: appletIconsRow anchors { bottom: parent.bottom right: parent.right } height: parent.height } } MouseArea { z: 99 property int oldMouseY: 0 anchors.fill: parent onPressed: { slidingPanel.userInteracting = true; oldMouseY = mouse.y; slidingPanel.visible = true; } onPositionChanged: { //var factor = (mouse.y - oldMouseY > 0) ? (1 - Math.max(0, (slidingArea.y + slidingPanel.overShoot) / slidingPanel.overShoot)) : 1 var factor = 1; slidingPanel.offset = slidingPanel.offset + (mouse.y - oldMouseY) * factor; oldMouseY = mouse.y; } onReleased: { slidingPanel.userInteracting = false; slidingPanel.updateState(); } } SlidingPanel { id: slidingPanel width: plasmoid.availableScreenRect.width height: plasmoid.availableScreenRect.height peekHeight: quickSettingsParent.height + notificationsParent.minimumHeight + root.height headerHeight: root.height onExpandedChanged: { modeSwitchAnim.running = false; modeSwitchAnim.to = expanded ? width : 0 modeSwitchAnim.running = true; } contents: Item { id: panelContents anchors.fill: parent implicitHeight: slidingPanel.expanded ? (slidingPanel.height-slidingPanel.headerHeight)*0.8 : (quickSettingsParent.height + notificationsParent.height + root.height) Rectangle { id: quickSettingsParent parent: slidingPanel.fixedArea color: PlasmaCore.ColorScope.backgroundColor z: 2 width: parent.width y: Math.min(0, slidingPanel.offset - height - root.height) height: quickSettings.Layout.minimumHeight QuickSettings { id: quickSettings anchors.fill: parent } Rectangle { anchors { left: parent.left right: parent.right bottom:parent.bottom } height: units.devicePixelRatio color: PlasmaCore.ColorScope.textColor opacity: 0.2 visible: slidingPanel.offset + slidingPanel.headerHeight < panelContents.height } } Item { id: notificationsParent anchors { left: parent.left bottom: parent.bottom right: parent.right bottomMargin: root.height } property var applet height: applet ? applet.fullRepresentationItem.Layout.maximumHeight : 0 property int minimumHeight: applet ? applet.fullRepresentationItem.Layout.minimumHeight : 0 } } } } diff --git a/containments/panel/package/contents/ui/quicksettings/QuickSettings.qml b/containments/panel/package/contents/ui/quicksettings/QuickSettings.qml index 593b8d8..42ef704 100644 --- a/containments/panel/package/contents/ui/quicksettings/QuickSettings.qml +++ b/containments/panel/package/contents/ui/quicksettings/QuickSettings.qml @@ -1,177 +1,216 @@ /* * Copyright 2015 Marco Martin * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Library General Public License as * published by the Free Software Foundation; either version 2, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Library General Public License for more details * * You should have received a copy of the GNU Library General Public * License along with this program; if not, write to the * Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ import QtQuick 2.1 import QtQuick.Layouts 1.1 import org.kde.plasma.core 2.0 as PlasmaCore import org.kde.plasma.components 2.0 as PlasmaComponents Item { id: root function toggleAirplane() { print("toggle airplane mode") } function toggleTorch() { plasmoid.nativeInterface.toggleTorch() } function requestShutdown() { print("Shutdown requested, depends on ksmserver running"); var service = pmSource.serviceForSource("PowerDevil"); //note the strange camelCasing is intentional var operation = service.operationDescription("requestShutDown"); return service.startOperationCall(operation); } function addPlasmoid(applet) { settingsModel.append({"icon": applet.icon, "text": applet.title, "enabled": false, "applet": applet, "settingsCommand": "", "toggleFunction": ""}); } signal plasmoidTriggered(var applet, var id) Layout.minimumHeight: flow.implicitHeight + units.largeSpacing*2 property int screenBrightness property bool disableBrightnessUpdate: true readonly property int maximumScreenBrightness: pmSource.data["PowerDevil"] ? pmSource.data["PowerDevil"]["Maximum Screen Brightness"] || 0 : 0 onScreenBrightnessChanged: { if(!disableBrightnessUpdate) { var service = pmSource.serviceForSource("PowerDevil"); var operation = service.operationDescription("setBrightness"); operation.brightness = screenBrightness; operation.silent = true service.startOperationCall(operation); } } PlasmaCore.DataSource { id: pmSource engine: "powermanagement" connectedSources: ["PowerDevil"] onSourceAdded: { if (source === "PowerDevil") { disconnectSource(source); connectSource(source); } } onDataChanged: { disableBrightnessUpdate = true; root.screenBrightness = pmSource.data["PowerDevil"]["Screen Brightness"]; disableBrightnessUpdate = false; } } //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": "", "enabled": false, "applet": null }); - + settingsModel.append({ + "text": i18n("Wifi"), + "icon": "network-wireless-signal", + "enabled": false, + "settingsCommand": "plasma-settings -m kcm_mobile_wifi", + "toggleFunction": "", + "delegate": "", + "enabled": false, + "applet": null + }); + settingsModel.append({ + "text": i18n("Mobile Data"), + "icon": "network-modem", + "enabled": false, + "settingsCommand": "plasma-settings -m kcm_mobile_broadband", + "toggleFunction": "", + "delegate": "", + "enabled": false, + "applet": null + }); + settingsModel.append({ + "text": i18n("Battery"), + "icon": "battery", + "enabled": false, + "settingsCommand": "plasma-settings -m kcm_mobile_power", + "toggleFunction": "", + "delegate": "", + "enabled": false, + "applet": null + }); + settingsModel.append({ + "text": i18n("Sound"), + "icon": "audio-speakers-symbolic", + "enabled": false, + "settingsCommand": "plasma-settings -m kcm_pulseaudio", + "toggleFunction": "", + "delegate": "", + "enabled": false, + "applet": null + }); settingsModel.append({ "text": i18n("Flashlight"), - "icon": "package_games_puzzle", + "icon": "flashlight-on", "enabled": false, "settingsCommand": "", "toggleFunction": "toggleTorch", "applet": null }); settingsModel.append({ "text": i18n("Location"), "icon": "find-location-symbolic", "enabled": false, "settingsCommand": "", "applet": null }); if (plasmoid.configuration.ShowPowerButton) { settingsModel.append({ "text": i18n("Shutdown"), "icon": "system-shutdown-symbolic", "enabled": false, "settingsCommand": "", "toggleFunction": "requestShutdown", "plasmoidId": -1, "applet": null }); } brightnessSlider.moved.connect(function() { root.screenBrightness = brightnessSlider.value; }); disableBrightnessUpdate = false; } ListModel { id: settingsModel } Flow { id: flow anchors { fill: parent margins: units.largeSpacing } spacing: units.largeSpacing Repeater { model: settingsModel delegate: Loader { //FIXME: why this is needed? width: flow.width / 2 - units.largeSpacing / 2//item ? item.implicitWidth : 0 height: item ? item.implicitHeight : 0 source: Qt.resolvedUrl((model.delegate ? model.delegate : "Delegate") + ".qml") } } move: Transition { NumberAnimation { duration: units.shortDuration easing.type: Easing.InOutQuad properties: "x,y" } } BrightnessItem { id: brightnessSlider width: flow.width icon: "video-display-brightness" label: i18n("Display Brightness") value: root.screenBrightness maximumValue: root.maximumScreenBrightness Connections { target: root onScreenBrightnessChanged: brightnessSlider.value = root.screenBrightness } } } }