~ubuntu-branches/ubuntu/saucy/plasma-mobile/saucy

« back to all changes in this revision

Viewing changes to applets/alarms/plasmoid/contents/ui/AlarmDelegate.qml

  • Committer: Package Import Robot
  • Author(s): Rohan Garg
  • Date: 2012-12-22 01:58:11 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20121222015811-zqq9spgc9e0gin07
Tags: 3.0-0ubuntu1
* New upstream release
* Update install files
* Run wrap-and-sort
* Add plasma-mobile-dev
* Drop plasma-active-keyboardcontainer

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *   Copyright 2012 Marco Martin <notmart@gmail.com>
 
3
 *
 
4
 *   This program is free software; you can redistribute it and/or modify
 
5
 *   it under the terms of the GNU Library General Public License as
 
6
 *   published by the Free Software Foundation; either version 2, or
 
7
 *   (at your option) any later version.
 
8
 *
 
9
 *   This program is distributed in the hope that it will be useful,
 
10
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 
11
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
12
 *   GNU Library General Public License for more details
 
13
 *
 
14
 *   You should have received a copy of the GNU Library General Public
 
15
 *   License along with this program; if not, write to the
 
16
 *   Free Software Foundation, Inc.,
 
17
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 
18
 */
 
19
 
 
20
import QtQuick 1.1
 
21
import org.kde.plasma.core 0.1 as PlasmaCore
 
22
import org.kde.plasma.components 0.1 as PlasmaComponents
 
23
import org.kde.locale 0.1 as KLocale
 
24
import org.kde.qtextracomponents 0.1
 
25
 
 
26
PlasmaComponents.ListItem {
 
27
    id: alarmItem
 
28
    opacity: 1-Math.abs(x)/width
 
29
 
 
30
    onClicked: editAlarm(id)
 
31
 
 
32
    checked: mainArea.pressed || pageRow.currentPage.alarmId == id
 
33
 
 
34
    MouseArea {
 
35
        id: mainArea
 
36
        width: alarmItem.width
 
37
        height: childrenRect.height
 
38
        drag {
 
39
            target: alarmItem
 
40
            axis: Drag.XAxis
 
41
        }
 
42
        onReleased: {
 
43
            if (alarmItem.x < -alarmItem.width/2) {
 
44
                removeAnimation.exitFromRight = false
 
45
                removeAnimation.running = true
 
46
            } else if (alarmItem.x > alarmItem.width/2 ) {
 
47
                removeAnimation.exitFromRight = true
 
48
                removeAnimation.running = true
 
49
            } else {
 
50
                resetAnimation.running = true
 
51
            }
 
52
        }
 
53
        onClicked: alarmItem.clicked()
 
54
        SequentialAnimation {
 
55
            id: removeAnimation
 
56
            property bool exitFromRight: true
 
57
            NumberAnimation {
 
58
                target: alarmItem
 
59
                properties: "x"
 
60
                to: removeAnimation.exitFromRight ? alarmItem.width : -alarmItem.width
 
61
                duration: 250
 
62
                easing.type: Easing.InOutQuad
 
63
            }
 
64
            NumberAnimation {
 
65
                target: alarmItem
 
66
                properties: "height"
 
67
                to: 0
 
68
                duration: 250
 
69
                easing.type: Easing.InOutQuad
 
70
            }
 
71
            ScriptAction {
 
72
                script: removeAlarm(id);
 
73
            }
 
74
        }
 
75
        SequentialAnimation {
 
76
            id: resetAnimation
 
77
            NumberAnimation {
 
78
                target: alarmItem
 
79
                properties: "x"
 
80
                to: 0
 
81
                duration: 250
 
82
                easing.type: Easing.InOutQuad
 
83
            }
 
84
        }
 
85
        Row {
 
86
            spacing: 8
 
87
            width: alarmItem.width - closeButton.width - spacing*3
 
88
 
 
89
            Column {
 
90
                width: parent.width/4
 
91
                PlasmaComponents.Label {
 
92
                    text: locale.formatDate(dateTime, KLocale.Locale.FancyShortDate)
 
93
                    elide: Text.ElideRight
 
94
                }
 
95
                PlasmaComponents.Label {
 
96
                    text: locale.formatLocaleTime(dateTime)
 
97
                    elide: Text.ElideRight
 
98
                }
 
99
            }
 
100
            PlasmaComponents.Label {
 
101
                anchors.verticalCenter: parent.verticalCenter
 
102
                horizontalAlignment: Text.AlignHCenter
 
103
                width: parent.width/4
 
104
                text: message
 
105
                wrapMode: Text.Wrap
 
106
                elide: Text.ElideRight
 
107
                maximumLineCount: 3
 
108
            }
 
109
            PlasmaComponents.Label {
 
110
                anchors.verticalCenter: parent.verticalCenter
 
111
                horizontalAlignment: Text.AlignHCenter
 
112
                width: parent.width/4
 
113
                text: recurs ? i18n("Every day") : i18n("Once")
 
114
                elide: Text.ElideRight
 
115
            }
 
116
            PlasmaComponents.Label {
 
117
                anchors.verticalCenter: parent.verticalCenter
 
118
                horizontalAlignment: Text.AlignHCenter
 
119
                width: parent.width/4
 
120
                text: audioFile ? i18n("Audio") : ""
 
121
                elide: Text.ElideRight
 
122
            }
 
123
        }
 
124
        PlasmaCore.SvgItem {
 
125
            id: closeButton
 
126
            svg: configIconsSvg
 
127
            elementId: "close"
 
128
            width: theme.mediumIconSize
 
129
            height: theme.mediumIconSize
 
130
            anchors {
 
131
                verticalCenter: parent.verticalCenter
 
132
                right: parent.right
 
133
                rightMargin: 12
 
134
            }
 
135
            MouseArea {
 
136
                anchors.fill: parent
 
137
                anchors.margins: -6
 
138
                onClicked: {
 
139
                    removeAnimation.running = true
 
140
                }
 
141
            }
 
142
        }
 
143
    }
 
144
}