From 62ff6312db9e7b6154607daa65638e24092160d9 Mon Sep 17 00:00:00 2001 From: Marco Martin Date: Wed, 25 Feb 2015 19:26:04 +0100 Subject: [PATCH] add a containment it will replace most of the logic of Desktop.qml --- CMakeLists.txt | 1 + containments/CMakeLists.txt | 2 + .../homescreen/contents/ui/HomeLauncher.qml | 40 +++++ .../contents/ui/HomeLauncherSvg.qml | 33 ++++ .../contents/ui/SatelliteStripe.qml | 21 +++ containments/homescreen/contents/ui/main.qml | 144 ++++++++++++++++++ containments/homescreen/metadata.desktop | 17 +++ 7 files changed, 258 insertions(+) create mode 100644 containments/CMakeLists.txt create mode 100644 containments/homescreen/contents/ui/HomeLauncher.qml create mode 100644 containments/homescreen/contents/ui/HomeLauncherSvg.qml create mode 100644 containments/homescreen/contents/ui/SatelliteStripe.qml create mode 100644 containments/homescreen/contents/ui/main.qml create mode 100644 containments/homescreen/metadata.desktop diff --git a/CMakeLists.txt b/CMakeLists.txt index 644ee2fb..ea29df30 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,3 +42,4 @@ add_subdirectory(bin) add_subdirectory(qmlcomponents) add_subdirectory(services) add_subdirectory(settingsmodules) +add_subdirectory(containments) diff --git a/containments/CMakeLists.txt b/containments/CMakeLists.txt new file mode 100644 index 00000000..7e680eeb --- /dev/null +++ b/containments/CMakeLists.txt @@ -0,0 +1,2 @@ + +plasma_install_package(homescreen org.kde.phone.homescreen) diff --git a/containments/homescreen/contents/ui/HomeLauncher.qml b/containments/homescreen/contents/ui/HomeLauncher.qml new file mode 100644 index 00000000..6e9d143e --- /dev/null +++ b/containments/homescreen/contents/ui/HomeLauncher.qml @@ -0,0 +1,40 @@ +import QtQuick 2.0 +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.kio 1.0 as Kio +import org.kde.plasma.components 2.0 as PlasmaComponents + +MouseArea { + id: root + width: applicationsView.cellWidth + height: width + onClicked: { + console.log("Clicked: " + model.ApplicationStorageIdRole) + appListModel.runApplication(model.ApplicationStorageIdRole) + } + + PlasmaCore.IconItem { + id: icon + anchors.centerIn: parent + width: units.iconSizes.large + height: width + source: model.ApplicationIconRole + } + + PlasmaComponents.Label { + visible: text.length > 0 + + anchors { + top: icon.bottom + left: icon.left + right: icon.right + } + + wrapMode: Text.WordWrap + horizontalAlignment: Qt.AlignHCenter + verticalAlignment: Qt.AlignVCenter + + text: model.ApplicationNameRole + font.pixelSize: theme.smallestFont.pixelSize + color: PlasmaCore.ColorScope.textColor + } +} diff --git a/containments/homescreen/contents/ui/HomeLauncherSvg.qml b/containments/homescreen/contents/ui/HomeLauncherSvg.qml new file mode 100644 index 00000000..1b897900 --- /dev/null +++ b/containments/homescreen/contents/ui/HomeLauncherSvg.qml @@ -0,0 +1,33 @@ +import QtQuick 2.0 +import org.kde.plasma.core 2.0 as PlasmaCore + +Item { + id: root + width: parent.width / parent.columns + height: parent.buttonHeight + property var callback + property string text + property string sub + property alias svg: icon.svg + property alias elementId: icon.elementId + + PlasmaCore.SvgItem{ + id: icon + width: units.iconSizes.medium + height: width + anchors.centerIn: parent + } + + MouseArea { + anchors.fill: parent + propagateComposedEvents: true + + onClicked: { + if (callback) { + callback(); + } else { + addNumber(parent.text); + } + } + } +} diff --git a/containments/homescreen/contents/ui/SatelliteStripe.qml b/containments/homescreen/contents/ui/SatelliteStripe.qml new file mode 100644 index 00000000..813576f6 --- /dev/null +++ b/containments/homescreen/contents/ui/SatelliteStripe.qml @@ -0,0 +1,21 @@ +import QtQuick 2.0 +import org.kde.plasma.core 2.0 as PlasmaCore + +Item { + PlasmaCore.FrameSvgItem { + z: -1 + imagePath: "widgets/background" + enabledBorders: PlasmaCore.FrameSvgItem.TopBorder | PlasmaCore.FrameSvgItem.BottomBorder + anchors { + fill: parent + topMargin: -margins.top + bottomMargin: -margins.bottom + } + } + + opacity: 0.6 + height: Math.max(100, units.gridUnit * 2.5) + width: parent.width + y: parent.height / 2 - height / 2 + x: 0 +} diff --git a/containments/homescreen/contents/ui/main.qml b/containments/homescreen/contents/ui/main.qml new file mode 100644 index 00000000..64049843 --- /dev/null +++ b/containments/homescreen/contents/ui/main.qml @@ -0,0 +1,144 @@ +/* + * 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 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.satellite.components 0.1 as SatelliteComponents + +Item { + id: root + width: 640 + height: 480 + + property Item toolBox + property alias appletsSpace: applicationsView.headerItem + property int buttonHeight: width/4 + + Containment.onAppletAdded: { + var container = appletContainerComponent.createObject(appletsSpace) + container.visible = true + print("Applet added: " + applet) + applet.parent = container + container.applet = applet + applet.anchors.fill = applet.parent + applet.visible = true + container.width = 500 + container.height = 500 + } + + Component { + id: appletContainerComponent + Item { + property Item applet + } + } + + Rectangle { + color: Qt.rgba(0, 0, 0, 0.9 * (Math.min(applicationsView.contentY + root.height, root.height) / root.height)) + anchors.fill: parent + } + + PlasmaCore.ColorScope { + anchors.fill: parent + colorGroup: PlasmaCore.Theme.ComplementaryColorGroup + GridView { + id: applicationsView + anchors { + top: parent.top + bottom: parent.bottom + left: parent.left + right: parent.right + } + z: 1 + cellWidth: root.buttonHeight + cellHeight: cellWidth + model: SatelliteComponents.ApplicationListModel { + id: appListModel + } + snapMode: GridView.SnapToRow + //clip: true + delegate: HomeLauncher {} + header: MouseArea { + z: 999 + width: root.width + height: root.height - units.iconSizes.medium + + onPressAndHold: { + containment.action("configure").trigger(); + } + + /*SatelliteStripe { + id: stripe + z: 99 + y: Math.max(applications.contentY + parent.height, parent.height - height) + + PlasmaCore.Svg { + id: stripeIcons + imagePath: Qt.resolvedUrl("../images/homescreenicons.svg") + } + + Row { + anchors.fill: parent + property int columns: 4 + property alias buttonHeight: stripe.height + + HomeLauncherSvg { + id: phoneIcon + svg: stripeIcons + elementId: "phone" + callback: function() { + dialerOverlay.open() + } + } + + HomeLauncherSvg { + id: messagingIcon + svg: stripeIcons + elementId: "messaging" + callback: function() { console.log("Start messaging") } + } + + + HomeLauncherSvg { + id: emailIcon + svg: stripeIcons + elementId: "email" + callback: function() { console.log("Start email") } + } + + + HomeLauncherSvg { + id: webIcon + svg: stripeIcons + elementId: "web" + callback: function() { console.log("Start web") } + } + } + }*/ + } + } + } + + Component.onCompleted: { + print("root Containment loaded") + } +} \ No newline at end of file diff --git a/containments/homescreen/metadata.desktop b/containments/homescreen/metadata.desktop new file mode 100644 index 00000000..5dfc2c2d --- /dev/null +++ b/containments/homescreen/metadata.desktop @@ -0,0 +1,17 @@ +[Desktop Entry] +Encoding=UTF-8 +Keywords= +Name=Phone Homescreen +Type=Service + +X-KDE-ServiceTypes=Plasma/Applet,Plasma/Containment +X-Plasma-API=declarativeappletscript +X-KDE-ParentApp= +X-KDE-PluginInfo-Author=Marco Martin +X-KDE-PluginInfo-Category= +X-KDE-PluginInfo-Email=mart@kde.org +X-KDE-PluginInfo-License=GPLv2+ +X-KDE-PluginInfo-Name=org.kde.phone.homescreen +X-KDE-PluginInfo-Version= +X-KDE-PluginInfo-Website= +X-Plasma-MainScript=ui/main.qml