diff --git a/containments/CMakeLists.txt b/containments/CMakeLists.txt index cb99c20e..a1915629 100644 --- a/containments/CMakeLists.txt +++ b/containments/CMakeLists.txt @@ -1,5 +1,4 @@ -plasma_install_package(panel org.kde.phone.panel) - +add_subdirectory(panel) add_subdirectory(homescreen) add_subdirectory(taskpanel) diff --git a/containments/panel/CMakeLists.txt b/containments/panel/CMakeLists.txt new file mode 100644 index 00000000..c6a5a2e1 --- /dev/null +++ b/containments/panel/CMakeLists.txt @@ -0,0 +1,19 @@ +set(phonepanel_SRCS + phonepanel.cpp +) + +add_library(plasma_applet_phonepanel MODULE ${phonepanel_SRCS}) + +kcoreaddons_desktop_to_json(plasma_applet_phonepanel package/metadata.desktop) + +target_link_libraries(plasma_applet_phonepanel + Qt5::Gui + KF5::Plasma + KF5::I18n) + + +install(TARGETS plasma_applet_phonepanel DESTINATION ${KDE_INSTALL_PLUGINDIR}/plasma/applets) +#install(FILES plasma-phonepanel-default.desktop DESTINATION ${SERVICES_INSTALL_DIR}) + +plasma_install_package(package org.kde.phone.panel) + diff --git a/containments/panel/contents/code/LayoutManager.js b/containments/panel/package/contents/code/LayoutManager.js similarity index 100% rename from containments/panel/contents/code/LayoutManager.js rename to containments/panel/package/contents/code/LayoutManager.js diff --git a/containments/panel/contents/config/main.xml b/containments/panel/package/contents/config/main.xml similarity index 100% rename from containments/panel/contents/config/main.xml rename to containments/panel/package/contents/config/main.xml diff --git a/containments/panel/contents/ui/SignalStrength.qml b/containments/panel/package/contents/ui/SignalStrength.qml similarity index 100% rename from containments/panel/contents/ui/SignalStrength.qml rename to containments/panel/package/contents/ui/SignalStrength.qml diff --git a/containments/panel/contents/ui/SlidingPanel.qml b/containments/panel/package/contents/ui/SlidingPanel.qml similarity index 96% rename from containments/panel/contents/ui/SlidingPanel.qml rename to containments/panel/package/contents/ui/SlidingPanel.qml index 592ebcce..e5d2c09c 100644 --- a/containments/panel/contents/ui/SlidingPanel.qml +++ b/containments/panel/package/contents/ui/SlidingPanel.qml @@ -30,6 +30,7 @@ FullScreenPanel { property int offset: 0 property int peekHeight property bool userInteracting: false + property bool expanded: false color: "transparent" property alias contents: contentArea.data @@ -47,7 +48,9 @@ FullScreenPanel { closeAnim.running = true; } function updateState() { - if (offset < peekHeight / 2) { + if (expanded) { + openAnim.running = true; + } else if (offset < peekHeight / 2) { close(); } else if (offset < peekHeight) { open(); @@ -70,6 +73,8 @@ FullScreenPanel { window.width = Screen.width; window.height = Screen.height; window.requestActivate(); + } else { + window.expanded = false; } } SequentialAnimation { @@ -130,6 +135,7 @@ FullScreenPanel { Flickable { id: mainFlickable anchors.fill: parent + interactive: !window.expanded Binding { target: mainFlickable property: "contentY" diff --git a/containments/panel/contents/ui/TaskWidget.qml b/containments/panel/package/contents/ui/TaskWidget.qml similarity index 100% rename from containments/panel/contents/ui/TaskWidget.qml rename to containments/panel/package/contents/ui/TaskWidget.qml diff --git a/containments/panel/contents/ui/main.qml b/containments/panel/package/contents/ui/main.qml similarity index 68% rename from containments/panel/contents/ui/main.qml rename to containments/panel/package/contents/ui/main.qml index cf215ef3..f3fd1c19 100644 --- a/containments/panel/contents/ui/main.qml +++ b/containments/panel/package/contents/ui/main.qml @@ -17,7 +17,7 @@ */ import QtQuick 2.1 -import QtQuick.Layouts 1.1 +import QtQuick.Layouts 1.3 import org.kde.plasma.plasmoid 2.0 import org.kde.plasma.core 2.0 as PlasmaCore @@ -27,6 +27,8 @@ import org.kde.plasma.workspace.components 2.0 as PlasmaWorkspace import "LayoutManager.js" as LayoutManager +import "quicksettings" + PlasmaCore.ColorScope { id: root width: 480 @@ -44,13 +46,6 @@ PlasmaCore.ColorScope { } function addApplet(applet, x, y) { - if (applet.pluginName == "org.kde.phone.quicksettings") { - applet.parent = quickSettingsParent; - quickSettingsParent.applet = applet; - applet.anchors.fill = quickSettingsParent; - applet.visible = true; - return; - } var container = appletContainerComponent.createObject(appletIconsRow) print("Applet added: " + applet + " " + applet.title) container.width = units.iconSizes.medium @@ -65,6 +60,13 @@ PlasmaCore.ColorScope { applet.fullRepresentationItem.parent = notificationsParent; notificationsParent.applet = applet; applet.fullRepresentationItem.anchors.fill = notificationsParent; + } else if (applet.pluginName != "org.kde.phone.quicksettings") { + applet.expanded = true + applet.expanded = false + quickSettings.addPlasmoid(applet.icon, applet.title, fullRepsLayout.count); + applet.fullRepresentationItem.parent = fullRepsLayout; + fullRepsLayout.currentIndex = 0 + applet.fullRepresentationItem.anchors.fill = fullRepsLayout; } } @@ -206,22 +208,32 @@ PlasmaCore.ColorScope { 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: quickSettingsParent.height + notificationsParent.height + root.height + 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 - anchors { - left: parent.left - right: parent.right - } + width: parent.width + x: -modeFlick.contentX y: Math.min(0, slidingPanel.offset - height - root.height) - property var applet - height: applet ? applet.fullRepresentationItem.Layout.minimumHeight : 0 + height: quickSettings.Layout.minimumHeight + QuickSettings { + id: quickSettings + anchors.fill: parent + onPlasmoidTriggered: { + fullRepsLayout.currentIndex = id; + slidingPanel.expanded = true; + } + } Rectangle { anchors { left: parent.left @@ -234,17 +246,54 @@ PlasmaCore.ColorScope { visible: slidingPanel.offset + slidingPanel.headerHeight < panelContents.height } } - Item { - id: notificationsParent - anchors { - left: parent.left - bottom: parent.bottom - right: parent.right - bottomMargin: root.height + PropertyAnimation { + id: modeSwitchAnim + target: modeFlick + duration: units.longDuration + easing.type: Easing.InOutQuad + properties: "contentX" + from: modeFlick.contentX + to: 0 + } + Flickable { + id: modeFlick + anchors.fill: parent + contentWidth: width * 2 + contentHeight: height + boundsBehavior: Flickable.StopAtBounds + interactive: slidingPanel.expanded + onFlickEnded: movementEnded() + onMovementEnded: { + slidingPanel.expanded = (contentX > panelContents.width/2); + modeSwitchAnim.running = false; + modeSwitchAnim.to = slidingPanel.expanded ? width : 0 + modeSwitchAnim.running = true; + } + Item { + width: modeFlick.width + height: modeFlick.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 + } + StackLayout { + id: fullRepsLayout + anchors { + left: notificationsParent.right + bottom: parent.bottom + } + width: panelContents.width + height: panelContents.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/Delegate.qml b/containments/panel/package/contents/ui/quicksettings/Delegate.qml new file mode 100644 index 00000000..3db8a7f6 --- /dev/null +++ b/containments/panel/package/contents/ui/quicksettings/Delegate.qml @@ -0,0 +1,89 @@ +/* + * 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 + +RowLayout { + id: delegateRoot + property bool toggled: model.enabled + spacing: units.smallSpacing + implicitWidth: flow.width / 2 - units.largeSpacing / 2 + Rectangle { + Layout.minimumWidth: units.iconSizes.medium + Layout.minimumHeight: width + color: toggled ? + Qt.rgba(PlasmaCore.ColorScope.highlightColor.r, PlasmaCore.ColorScope.highlightColor.g, PlasmaCore.ColorScope.highlightColor.b, iconMouseArea.pressed ? 0.5 : 0.3) : + Qt.rgba(PlasmaCore.ColorScope.textColor.r, PlasmaCore.ColorScope.textColor.g, PlasmaCore.ColorScope.textColor.b, iconMouseArea.pressed ? 0.5 : 0.2) + + PlasmaCore.IconItem { + colorGroup: PlasmaCore.ColorScope.colorGroup + anchors { + fill: parent + margins: units.smallSpacing + } + source: model.icon + MouseArea { + id: iconMouseArea + anchors.fill: parent + onClicked: { + if (model.plasmoidId > -1) { + root.plasmoidTriggered(model.plasmoidId); + } else if (delegateRoot.toggle) { + delegateRoot.toggle(); + } else if (model.toggleFunction) { + root[model.toggleFunction](); + } else if (model.settingsCommand) { + plasmoid.nativeInterface.executeCommand(model.settingsCommand); + } + } + } + } + } + Rectangle { + Layout.fillWidth: true + Layout.fillHeight: true + color: Qt.rgba(PlasmaCore.ColorScope.textColor.r, PlasmaCore.ColorScope.textColor.g, PlasmaCore.ColorScope.textColor.b, labelMouseArea.pressed ? 0.5 : 0.2) + PlasmaComponents.Label { + anchors { + fill: parent + margins: units.smallSpacing + } + text: model.text + elide: Text.ElideRight + verticalAlignment: Text.AlignVCenter + MouseArea { + id: labelMouseArea + anchors.fill: parent + onClicked: { + if (model.plasmoidId > -1) { + root.plasmoidTriggered(model.plasmoidId); + } else if (model.settingsCommand) { + plasmoid.nativeInterface.executeCommand(model.settingsCommand); + } else if (model.toggleFunction) { + root[model.toggleFunction](); + } + } + } + } + } +} + diff --git a/containments/panel/package/contents/ui/quicksettings/QuickSettings.qml b/containments/panel/package/contents/ui/quicksettings/QuickSettings.qml new file mode 100644 index 00000000..3830f8f8 --- /dev/null +++ b/containments/panel/package/contents/ui/quicksettings/QuickSettings.qml @@ -0,0 +1,181 @@ +/* + * 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 addPlasmoid(icon, text, id) { + settingsModel.append({"icon": icon, "text": text, "plasmoidId": id, "enabled": false}) + } + + signal plasmoidTriggered(var id) + Layout.minimumHeight: flow.implicitHeight + units.largeSpacing*2 + + property int screenBrightness + readonly property int maximumScreenBrightness: pmSource.data["PowerDevil"] ? pmSource.data["PowerDevil"]["Maximum Screen Brightness"] || 0 : 0 + onScreenBrightnessChanged: { + 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: { + root.screenBrightness = pmSource.data["PowerDevil"]["Screen Brightness"]; + } + } + + 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 { + id: flow + anchors { + fill: parent + margins: units.largeSpacing + } + spacing: units.largeSpacing + Repeater { + model: settingsModel + delegate: Loader { + width: 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" + } + } + RowLayout { + width: flow.width + PlasmaCore.IconItem { + Layout.preferredWidth: units.iconSizes.small + Layout.preferredHeight: Layout.preferredWidth + //TODO: needs brightness + source: "contrast" + } + PlasmaComponents.Slider { + id: brightnessSlider + Layout.fillWidth: true + value: root.screenBrightness + onValueChanged: { + if (pressed) { + root.screenBrightness = value + } + } + minimumValue: maximumValue > 100 ? 1 : 0 + maximumValue: root.maximumScreenBrightness + stepSize: 1 + } + PlasmaCore.IconItem { + Layout.preferredWidth: units.iconSizes.small + Layout.preferredHeight: Layout.preferredWidth + //TODO: needs brightness + source: "contrast" + } + } + } +} diff --git a/containments/panel/metadata.desktop b/containments/panel/package/metadata.desktop similarity index 96% rename from containments/panel/metadata.desktop rename to containments/panel/package/metadata.desktop index aca367ce..6fb00f27 100644 --- a/containments/panel/metadata.desktop +++ b/containments/panel/package/metadata.desktop @@ -28,6 +28,7 @@ X-KDE-PluginInfo-Author=Marco Martin X-KDE-PluginInfo-Category=Containments X-KDE-PluginInfo-Email=mart@kde.org X-KDE-PluginInfo-License=GPLv2+ +X-KDE-Library=plasma_applet_phonepanel X-KDE-PluginInfo-Name=org.kde.phone.panel X-KDE-PluginInfo-Version= X-KDE-PluginInfo-Website= diff --git a/containments/panel/phonepanel.cpp b/containments/panel/phonepanel.cpp new file mode 100644 index 00000000..9ba98d82 --- /dev/null +++ b/containments/panel/phonepanel.cpp @@ -0,0 +1,43 @@ +/*************************************************************************** + * Copyright (C) 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 02110-1301 USA . * + ***************************************************************************/ + +#include "phonepanel.h" + +#include +#include + +PhonePanel::PhonePanel(QObject *parent, const QVariantList &args) + : Plasma::Containment(parent, args) +{ + //setHasConfigurationInterface(true); +} + +PhonePanel::~PhonePanel() +{ +} + +void PhonePanel::executeCommand(const QString &command) +{ + qWarning()<<"Executing"< * + * + * * + * 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 02110-1301 USA . * + ***************************************************************************/ + +#ifndef PHONEPANEL_H +#define PHONEPANEL_H + + +#include + + +class PhonePanel : public Plasma::Containment +{ + Q_OBJECT + +public: + PhonePanel( QObject *parent, const QVariantList &args ); + ~PhonePanel(); + +public Q_SLOTS: + void executeCommand(const QString &command); + +private: + +}; + +#endif