~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/SliderMenu.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
14
14
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
15
15
 *
16
16
 * Authored by Andrea Cimitan <andrea.cimitan@canonical.com>
 
17
 *             Marco Trevisan <marco.trevisan@canonical.com>
17
18
 */
18
19
 
19
20
import QtQuick 2.4
20
21
import Ubuntu.Components 1.3
21
 
import Ubuntu.Components.ListItems 1.3 as ListItem
22
22
 
23
 
ListItem.Empty {
 
23
BaseMenu {
24
24
    id: menu
25
25
 
26
26
    property alias minimumValue: slider.minimumValue
27
27
    property alias maximumValue: slider.maximumValue
28
28
    property alias live: slider.live
 
29
    property alias text: label.text
29
30
    property double value: 0.0
30
31
 
31
32
    property alias minIcon: leftButton.source
32
33
    property alias maxIcon: rightButton.source
33
34
 
 
35
    // These fields are for retro-compatibility with ListItem.Empty
 
36
    property string iconSource
 
37
 
34
38
    signal updated(real value)
35
39
 
36
40
    property QtObject d: QtObject {
93
97
        }
94
98
    }
95
99
 
96
 
    implicitHeight: column.height + units.gu(1.5)
 
100
    implicitHeight: slotsLayout.height + (divider.visible ? divider.height : 0)
 
101
    highlightWhenPressed: false
97
102
 
98
103
    Column {
99
104
        id: column
100
 
        anchors {
101
 
            verticalCenter: parent.verticalCenter
102
 
            left: parent.left
103
 
            right: parent.right
104
 
            leftMargin: menu.__contentsMargins
105
 
            rightMargin: menu.__contentsMargins
106
 
        }
107
 
        height: childrenRect.height
108
 
        spacing: units.gu(0.5)
 
105
        anchors.fill: parent
 
106
        anchors.topMargin: units.gu(0.5)
 
107
        spacing: -units.gu(1.5)
109
108
 
110
109
        Label {
111
110
            id: label
112
 
            text: menu.text
113
 
            anchors {
114
 
                left: parent.left
115
 
                right: parent.right
116
 
            }
117
111
            visible: text != ""
 
112
            x: Qt.application.layoutDirection == Qt.LeftToRight ?
 
113
                    leftButton.x : rightButton.x + rightButton.width - width
118
114
        }
119
115
 
120
 
        Item {
121
 
            id: row
122
 
            anchors {
123
 
                left: parent.left
124
 
                right: parent.right
125
 
            }
126
 
            height: slider.height
127
 
 
128
 
            Icon {
129
 
                id: leftButton
130
 
                objectName: "leftButton"
131
 
                visible: source != ""
132
 
                anchors.left: row.left
133
 
                anchors.verticalCenter: row.verticalCenter
134
 
                height: slider.height - units.gu(2)
135
 
                width: height
136
 
                color: theme.palette.normal.backgroundText
137
 
 
138
 
                MouseArea {
139
 
                    anchors.fill: parent
140
 
                    onClicked: slider.value = slider.minimumValue
141
 
                }
142
 
 
143
 
            }
144
 
 
145
 
            Slider {
 
116
        SlotsLayout {
 
117
            id: slotsLayout
 
118
            objectName: "sliderMenuSlotsLayout"
 
119
 
 
120
            mainSlot: Slider {
146
121
                id: slider
147
122
                objectName: "slider"
148
 
                anchors {
149
 
                    left: leftButton.visible ? leftButton.right : row.left
150
 
                    right: rightButton.visible ? rightButton.left : row.right
151
 
                    leftMargin: leftButton.visible ? units.gu(0.5) : 0
152
 
                    rightMargin: rightButton.visible ? units.gu(0.5) : 0
153
 
                }
154
123
                live: true
155
124
 
156
125
                Component.onCompleted: {
182
151
            }
183
152
 
184
153
            Icon {
 
154
                id: leftButton
 
155
                objectName: "leftButton"
 
156
                visible: source !== ""
 
157
                height: slider.height - units.gu(2)
 
158
                width: height
 
159
                color: theme.palette.normal.backgroundText
 
160
 
 
161
                AbstractButton {
 
162
                    anchors.fill: parent
 
163
                    onClicked: slider.value = slider.minimumValue
 
164
                }
 
165
 
 
166
                SlotsLayout.position: SlotsLayout.Leading
 
167
                SlotsLayout.overrideVerticalPositioning: true
 
168
                anchors.verticalCenter: slider.verticalCenter
 
169
            }
 
170
 
 
171
            Icon {
185
172
                id: rightButton
186
173
                objectName: "rightButton"
187
 
                visible: source != ""
188
 
                anchors.right: row.right
189
 
                anchors.verticalCenter: row.verticalCenter
 
174
                visible: source !== ""
190
175
                height: slider.height - units.gu(2)
191
176
                width: height
192
177
                color: theme.palette.normal.backgroundText
193
178
 
194
 
                MouseArea {
 
179
                AbstractButton {
195
180
                    anchors.fill: parent
196
181
                    onClicked: slider.value =  slider.maximumValue
197
182
                }
 
183
 
 
184
                SlotsLayout.position: SlotsLayout.Trailing
 
185
                SlotsLayout.overrideVerticalPositioning: true
 
186
                anchors.verticalCenter: slider.verticalCenter
198
187
            }
199
188
        }
200
189
    }