~ci-train-bot/ubuntu-settings-components/ubuntu-settings-components-ubuntu-zesty-2202

« back to all changes in this revision

Viewing changes to plugins/Ubuntu/Settings/Menus/SimpleMessageMenu.qml

  • Committer: Bileto Bot
  • Date: 2016-10-24 11:32:00 UTC
  • mfrom: (146.3.110 slots-layout)
  • Revision ID: ci-train-bot@canonical.com-20161024113200-85dvkl9m1o0msi5i
* Menus: rewrite components using ListItemLayout's and SlotsLayout's
* Bump revision to 0.10, as per Components removal

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright 2013 Canonical Ltd.
 
2
 * Copyright 2013-2016 Canonical Ltd.
3
3
 *
4
4
 * This program is free software; you can redistribute it and/or modify
5
5
 * it under the terms of the GNU Lesser General Public License as published by
16
16
 * Authors:
17
17
 *      Renato Araujo Oliveira Filho <renato@canonical.com>
18
18
 *      Olivier Tilloy <olivier.tilloy@canonical.com>
 
19
 *      Marco Trevisan <marco.trevisan@canonical.com>
19
20
 */
20
21
 
21
22
import QtQuick 2.4
22
23
import Ubuntu.Components 1.3
23
 
import Ubuntu.Components.ListItems 1.3 as ListItem
24
24
import Ubuntu.Settings.Components 0.1 as USC
25
 
import QtQuick.Layouts 1.1
26
25
 
27
 
ListItem.Empty {
 
26
BaseMenu {
28
27
    id: menu
29
28
 
30
 
    property alias title: messageHeader.title
 
29
    property string title
 
30
    property string body
31
31
    property alias time: messageHeader.time
32
 
    property alias body: messageHeader.body
33
32
 
34
33
    property url avatar
35
34
    property url icon
37
36
    signal iconActivated
38
37
    signal dismissed
39
38
 
40
 
    property alias footer: footerLoader.sourceComponent
 
39
    property alias footer: footerContainer.children
41
40
    property real _animationDuration: UbuntuAnimation.FastDuration
42
41
 
43
 
    __height: layout.implicitHeight + units.gu(3)
44
 
    clip: heightAnimation.running
 
42
    height: layout.height + (divider.visible ? divider.height : 0)
 
43
    clip: leadingActions || trailingActions || heightAnimation.running
45
44
 
46
 
    ColumnLayout {
 
45
    Column {
47
46
        id: layout
48
 
 
49
 
        anchors {
50
 
            left: parent.left
51
 
            right: parent.right
52
 
            leftMargin: units.gu(2)
53
 
            rightMargin: units.gu(2)
54
 
            top: parent.top
55
 
            topMargin: units.gu(1.5)
56
 
        }
57
 
        spacing: units.gu(1.5)
 
47
        anchors { right: parent.right; left: parent.left }
58
48
 
59
49
        USC.MessageHeader {
60
50
            id: messageHeader
61
 
            Layout.fillWidth: true
62
 
            Layout.alignment: Qt.AlignTop
63
51
 
64
52
            avatar: menu.avatar != "" ? menu.avatar : "image://theme/contact"
65
53
            icon: menu.icon != "" ? menu.icon : "image://theme/message"
66
 
 
67
54
            state: menu.state
 
55
            title.text: menu.title
 
56
            body.text: menu.body
68
57
 
69
58
            onIconClicked:  {
70
59
                menu.iconActivated();
71
60
            }
72
61
        }
73
62
 
74
 
        Loader {
75
 
            id: footerLoader
 
63
        Item {
 
64
            id: footerContainer
 
65
            anchors { right: parent.right; left: parent.left }
 
66
            width: childrenRect.width
 
67
            height: childrenRect.height
76
68
            visible: menu.state === "expanded"
77
 
            opacity: 0.0
78
 
            asynchronous: false
79
 
            Layout.fillWidth: true
80
 
            Layout.fillHeight: true
 
69
            opacity: 0
 
70
 
 
71
            Behavior on opacity {
 
72
                NumberAnimation {
 
73
                    duration:  _animationDuration
 
74
                }
 
75
            }
81
76
        }
82
77
    }
83
78
 
89
84
        }
90
85
    }
91
86
 
92
 
    onTriggered: if (!footer || !selected) messageHeader.shakeIcon();
 
87
    onTriggered: if (!selected) messageHeader.shakeIcon();
93
88
 
94
89
    states: State {
95
90
        name: "expanded"
96
 
        when: selected && footerLoader.status == Loader.Ready
 
91
        when: selected
97
92
 
98
93
        PropertyChanges {
99
 
            target: footerLoader
 
94
            target: footerContainer
100
95
            opacity: 1.0
101
96
        }
102
 
    }
103
97
 
104
 
    transitions: Transition {
105
 
        ParallelAnimation {
106
 
            PropertyAnimation { target: footerLoader; property: "opacity"; duration:  _animationDuration }
 
98
        PropertyChanges {
 
99
            target: menu
 
100
            color: highlightColor
107
101
        }
108
102
    }
109
103