Commit 264bff28 authored by Marco Martin's avatar Marco Martin

Merge branch 'mart/newContainmentShell'

Conflicts:
	CMakeLists.txt
	shell/contents/views/Desktop.qml
parents 9ef0eef9 4267242a
......@@ -23,10 +23,10 @@ include(ECMGenerateHeaders)
include(GenerateExportHeader)
include(FeatureSummary)
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED Core Gui Widgets Qml Quick)
find_package(Qt5 ${QT_MIN_VERSION} CONFIG REQUIRED Core Gui Widgets Qml Quick Test)
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Plasma Service Declarative)
find_package(KF5 REQUIRED COMPONENTS PlasmaQuick I18n)
find_package(KF5 ${KF5_MIN_VERSION} REQUIRED COMPONENTS Plasma Service Declarative I18n)
find_package(KF5 REQUIRED COMPONENTS PlasmaQuick DBusAddons Notifications)
feature_summary(WHAT ALL INCLUDE_QUIET_PACKAGES FATAL_ON_MISSING_REQUIRED_PACKAGES)
......@@ -44,9 +44,13 @@ install(DIRECTORY compositor/
PATTERN Messages.sh EXCLUDE
PATTERN dummydata EXCLUDE)
kpackage_install_package(phonebook org.kde.phone.phonebook genericqml)
install(FILES phonebook/metadata.desktop DESTINATION ${XDG_APPS_INSTALL_DIR} RENAME org.kde.phone.dialer.desktop)
add_subdirectory(bin)
add_subdirectory(qmlcomponents)
add_subdirectory(services)
add_subdirectory(settingsmodules)
add_subdirectory(applets)
add_subdirectory(containments)
add_subdirectory(dialer)
plasma_install_package(clock org.kde.phone.clock)
plasma_install_package(notifications org.kde.phone.notifications)
add_subdirectory(quicksettings)
......@@ -18,25 +18,24 @@
*/
import QtQuick 2.0
import QtQuick.Layouts 1.1
import org.kde.plasma.core 2.0 as PlasmaCore
import org.kde.plasma.components 2.0 as PlasmaComponents
MouseArea {
id: root
id: notificationItem
height: units.gridUnit * 2
height: units.gridUnit * (expanded ? (actionsLayout.visible ? 6 : 4) : 2) + background.margins.top + background.margins.bottom
width: parent.width
anchors.bottomMargin: 10
drag.axis: Drag.XAxis
drag.target: root
drag.target: notificationItem
property bool expanded: false
property var textGradient: Gradient {
GradientStop { position: 1.0; color: "#FF00000C" }
GradientStop { position: 0.0; color: "#00000C00" }
}
property color textGradientOverlay: "#9900000C"
property string source: model.source
property var actions: model.actions
Behavior on x {
SpringAnimation { spring: 2; damping: 0.2 }
......@@ -46,112 +45,105 @@ MouseArea {
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) {
//if there is an action, execute the first when swiping left
if (x < 0 && actions) {
var action = actions.get(0)
root.executeAction(source, action.id)
}
notificationsModel.remove(index);
} else {
x = 0;
}
} else if (body) {
} else if (body || actions) {
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"
PlasmaCore.FrameSvgItem {
id: background
imagePath: "widgets/background"
anchors {
fill: parent
rightMargin: -notificationItem.width
leftMargin: units.gridUnit
}
colorGroup: PlasmaCore.ColorScope.colorGroup
}
Item {
id: rounded
clip: true
height: parent.height
width: height / 2
visible: !root.expanded
PlasmaComponents.ToolButton {
anchors {
left: icon.right
leftMargin: units.largeSpacing
left: parent.left
verticalCenter: parent.verticalCenter
leftMargin: units.gridUnit / 2
}
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
}
iconSource: "window-close"
flat: false
onClicked: {
notificationsModel.remove(index);
}
}
Rectangle {
id: summaryArea
width: parent.width - icon.width - rounded.width - (units.largeSpacing * 2)
height: parent.height
PlasmaComponents.Label {
anchors {
left: root.expanded ? root.left : rounded.right
right: root.right
top: parent.top
left: parent.left
verticalCenter: parent.verticalCenter
leftMargin: units.gridUnit * 3
}
color: PlasmaCore.ColorScope.textColor
text: model.appName
}
gradient: root.textGradient
Rectangle {
anchors.fill: parent
color: textGradientOverlay
PlasmaComponents.Label {
id: summaryText
anchors {
right: icon.left
verticalCenter: parent.verticalCenter
rightMargin: units.smallSpacing
}
horizontalAlignment: Qt.AlignRight
verticalAlignment: Qt.AlignVCenter
color: PlasmaCore.ColorScope.textColor
text: summary + (notificationItem.expanded ? (body ? "\n" + body : '') :
(body ? '...' : ''))
}
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 ? '...' : ''))
PlasmaCore.IconItem {
id: icon
anchors {
right: notificationItem.right
verticalCenter: parent.verticalCenter
}
width: units.iconSizes.medium
height: width
source: appIcon && appIcon.length > 0 ? appIcon : "im-user"
}
Rectangle {
id: extraArea
width: parent.width
height: parent.width
RowLayout {
id: actionsLayout
anchors {
left: summaryArea.right
top: parent.top
bottom: parent.bottom
right: summaryText.right
top: summaryText.bottom
topMargin: units.smallSpacing
}
gradient: root.textGradient
Rectangle {
anchors.fill: parent
color: textGradientOverlay
opacity: notificationItem.expanded && notificationItem.actions && notificationItem.actions.count > 0 ? 1 : 0
Behavior on opacity {
NumberAnimation {
duration: units.shortDuration
easing.type: Easing.InOutQuad
}
}
Repeater {
model: notificationItem.actions
delegate: PlasmaComponents.Button {
text: model.text
onClicked: {
root.executeAction(notificationItem.source, model.id)
notificationsModel.remove(index);
}
}
}
}
}
\ No newline at end of file
}
......@@ -25,9 +25,59 @@ import org.kde.plasma.components 2.0 as PlasmaComponents
Item {
id: root
property int notificationId: 0
Layout.minimumHeight: notificationView.contentsHeight
function addNotification(source, data, actions) {
// Do not show duplicated notifications
// Remove notifications that are sent again (odd, but true)
for (var i = 0; i < notificationsModel.count; ++i) {
var tmp = notificationsModel.get(i);
var matches = (tmp.appName == data.appName &&
tmp.summary == data.summary &&
tmp.body == data.body);
var sameSource = tmp.source == source;
if (sameSource && matches) {
return;
}
if (sameSource || matches) {
notificationsModel.remove(i)
break;
}
}
data["id"] = ++notificationId;
data["source"] = source;
if (data["summary"].length < 1) {
data["summary"] = data["body"];
data["body"] = '';
}
data["actions"] = actions;
notificationsModel.insert(0, data);
if (!data["isPersistent"]) {
pendingRemovals.push(notificationId);
pendingTimer.start();
}
}
function executeAction(source, id) {
//try to use the service
if (source.indexOf("notification") !== -1) {
var service = notificationsSource.serviceForSource(source)
var op = service.operationDescription("invokeAction")
op["actionId"] = id
service.startOperationCall(op)
//try to open the id as url
} else if (source.indexOf("Job") !== -1) {
Qt.openUrlExternally(id)
}
}
PlasmaCore.DataSource {
id: notificationsSource
......@@ -58,7 +108,7 @@ Item {
}
}
homescreen.addNotification(
root.addNotification(
sourceName,
data,
actions);
......@@ -70,17 +120,26 @@ Item {
id: notificationsModel
ListElement {
source: "call1Source"
appIcon: "call-start"
summary: "Missed call from Joe"
appName: "Phone"
body: "Called at 8:42 from +41 56 373 37 31"
actions: []
}
ListElement {
source: "im1Source"
appIcon: "im-google"
appName: "Message"
summary: "July: Hey! Are you around?"
actions: []
}
ListElement {
source: "im2Source"
appIcon: "im-google"
appName: "Message"
summary: "July: Hello?"
actions: []
}
}
......
set(quicksettings_SRCS
quicksettings.cpp
)
add_library(plasma_applet_quicksettings MODULE ${quicksettings_SRCS})
kcoreaddons_desktop_to_json(plasma_applet_quicksettings package/metadata.desktop)
target_link_libraries(plasma_applet_quicksettings
Qt5::Gui
KF5::Plasma
KF5::I18n)
install(TARGETS plasma_applet_quicksettings DESTINATION ${PLUGIN_INSTALL_DIR})
#install(FILES plasma-quicksettings-default.desktop DESTINATION ${SERVICES_INSTALL_DIR})
plasma_install_package(package org.kde.phone.quicksettings)
#! /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.quicksettings.pot
rm -f rc.cpp
/*
* Copyright 2015 Marco Martin <notmart@gmail.com>
*
* 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.4
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: delegateRoot
implicitWidth: delegate.implicitWidth
implicitHeight: delegate.implicitHeight + (slider.opacity > 0 ? slider.height : 0)
property int screenBrightness
readonly property int maximumScreenBrightness: pmSource.data["PowerDevil"] ? pmSource.data["PowerDevil"]["Maximum Screen Brightness"] || 0 : 0
PlasmaCore.DataSource {
id: pmSource
engine: "powermanagement"
connectedSources: ["PowerDevil"]
onDataChanged: {
delegateRoot.screenBrightness = source.data["PowerDevil"]["Screen Brightness"];
}
}
Delegate {
id: delegate
toggled: slider.opacity > 0
function toggle() {
slider.opacity = slider.opacity > 0 ? 0 : 1;
}
}
PlasmaComponents.Slider {
id: slider
anchors.top: delegate.bottom
width: flow.width
opacity: 0
x: -delegateRoot.parent.x
value: screenBrightness
minimumValue: maximumValue > 100 ? 1 : 0
maximumValue: delegateRoot.maximumScreenBrightness
Behavior on opacity {
OpacityAnimator {
duration: units.shortDuration
easing.type: Easing.InOutQuad
}
}
}
onScreenBrightnessChanged: {
var service = pmSource.serviceForSource("PowerDevil");
var operation = service.operationDescription("setBrightness");
operation.brightness = slider.value;
operation.silent = true
service.startOperationCall(operation);
}
}
/*
* Copyright 2015 Marco Martin <notmart@gmail.com>
*
* 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.large
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 (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.settingsCommand) {
plasmoid.nativeInterface.executeCommand(model.settingsCommand);
} else if (model.toggleFunction) {
root[model.toggleFunction]();
}
}
}
}
}
}
/*
* Copyright 2015 Marco Martin <notmart@gmail.com>
*
* 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
import org.kde.plasma.plasmoid 2.0
Item {
id: root
function toggleAirplane() {
print("toggle airplane mode")
}
Plasmoid.preferredRepresentation: plasmoid.fullRepresentation
ListModel {
id: settingsModel
ListElement {
text: "Settings"
icon: "configure"
enabled: false
settingsCommand: "active-settings"
toggleFunction: ""
delegate: ""
}
ListElement {
text: "Mobile network"
icon: "network-mobile-80"
enabled: true
settingsCommand: ""
}
ListElement {
text: "Airplane mode"
icon: "flightmode-on"
enabled: false
settingsCommand: ""
toggleFunction: "toggleAirplane"
}
ListElement {
text: "Bluetooth"
icon: "preferences-system-bluetooth"
enabled: false