diff --git a/CMakeLists.txt b/CMakeLists.txt index 08b3764f..60d6f2ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,3 +48,4 @@ add_subdirectory(bin) add_subdirectory(qmlcomponents) add_subdirectory(services) add_subdirectory(settingsmodules) +add_subdirectory(containments) diff --git a/compositor/Compositor.qml b/compositor/Compositor.qml index df8d850e..b44f8f0e 100644 --- a/compositor/Compositor.qml +++ b/compositor/Compositor.qml @@ -154,8 +154,8 @@ Rectangle { anchors.left: parent.left anchors.right: parent.right anchors.bottom: parent.bottom - height: compositorRoot.state == "homeScreen" ? 0 : bottomBarHeight - color: Qt.rgba(0, 0, 0, 0.9 + 0.1*windowsZoom.scale) + height: bottomBarHeight + color: Qt.rgba(0, 0, 0, 0.9) Behavior on height { NumberAnimation { @@ -167,11 +167,32 @@ Rectangle { RowLayout { anchors.fill: parent + PlasmaCore.IconItem { + colorGroup: PlasmaCore.Theme.ComplementaryColorGroup + width: units.iconSizes.smallMedium + height: width + source: "distribute-horizontal-x" + enabled: compositorRoot.state != "switcher" && windowsLayout.children.length > 0 + opacity: enabled ? 1 : 0.2 + + Layout.alignment: Qt.AlignHCenter + Layout.preferredWidth: units.iconSizes.medium + Layout.preferredHeight: units.iconSizes.medium + + MouseArea { + anchors.fill: parent + onClicked: { + compositorRoot.state = "switcher"; + } + } + } PlasmaCore.IconItem { colorGroup: PlasmaCore.Theme.ComplementaryColorGroup width: units.iconSizes.smallMedium height: width source: "go-home" + enabled: compositorRoot.state != "homeScreen"; + opacity: enabled ? 1 : 0.2 Layout.alignment: Qt.AlignHCenter Layout.preferredWidth: units.iconSizes.medium @@ -190,7 +211,7 @@ Rectangle { height: width source: "window-close" enabled: compositorRoot.currentWindow - opacity: enabled ? 1 : 0.6 + opacity: enabled ? 1 : 0.2 Layout.alignment: Qt.AlignHCenter Layout.preferredWidth: units.iconSizes.medium 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/images/homescreenicons.svg b/containments/homescreen/contents/images/homescreenicons.svg new file mode 100644 index 00000000..e3c4edb3 --- /dev/null +++ b/containments/homescreen/contents/images/homescreenicons.svg @@ -0,0 +1,260 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/containments/homescreen/contents/ui/HomeLauncher.qml b/containments/homescreen/contents/ui/HomeLauncher.qml new file mode 100644 index 00000000..1fccfbbb --- /dev/null +++ b/containments/homescreen/contents/ui/HomeLauncher.qml @@ -0,0 +1,42 @@ +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: parent.height / 2 + height: width + source: model.ApplicationIconRole + } + + PlasmaComponents.Label { + id: label + visible: text.length > 0 + + anchors { + top: icon.bottom + left: icon.left + right: icon.right + } + + wrapMode: Text.WordWrap + horizontalAlignment: Qt.AlignHCenter + verticalAlignment: Qt.AlignVCenter + maximumLineCount: 2 + + 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..5092a196 --- /dev/null +++ b/containments/homescreen/contents/ui/main.qml @@ -0,0 +1,166 @@ +/* + * 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.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: 480 + height: 640 + + property Item toolBox + property alias appletsSpace: applicationsView.headerItem + property int buttonHeight: width/4 + + Containment.onAppletAdded: { + var container = appletContainerComponent.createObject(appletsSpace.layout) + 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 + Layout.fillWidth: true + Layout.fillHeight: applet && applet.Layout.fillHeight + Layout.onFillHeightChanged: { + if (plasmoid.formFactor == PlasmaCore.Types.Vertical) { + checkLastSpacer(); + } + } + + Layout.minimumWidth: root.width + Layout.minimumHeight: appletsSpace.layout.children.count > 1 ? Math.max(applet.Layout.minimumHeight, root.height / 2) : root.height + + Layout.preferredWidth: root.width + Layout.preferredHeight: Layout.minimumHeight + + Layout.maximumWidth: root.width + Layout.maximumHeight: Layout.minimumHeight + } + } + + 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 + } + + cellWidth: root.buttonHeight + cellHeight: cellWidth + model: SatelliteComponents.ApplicationListModel { + id: appListModel + } + snapMode: GridView.SnapToRow + //clip: true + delegate: HomeLauncher {} + header: MouseArea { + z: 999 + property Item layout: mainLayout + width: root.width + height: Math.max(root.height, (root.height/2) * mainLayout.children.length) + + onPressAndHold: { + plasmoid.action("configure").trigger(); + } + + ColumnLayout { + id: mainLayout + anchors.fill: parent + } + SatelliteStripe { + id: stripe + z: 99 + y: Math.max(applicationsView.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() { + console.log("Start phone") + } + } + + 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 diff --git a/shell/contents/components/HomeLauncherSvg.qml b/shell/contents/components/HomeLauncherSvg.qml index a64672ce..1b897900 100644 --- a/shell/contents/components/HomeLauncherSvg.qml +++ b/shell/contents/components/HomeLauncherSvg.qml @@ -21,8 +21,7 @@ Item { MouseArea { anchors.fill: parent propagateComposedEvents: true - drag.target: stripe - drag.axis: Drag.YAxis + onClicked: { if (callback) { callback(); diff --git a/shell/contents/components/SatelliteStripe.qml b/shell/contents/components/SatelliteStripe.qml index 03e1aa91..813576f6 100644 --- a/shell/contents/components/SatelliteStripe.qml +++ b/shell/contents/components/SatelliteStripe.qml @@ -1,10 +1,16 @@ import QtQuick 2.0 import org.kde.plasma.core 2.0 as PlasmaCore -Rectangle { - gradient: Gradient { - GradientStop { position: 0.0; color: "#FFEDDF00" } - GradientStop { position: 3.0; color: "#00EDDF00" } +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 diff --git a/shell/contents/views/Desktop.qml b/shell/contents/views/Desktop.qml index 36cd33bc..b6e914e4 100644 --- a/shell/contents/views/Desktop.qml +++ b/shell/contents/views/Desktop.qml @@ -30,7 +30,7 @@ import org.kde.kquickcontrolsaddons 2.0 import MeeGo.QOfono 0.2 import "../components" -MouseEventListener { +Item { id: homescreen width: 1080 height: 1920 @@ -39,6 +39,7 @@ MouseEventListener { property Item wallpaper; property var pendingRemovals: []; property int notificationId: 0; + property int buttonHeight: width/4 /* Notificadtion data object has the following properties: @@ -88,10 +89,6 @@ MouseEventListener { } } - onPressAndHold: { - containment.action("configure").trigger(); - } - OfonoManager { id: ofonoManager onAvailableChanged: { @@ -210,6 +207,18 @@ MouseEventListener { } } + Rectangle { + z: 1 + color: Qt.rgba(0, 0, 0, 0.9 * (Math.min(applications.contentY + homescreen.height, homescreen.height) / homescreen.height)) + anchors.fill: parent + } + + PlasmaCore.DataSource { + id: timeSource + engine: "time" + connectedSources: ["Local"] + interval: 60 * 1000 + } PlasmaCore.DataSource { id: notificationsSource @@ -303,19 +312,12 @@ MouseEventListener { right: parent.right } height: units.iconSizes.small - z: 1 + z: 2 colorGroup: PlasmaCore.Theme.ComplementaryColorGroup Rectangle { anchors.fill: parent - color: Qt.rgba(0, 0, 0, 0.7) - - PlasmaCore.DataSource { - id: timeSource - engine: "time" - connectedSources: ["Local"] - interval: 500 - } + color: Qt.rgba(0, 0, 0, 0.9) PlasmaCore.IconItem { id: strengthIcon @@ -396,111 +398,15 @@ MouseEventListener { height: homescreen.height } + PlasmaCore.ColorScope { z: 1 anchors { - top: statusPanel.bottom - bottom: parent.bottom - left: parent.left - right: parent.right + fill: parent } colorGroup: PlasmaCore.Theme.ComplementaryColorGroup - ListView { - id: notificationView - spacing: units.smallSpacing - anchors { - top: parent.top - bottom: stripe.top - left: parent.left - right: parent.right - bottomMargin: units.smallSpacing - } - - z: 1 - clip: true - verticalLayoutDirection: ListView.BottomToTop - model: notificationsModel - add: Transition { - NumberAnimation { - properties: "x" - from: notificationView.width - duration: 100 - } - } - - remove: Transition { - NumberAnimation { - properties: "x" - to: notificationView.width - duration: 500 - } - NumberAnimation { - properties: "opacity" - to: 0 - duration: 500 - } - } - - removeDisplaced: Transition { - SequentialAnimation { - PauseAnimation { duration: 600 } - NumberAnimation { properties: "x,y"; duration: 100 } - } - } - - delegate: NotificationStripe {} - } - - SatelliteStripe { - id: stripe - z: 1 - - 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") } - } - } - } - SatelliteComponents.ApplicationListModel { id: appListModel } @@ -508,20 +414,142 @@ MouseEventListener { GridView { id: applications anchors { - top: stripe.bottom + top: parent.top bottom: parent.bottom left: parent.left right: parent.right - topMargin: units.smallSpacing } z: 1 - cellWidth: stripe.height * 2 + cellWidth: homescreen.buttonHeight cellHeight: cellWidth model: appListModel snapMode: GridView.SnapToRow clip: true + header: MouseArea { + z: 999 + width: homescreen.width + height: homescreen.height - units.iconSizes.medium + + onPressAndHold: { + containment.action("configure").trigger(); + } + + PlasmaComponents.Label { + id: bigClock + anchors { + horizontalCenter: parent.horizontalCenter + top: parent.top + bottom: notificationView.top + } + text: Qt.formatTime(timeSource.data.Local.DateTime, "hh:mm") + color: PlasmaCore.ColorScope.textColor + horizontalAlignment: Qt.AlignHCenter + verticalAlignment: Qt.AlignVCenter + font.pointSize: 40 + style: Text.Raised + styleColor: "black" + } + + ListView { + id: notificationView + spacing: units.smallSpacing + anchors { + bottom: parent.bottom + left: parent.left + right: parent.right + bottomMargin: stripe.height * 2 + } + height: parent.height / 3 + interactive: false + + z: 1 + verticalLayoutDirection: ListView.BottomToTop + model: notificationsModel + + add: Transition { + NumberAnimation { + properties: "x" + from: notificationView.width + duration: 100 + } + } + + remove: Transition { + NumberAnimation { + properties: "x" + to: notificationView.width + duration: 500 + } + NumberAnimation { + properties: "opacity" + to: 0 + duration: 500 + } + } + + removeDisplaced: Transition { + SequentialAnimation { + PauseAnimation { duration: 600 } + NumberAnimation { properties: "x,y"; duration: 100 } + } + } + + delegate: NotificationStripe {} + + } + 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") } + } + } + } + } delegate: HomeLauncher {} Component.onCompleted : { console.log("WTF " + width) } + + } }