2014-09-29 17:15:21 +00:00
|
|
|
/*
|
|
|
|
|
* Copyright 2014 Aaron Seigo <aseigo@kde.org>
|
|
|
|
|
*
|
|
|
|
|
* 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.
|
|
|
|
|
*/
|
|
|
|
|
|
2014-09-29 12:27:23 +00:00
|
|
|
import QtQuick 2.0
|
|
|
|
|
import org.kde.plasma.core 2.0 as PlasmaCore
|
2014-11-25 16:57:38 +00:00
|
|
|
import org.kde.plasma.components 2.0 as PlasmaComponents
|
2014-09-29 12:27:23 +00:00
|
|
|
|
2014-09-29 18:25:17 +00:00
|
|
|
MouseArea {
|
2014-09-29 12:27:23 +00:00
|
|
|
id: root
|
2014-09-29 14:40:58 +00:00
|
|
|
|
2014-09-29 18:25:17 +00:00
|
|
|
|
2014-09-29 12:27:23 +00:00
|
|
|
height: units.gridUnit * 2
|
2014-09-29 14:40:58 +00:00
|
|
|
width: parent.width
|
|
|
|
|
anchors.bottomMargin: 10
|
2014-09-29 18:25:17 +00:00
|
|
|
drag.axis: Drag.XAxis
|
|
|
|
|
drag.target: root
|
2014-09-29 12:27:23 +00:00
|
|
|
|
2014-09-29 17:31:13 +00:00
|
|
|
property bool expanded: false
|
2014-09-29 12:27:23 +00:00
|
|
|
property var textGradient: Gradient {
|
|
|
|
|
GradientStop { position: 1.0; color: "#FF00000C" }
|
|
|
|
|
GradientStop { position: 0.0; color: "#00000C00" }
|
|
|
|
|
}
|
|
|
|
|
property color textGradientOverlay: "#9900000C"
|
|
|
|
|
|
2014-09-29 17:15:21 +00:00
|
|
|
Behavior on x {
|
|
|
|
|
SpringAnimation { spring: 2; damping: 0.2 }
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-29 17:31:13 +00:00
|
|
|
Behavior on height {
|
|
|
|
|
SpringAnimation { spring: 5; damping: 0.3 }
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
onExpandedChanged: {
|
2014-09-29 17:40:48 +00:00
|
|
|
if (expanded && body) {
|
2014-09-29 17:31:13 +00:00
|
|
|
height = units.gridUnit * 4;
|
2014-09-29 17:40:48 +00:00
|
|
|
} else {
|
|
|
|
|
height = units.gridUnit * 2;
|
2014-09-29 17:31:13 +00:00
|
|
|
}
|
|
|
|
|
}
|
2014-09-29 17:40:48 +00:00
|
|
|
|
2014-09-29 18:25:17 +00:00
|
|
|
onReleased: {
|
|
|
|
|
if (drag.active) {
|
|
|
|
|
if (x > width / 4 || x < width / -4) {
|
|
|
|
|
notificationsModel.remove(index);
|
2014-09-29 17:31:13 +00:00
|
|
|
} else {
|
2014-09-29 18:25:17 +00:00
|
|
|
x = 0;
|
2014-09-29 17:15:21 +00:00
|
|
|
}
|
2014-09-29 21:01:19 +00:00
|
|
|
} else if (body) {
|
2014-09-29 18:25:17 +00:00
|
|
|
expanded = !expanded;
|
2014-09-29 17:15:21 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-29 18:25:17 +00:00
|
|
|
|
2014-09-29 12:27:23 +00:00
|
|
|
PlasmaCore.IconItem {
|
|
|
|
|
id: icon
|
|
|
|
|
width: units.iconSizes.medium
|
|
|
|
|
height: width
|
2014-09-29 21:01:19 +00:00
|
|
|
visible: !root.expanded
|
2014-09-29 19:02:07 +00:00
|
|
|
anchors.verticalCenter: parent.verticalCenter
|
2014-09-29 12:27:23 +00:00
|
|
|
x: units.largeSpacing
|
|
|
|
|
y: 0
|
2014-09-29 17:15:21 +00:00
|
|
|
source: appIcon && appIcon.length > 0 ? appIcon : "im-user"
|
2014-09-29 12:27:23 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Item {
|
|
|
|
|
id: rounded
|
|
|
|
|
clip: true
|
|
|
|
|
height: parent.height
|
|
|
|
|
width: height / 2
|
2014-09-29 21:01:19 +00:00
|
|
|
visible: !root.expanded
|
2014-09-29 12:27:23 +00:00
|
|
|
anchors {
|
|
|
|
|
left: icon.right
|
|
|
|
|
leftMargin: units.largeSpacing
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
2014-09-29 17:31:13 +00:00
|
|
|
id: roundedRect
|
2014-09-29 12:27:23 +00:00
|
|
|
height: parent.height
|
|
|
|
|
width: parent.width * 2
|
2014-09-29 17:31:13 +00:00
|
|
|
radius: height //Math.max(height, units.gridUnit)
|
2014-09-29 12:27:23 +00:00
|
|
|
anchors {
|
|
|
|
|
left: parent.left
|
|
|
|
|
top: parent.top
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gradient: root.textGradient
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
radius: height / 2
|
|
|
|
|
color: textGradientOverlay
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Rectangle {
|
2014-09-29 14:40:58 +00:00
|
|
|
id: summaryArea
|
2014-09-29 12:27:23 +00:00
|
|
|
width: parent.width - icon.width - rounded.width - (units.largeSpacing * 2)
|
|
|
|
|
height: parent.height
|
|
|
|
|
anchors {
|
2014-09-29 21:01:19 +00:00
|
|
|
left: root.expanded ? root.left : rounded.right
|
|
|
|
|
right: root.right
|
2014-09-29 12:27:23 +00:00
|
|
|
top: parent.top
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gradient: root.textGradient
|
|
|
|
|
Rectangle {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
color: textGradientOverlay
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-25 16:57:38 +00:00
|
|
|
PlasmaComponents.Label {
|
2014-09-29 17:31:13 +00:00
|
|
|
id: summaryText
|
2014-09-29 12:27:23 +00:00
|
|
|
anchors.fill: parent
|
2014-09-29 17:40:48 +00:00
|
|
|
clip: true
|
2014-09-29 21:01:19 +00:00
|
|
|
horizontalAlignment: root.expanded ? Qt.AlignHCenter : Qt.AlignLeft
|
2014-09-29 12:27:23 +00:00
|
|
|
verticalAlignment: Qt.AlignVCenter
|
2014-11-25 16:57:38 +00:00
|
|
|
color: PlasmaCore.ColorScope.textColor
|
2014-09-29 17:40:48 +00:00
|
|
|
text: summary + (root.expanded ? (body ? "\n" + body : '') :
|
|
|
|
|
(body ? '...' : ''))
|
2014-09-29 12:27:23 +00:00
|
|
|
}
|
2014-09-29 17:40:48 +00:00
|
|
|
|
2014-09-29 12:27:23 +00:00
|
|
|
}
|
2014-09-29 18:25:17 +00:00
|
|
|
|
|
|
|
|
Rectangle {
|
|
|
|
|
id: extraArea
|
|
|
|
|
width: parent.width
|
|
|
|
|
height: parent.width
|
|
|
|
|
anchors {
|
|
|
|
|
left: summaryArea.right
|
|
|
|
|
top: parent.top
|
2014-09-29 21:01:19 +00:00
|
|
|
bottom: parent.bottom
|
2014-09-29 18:25:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
gradient: root.textGradient
|
|
|
|
|
Rectangle {
|
|
|
|
|
anchors.fill: parent
|
|
|
|
|
color: textGradientOverlay
|
|
|
|
|
}
|
|
|
|
|
}
|
2014-09-29 12:27:23 +00:00
|
|
|
}
|