From 8d2cf69972823953b6f182c50c3b8d4866b52342 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Mon, 7 Oct 2019 18:49:18 +0200 Subject: [PATCH] most icons are not plasmoids anymore show plasmoids full rep in a flickable under quicksettings --- .../package/contents/applet/CompactApplet.qml | 84 ++++++++++++++ .../contents/ui/indicators/Battery.qml | 56 +++++++++ .../contents/ui/indicators/Bluetooth.qml | 62 ++++++++++ .../contents/ui/indicators/Indicator.qml | 44 +++++++ .../package/contents/ui/indicators/Wifi.qml | 52 +++++++++ .../panel/package/contents/ui/main.qml | 108 +++++++++++++----- shell/contents/layout.js | 8 +- 7 files changed, 380 insertions(+), 34 deletions(-) create mode 100644 containments/panel/package/contents/applet/CompactApplet.qml create mode 100644 containments/panel/package/contents/ui/indicators/Battery.qml create mode 100644 containments/panel/package/contents/ui/indicators/Bluetooth.qml create mode 100644 containments/panel/package/contents/ui/indicators/Indicator.qml create mode 100644 containments/panel/package/contents/ui/indicators/Wifi.qml diff --git a/containments/panel/package/contents/applet/CompactApplet.qml b/containments/panel/package/contents/applet/CompactApplet.qml new file mode 100644 index 00000000..f7a5f67e --- /dev/null +++ b/containments/panel/package/contents/applet/CompactApplet.qml @@ -0,0 +1,84 @@ +/* + * Copyright 2011 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.plasmoid 2.0 + + +PlasmaCore.ToolTipArea { + id: appletRoot + objectName: "org.kde.desktop-CompactApplet" + anchors.fill: parent + + icon: plasmoid.icon + mainText: plasmoid.toolTipMainText + subText: plasmoid.toolTipSubText + location: if (plasmoid.parent && plasmoid.parent.parent.objectName === "hiddenTasksColumn" && plasmoid.location !== PlasmaCore.Types.LeftEdge) { + return PlasmaCore.Types.RightEdge; + } else { + return plasmoid.location; + } + active: !plasmoid.expanded + textFormat: plasmoid.toolTipTextFormat + mainItem: plasmoid.toolTipItem ? plasmoid.toolTipItem : null + + property Item fullRepresentation + property Item compactRepresentation + + Connections { + target: plasmoid + onContextualActionsAboutToShow: appletRoot.hideToolTip() + } + + + + Layout.minimumWidth: { + switch (plasmoid.formFactor) { + case PlasmaCore.Types.Vertical: + return 0; + case PlasmaCore.Types.Horizontal: + return height; + default: + return units.gridUnit * 3; + } + } + + Layout.minimumHeight: { + switch (plasmoid.formFactor) { + case PlasmaCore.Types.Vertical: + return width; + case PlasmaCore.Types.Horizontal: + return 0; + default: + return units.gridUnit * 3; + } + } + + onCompactRepresentationChanged: { + if (compactRepresentation) { + compactRepresentation.parent = appletRoot; + compactRepresentation.anchors.fill = appletRoot; + compactRepresentation.visible = true; + } + appletRoot.visible = true; + } +} + diff --git a/containments/panel/package/contents/ui/indicators/Battery.qml b/containments/panel/package/contents/ui/indicators/Battery.qml new file mode 100644 index 00000000..4e1dc9f6 --- /dev/null +++ b/containments/panel/package/contents/ui/indicators/Battery.qml @@ -0,0 +1,56 @@ +/* + * Copyright 2019 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.6 +import QtQuick.Layouts 1.4 + +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.components 3.0 as PlasmaComponents +import org.kde.plasma.workspace.components 2.0 as PW + + +RowLayout { + visible: pmSource.data["Battery"]["Has Cumulative"] + + PW.BatteryIcon { + id: battery + Layout.preferredWidth: height + Layout.fillHeight: true + hasBattery: true + percent: pmSource.data["Battery"]["Percent"] + pluggedIn: pmSource.data["AC Adapter"] ? pmSource.data["AC Adapter"]["Plugged in"] : false + + height: batteryLabel.height + width: batteryLabel.height + + PlasmaCore.DataSource { + id: pmSource + engine: "powermanagement" + connectedSources: ["Battery", "AC Adapter"] + } + } + + PlasmaComponents.Label { + id: batteryLabel + text: i18n("%1%", battery.percent) + Layout.alignment: Qt.AlignVCenter + + color: PlasmaCore.ColorScope.textColor + font.pixelSize: parent.height / 2 + } +} diff --git a/containments/panel/package/contents/ui/indicators/Bluetooth.qml b/containments/panel/package/contents/ui/indicators/Bluetooth.qml new file mode 100644 index 00000000..b0d01540 --- /dev/null +++ b/containments/panel/package/contents/ui/indicators/Bluetooth.qml @@ -0,0 +1,62 @@ +/* + Copyright 2019 MArco MArtni + Copyright 2013-2017 Jan Grulich + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) version 3, or any + later version accepted by the membership of KDE e.V. (or its + successor approved by the membership of KDE e.V.), which shall + act as a proxy defined in Section 6 of version 3 of the license. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library. If not, see . +*/ + +import QtQuick 2.2 +import QtQuick.Layouts 1.4 +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.components 2.0 as PlasmaComponents +import org.kde.bluezqt 1.0 as BluezQt + +PlasmaCore.IconItem { + id: connectionIcon + + property bool deviceConnected : false + + source: deviceConnected ? "preferences-system-bluetooth-activated" : "preferences-system-bluetooth"; + colorGroup: PlasmaCore.ColorScope.colorGroup + + visible: BluezQt.Manager.bluetoothOperational + + Layout.fillHeight: true + Layout.preferredWidth: height + function updateStatus() + { + var connectedDevices = []; + + for (var i = 0; i < BluezQt.Manager.devices.length; ++i) { + var device = BluezQt.Manager.devices[i]; + if (device.connected) { + connectedDevices.push(device); + } + } + deviceConnected = connectedDevices.length > 0; + } + + Component.onCompleted: { + BluezQt.Manager.deviceAdded.connect(updateStatus); + BluezQt.Manager.deviceRemoved.connect(updateStatus); + BluezQt.Manager.deviceChanged.connect(updateStatus); + BluezQt.Manager.bluetoothBlockedChanged.connect(updateStatus); + BluezQt.Manager.bluetoothOperationalChanged.connect(updateStatus); + + updateStatus(); + } +} diff --git a/containments/panel/package/contents/ui/indicators/Indicator.qml b/containments/panel/package/contents/ui/indicators/Indicator.qml new file mode 100644 index 00000000..5710c5ee --- /dev/null +++ b/containments/panel/package/contents/ui/indicators/Indicator.qml @@ -0,0 +1,44 @@ +/* + * Copyright 2019 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.6 +import QtQuick.Layouts 1.4 + +import org.kde.plasma.plasmoid 2.0 +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.components 3.0 as PlasmaComponents + + +RowLayout { + + property alias icon: icon.source + property alias text: label.text + PlasmaCore.IconItem { + id: icon + colorGroup: PlasmaCore.ColorScope.colorGroup + + Layout.fillHeight: true + Layout.preferredWidth: height + } + PlasmaComponents.Label { + id: label + visible: text.length > 0 + color: PlasmaCore.ColorScope.textColor + font.pixelSize: parent.height / 2 + } +} diff --git a/containments/panel/package/contents/ui/indicators/Wifi.qml b/containments/panel/package/contents/ui/indicators/Wifi.qml new file mode 100644 index 00000000..a01c38b8 --- /dev/null +++ b/containments/panel/package/contents/ui/indicators/Wifi.qml @@ -0,0 +1,52 @@ +/* + Copyright 2019 MArco MArtni + Copyright 2013-2017 Jan Grulich + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) version 3, or any + later version accepted by the membership of KDE e.V. (or its + successor approved by the membership of KDE e.V.), which shall + act as a proxy defined in Section 6 of version 3 of the license. + + This library 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 + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with this library. If not, see . +*/ + +import QtQuick 2.2 +import QtQuick.Layouts 1.4 +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.components 2.0 as PlasmaComponents +import org.kde.plasma.networkmanagement 0.2 as PlasmaNM + +PlasmaCore.IconItem { + id: connectionIcon + + source: connectionIconProvider.connectionIcon + colorGroup: PlasmaCore.ColorScope.colorGroup + + Layout.fillHeight: true + Layout.preferredWidth: height + + PlasmaComponents.BusyIndicator { + id: connectingIndicator + + anchors.fill: parent + running: connectionIconProvider.connecting + visible: running + } + + PlasmaNM.NetworkStatus { + id: networkStatus + } + + PlasmaNM.ConnectionIcon { + id: connectionIconProvider + } +} diff --git a/containments/panel/package/contents/ui/main.qml b/containments/panel/package/contents/ui/main.qml index 69ac1c85..5e13db41 100644 --- a/containments/panel/package/contents/ui/main.qml +++ b/containments/panel/package/contents/ui/main.qml @@ -29,6 +29,7 @@ import org.kde.taskmanager 0.1 as TaskManager import "LayoutManager.js" as LayoutManager import "quicksettings" +import "indicators" as Indicators PlasmaCore.ColorScope { id: root @@ -51,28 +52,25 @@ PlasmaCore.ColorScope { } function addApplet(applet, x, y) { - var container = appletContainerComponent.createObject(appletIconsRow) + var compactContainer = compactContainerComponent.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.parent = compactContainer; + compactContainer.applet = applet; + applet.anchors.fill = compactContainer; 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 - applet.switchWidth = -1; - applet.switchHeight = -1; + } + //FIXME: make a way to instantiate fullRepresentationItem without the open/close dance + applet.expanded = true + applet.expanded = false + + var fullContainer = fullContainerComponent.createObject(fullRepresentationsLayout); + fullContainer.parent = fullRepresentationsLayout; + applet.fullRepresentationItem.parent = fullContainer; + fullContainer.applet = applet; + applet.fullRepresentationItem.anchors.fill = fullContainer; } Component.onCompleted: { @@ -109,17 +107,32 @@ PlasmaCore.ColorScope { Layout.minimumHeight: Math.max(root.height, Math.round(Layout.preferredHeight / root.height) * root.height) } + //todo: REMOVE? Component { - id: appletContainerComponent + id: compactContainerComponent Item { - //not used yet - property bool animationsEnabled: false property Item applet + visible: applet && (applet.status != PlasmaCore.Types.HiddenStatus && applet.status != PlasmaCore.Types.PassiveStatus) Layout.fillHeight: true Layout.minimumWidth: applet && applet.compactRepresentationItem ? Math.max(applet.compactRepresentationItem.Layout.minimumWidth, appletIconsRow.height) : appletIconsRow.height Layout.maximumWidth: Layout.minimumWidth } } + Component { + id: fullContainerComponent + Item { + property Item applet + visible: applet && (applet.status != PlasmaCore.Types.HiddenStatus && applet.status != PlasmaCore.Types.PassiveStatus) + Layout.fillHeight: true + Layout.minimumWidth: fullRepresentationsView.width + Layout.minimumHeight: applet && applet.switchHeight + onVisibleChanged: { + if (visible) { + fullRepresentationsView.setCurrentItem(this); + } + } + } + } PlasmaCore.DataSource { id: timeSource @@ -183,10 +196,24 @@ PlasmaCore.ColorScope { id: appletIconsRow anchors { bottom: parent.bottom - right: parent.right + right: simpleIndicatorsLayout.left } height: parent.height } + + //TODO: pluggable + RowLayout { + id: simpleIndicatorsLayout + anchors { + top: parent.top + bottom: parent.bottom + right: parent.right + rightMargin: units.smallSpacing + } + Indicators.Bluetooth {} + Indicators.Wifi {} + Indicators.Battery {} + } } MouseArea { z: 99 @@ -239,14 +266,39 @@ PlasmaCore.ColorScope { } y: quickSettingsParent.height - height * (1-opacity) opacity: slidingPanel.offset/panelContents.height - contentItem: Item { - id: notificationsParent + height: Math.min(plasmoid.screenGeometry.height - quickSettingsParent.y - quickSettingsParent.height, implicitHeight) + contentItem: Flickable { + id: fullRepresentationsView - property var applet - implicitHeight: applet ? applet.fullRepresentationItem.Layout.maximumHeight : 0 - property int minimumHeight: applet ? applet.fullRepresentationItem.Layout.minimumHeight : 0 - - //TODO implicitHeight: applet ? applet.switchHeight : 0 + property Item currentItem + onCurrentItemChanged: { + if (currentItem) { + contentX = currentItem.x + } else { + currentItem = children[0]; + } + } + + function setCurrentItem(item) { + currentItem = item; + currentItemChanged(); + } + onMovementEnded: setCurrentItem(fullRepresentationsLayout.childAt(contentX + width/2, 1)) + contentWidth: fullRepresentationsLayout.width + contentHeight: height + implicitHeight: fullRepresentationsLayout.implicitHeight + clip: true + Behavior on contentX { + NumberAnimation { + duration: units.longDuration + easing: easing.InOutQuad + } + } + + RowLayout { + id: fullRepresentationsLayout + spacing: 0 + } } } } diff --git a/shell/contents/layout.js b/shell/contents/layout.js index 4dd0b734..63aa3b2e 100644 --- a/shell/contents/layout.js +++ b/shell/contents/layout.js @@ -6,12 +6,8 @@ for (var j = 0; j < desktopsArray.length; j++) { var panel = new Panel("org.kde.phone.panel"); panel.addWidget("org.kde.phone.notifications"); -panel.addWidget("org.kde.plasma.networkmanagement"); -var battery = panel.addWidget("org.kde.plasma.battery"); -battery.writeConfig("showPercentage", true); -battery.reloadConfig(); -panel.addWidget("org.kde.plasma.volume"); -panel.addWidget("org.kde.phone.activities"); +panel.addWidget("org.kde.plasma.mediacontroller"); +panel.addWidget("org.kde.plasma.devicenotifier"); panel.height = 1 * gridUnit; var bottomPanel = new Panel("org.kde.phone.taskpanel");