diff --git a/CMakeLists.txt b/CMakeLists.txt index 60d6f2ef..d8edfb84 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -48,4 +48,5 @@ add_subdirectory(bin) add_subdirectory(qmlcomponents) add_subdirectory(services) add_subdirectory(settingsmodules) +add_subdirectory(applets) add_subdirectory(containments) diff --git a/applets/CMakeLists.txt b/applets/CMakeLists.txt new file mode 100644 index 00000000..a99f1209 --- /dev/null +++ b/applets/CMakeLists.txt @@ -0,0 +1,3 @@ + +plasma_install_package(clock org.kde.phone.clock) +plasma_install_package(notifications org.kde.phone.notifications) diff --git a/applets/clock/Messages.sh b/applets/clock/Messages.sh new file mode 100755 index 00000000..2e97a97d --- /dev/null +++ b/applets/clock/Messages.sh @@ -0,0 +1,4 @@ +#! /usr/bin/env bash +$EXTRACTRC `find . -name \*.rc -o -name \*.ui -o -name \*.kcfg` >> rc.cpp +$XGETTEXT `find . -name \*.js -o -name \*.qml -o -name \*.cpp` -o $podir/plasma_applet_org.kde.phone.clock.pot +rm -f rc.cpp diff --git a/applets/clock/contents/ui/main.qml b/applets/clock/contents/ui/main.qml new file mode 100644 index 00000000..9118eaf7 --- /dev/null +++ b/applets/clock/contents/ui/main.qml @@ -0,0 +1,47 @@ +/* + * Copyright 2014 Aaron Seigo + * 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 + + +PlasmaComponents.Label { + id: bigClock + + PlasmaCore.DataSource { + id: timeSource + engine: "time" + connectedSources: ["Local"] + interval: 60 * 1000 + } + + Layout.minimumWidth: implicitWidth + Layout.minimumHeight: implicitHeight + + 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" +} diff --git a/applets/clock/metadata.desktop b/applets/clock/metadata.desktop new file mode 100644 index 00000000..6e04d3ab --- /dev/null +++ b/applets/clock/metadata.desktop @@ -0,0 +1,22 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=Clock + +Comment=Time displayed in a digital format + +Icon=preferences-system-time +Type=Service +X-KDE-ParentApp= +X-KDE-PluginInfo-Author=Marco Martin +X-KDE-PluginInfo-Email=mart@kde.org +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-Name=org.kde.phone.clock +X-KDE-PluginInfo-Version=1.0 +X-KDE-PluginInfo-Website=plasma.kde.org +X-KDE-ServiceTypes=Plasma/Applet +X-Plasma-API=declarativeappletscript +X-KDE-PluginInfo-Category=Date and Time +X-Plasma-Provides=org.kde.plasma.time + +X-Plasma-MainScript=ui/main.qml +X-Plasma-RemoteLocation= diff --git a/applets/notifications/Messages.sh b/applets/notifications/Messages.sh new file mode 100644 index 00000000..c23a5dc2 --- /dev/null +++ b/applets/notifications/Messages.sh @@ -0,0 +1,5 @@ +#! /usr/bin/env bash +$EXTRACTRC `find . -name \*.rc -o -name \*.ui -o -name \*.kcfg` >> rc.cpp +$XGETTEXT `find . -name \*.qml` -L Java -o $podir/plasma_applet_org.kde.phone.notifications.pot +$XGETTEXT rc.cpp -jo $podir/plasma_applet_org.kde.phone.notifications.pot +rm -f rc.cpp diff --git a/applets/notifications/contents/ui/NotificationStripe.qml b/applets/notifications/contents/ui/NotificationStripe.qml new file mode 100644 index 00000000..c9406ac8 --- /dev/null +++ b/applets/notifications/contents/ui/NotificationStripe.qml @@ -0,0 +1,157 @@ +/* + * Copyright 2014 Aaron Seigo + * + * 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.0 +import org.kde.plasma.core 2.0 as PlasmaCore +import org.kde.plasma.components 2.0 as PlasmaComponents + +MouseArea { + id: root + + + height: units.gridUnit * 2 + width: parent.width + anchors.bottomMargin: 10 + drag.axis: Drag.XAxis + drag.target: root + + property bool expanded: false + property var textGradient: Gradient { + GradientStop { position: 1.0; color: "#FF00000C" } + GradientStop { position: 0.0; color: "#00000C00" } + } + property color textGradientOverlay: "#9900000C" + + Behavior on x { + SpringAnimation { spring: 2; damping: 0.2 } + } + + Behavior on height { + SpringAnimation { spring: 5; damping: 0.3 } + } + + onExpandedChanged: { + if (expanded && body) { + height = units.gridUnit * 4; + } else { + height = units.gridUnit * 2; + } + } + + onReleased: { + if (drag.active) { + if (x > width / 4 || x < width / -4) { + notificationsModel.remove(index); + } else { + x = 0; + } + } else if (body) { + expanded = !expanded; + } + } + + + PlasmaCore.IconItem { + id: icon + width: units.iconSizes.medium + height: width + visible: !root.expanded + anchors.verticalCenter: parent.verticalCenter + x: units.largeSpacing + y: 0 + source: appIcon && appIcon.length > 0 ? appIcon : "im-user" + } + + Item { + id: rounded + clip: true + height: parent.height + width: height / 2 + visible: !root.expanded + anchors { + left: icon.right + leftMargin: units.largeSpacing + } + + Rectangle { + id: roundedRect + height: parent.height + width: parent.width * 2 + radius: height //Math.max(height, units.gridUnit) + anchors { + left: parent.left + top: parent.top + } + + gradient: root.textGradient + + Rectangle { + anchors.fill: parent + radius: height / 2 + color: textGradientOverlay + } + } + } + + Rectangle { + id: summaryArea + width: parent.width - icon.width - rounded.width - (units.largeSpacing * 2) + height: parent.height + anchors { + left: root.expanded ? root.left : rounded.right + right: root.right + top: parent.top + } + + gradient: root.textGradient + Rectangle { + anchors.fill: parent + color: textGradientOverlay + } + + PlasmaComponents.Label { + id: summaryText + anchors.fill: parent + clip: true + horizontalAlignment: root.expanded ? Qt.AlignHCenter : Qt.AlignLeft + verticalAlignment: Qt.AlignVCenter + color: PlasmaCore.ColorScope.textColor + text: summary + (root.expanded ? (body ? "\n" + body : '') : + (body ? '...' : '')) + } + + } + + Rectangle { + id: extraArea + width: parent.width + height: parent.width + anchors { + left: summaryArea.right + top: parent.top + bottom: parent.bottom + } + + gradient: root.textGradient + Rectangle { + anchors.fill: parent + color: textGradientOverlay + } + } +} \ No newline at end of file diff --git a/applets/notifications/contents/ui/main.qml b/applets/notifications/contents/ui/main.qml new file mode 100644 index 00000000..c38ab798 --- /dev/null +++ b/applets/notifications/contents/ui/main.qml @@ -0,0 +1,127 @@ +/* + * Copyright 2014 Aaron Seigo + * 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 + + Layout.minimumHeight: notificationView.contentsHeight + + PlasmaCore.DataSource { + id: notificationsSource + + engine: "notifications" + interval: 0 + + onSourceAdded: { + connectSource(source); + } + + onSourceRemoved: { + for (var i = 0; i < notificationsModel.count; ++i) { + if (notificationsModel.get(i) == source) { + notificationsModel.remove(i); + break; + } + } + } + + onNewData: { + var actions = new Array() + if (data["actions"] && data["actions"].length % 2 == 0) { + for (var i = 0; i < data["actions"].length; i += 2) { + var action = new Object(); + action["id"] = data["actions"][i]; + action["text"] = data["actions"][i+1]; + actions.push(action); + } + } + + homescreen.addNotification( + sourceName, + data, + actions); + } + + } + + ListModel { + id: notificationsModel + + ListElement { + appIcon: "call-start" + summary: "Missed call from Joe" + body: "Called at 8:42 from +41 56 373 37 31" + } + ListElement { + appIcon: "im-google" + summary: "July: Hey! Are you around?" + } + ListElement { + appIcon: "im-google" + summary: "July: Hello?" + } + } + + ListView { + id: notificationView + spacing: units.smallSpacing + anchors.fill: parent + 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 {} + } +} diff --git a/applets/notifications/metadata.desktop b/applets/notifications/metadata.desktop new file mode 100644 index 00000000..c2cbf50f --- /dev/null +++ b/applets/notifications/metadata.desktop @@ -0,0 +1,22 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=Notifications +Comment=Display notifications and jobs + +Type=Service +Icon=preferences-desktop-notification +X-KDE-ParentApp= +X-KDE-PluginInfo-Author=Marco Martin +X-KDE-PluginInfo-Category=Tasks +X-KDE-PluginInfo-Email=mart@kde.org +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-Name=org.kde.phone.notifications +X-KDE-PluginInfo-Version=0.1 +X-KDE-PluginInfo-Website=http://plasma.kde.org/ +X-KDE-ServiceTypes=Plasma/Applet +X-Plasma-API=declarativeappletscript +X-Plasma-Provides=org.kde.plasma.notifications +X-KDE-PluginInfo-EnabledByDefault=true + +X-Plasma-MainScript=ui/main.qml +X-Plasma-NotificationArea=true diff --git a/containments/homescreen/contents/ui/main.qml b/containments/homescreen/contents/ui/main.qml index b1a1aa19..215715de 100644 --- a/containments/homescreen/contents/ui/main.qml +++ b/containments/homescreen/contents/ui/main.qml @@ -102,7 +102,7 @@ Item { z: 999 property Item layout: mainLayout width: root.width - height: Math.max(root.height, (root.height/2) * mainLayout.children.length) + height: Math.max(root.height, ((root.height - units.gridUnit * 2)/2) * mainLayout.children.length) onPressAndHold: { plasmoid.action("configure").trigger(); @@ -112,7 +112,7 @@ Item { id: mainLayout anchors { fill: parent - bottomMargin: stripe.height + bottomMargin: stripe.height + units.gridUnit * 2 } Item { Layout.fillWidth: true