~ubuntu-branches/ubuntu/trusty/unity8/trusty-proposed

« back to all changes in this revision

Viewing changes to qml/Components/PageHeader.qml

  • Committer: Package Import Robot
  • Author(s): Didier Roche
  • Date: 2014-02-03 16:56:47 UTC
  • mfrom: (1.1.64)
  • Revision ID: package-import@ubuntu.com-20140203165647-ik9w833cac4zu9da
Tags: 7.84+14.04.20140130.is.7.84+14.04.20131220-0ubuntu1
Reverting to last known good version, as after installing a click
application, it redirects you to the first click application everytime.
(LP: #1275832)

Show diffs side-by-side

added added

removed removed

Lines of Context:
21
21
import Unity 0.1
22
22
 
23
23
Item {
24
 
    id: root
 
24
    /*!
 
25
     \preliminary
 
26
     The text that is shown inside the Page Header
 
27
     \qmlproperty string text
 
28
    */
 
29
    property alias text: label.text
 
30
 
25
31
    property bool searchEntryEnabled: false
26
32
    property alias searchQuery: searchField.text
27
33
    property ListModel searchHistory
28
34
    property Scope scope
29
 
    property alias childItem: itemContainer.children
30
35
 
31
36
    height: units.gu(8.5)
32
37
    implicitHeight: units.gu(8.5)
77
82
            height: childrenRect.height
78
83
 
79
84
            Item {
80
 
                id: itemContainer
 
85
                id: textContainer
81
86
 
82
 
                width: searchContainer.narrowMode ? header.width : header.width - searchContainer.width
 
87
                width: header.width
83
88
                height: header.height
 
89
 
 
90
                Label {
 
91
                    id: label
 
92
                    anchors {
 
93
                        left: parent.left
 
94
                        leftMargin: units.gu(2)
 
95
                        right: parent.right
 
96
                        verticalCenter: parent.verticalCenter
 
97
                    }
 
98
 
 
99
                    color: Theme.palette.selected.backgroundText
 
100
                    opacity: 0.8
 
101
                    font.family: "Ubuntu"
 
102
                    font.weight: Font.Light
 
103
                    fontSize: "x-large"
 
104
                    elide: Text.ElideRight
 
105
                    style: Text.Raised
 
106
                    styleColor: "black"
 
107
                }
84
108
            }
85
109
 
86
110
            Item {
91
115
                property bool popoverShouldOpen: false
92
116
                property bool popoverShouldClose: false
93
117
 
94
 
                property bool narrowMode: parent.width < units.gu(80)
 
118
                property bool narrowMode: parent.width < label.contentWidth + units.gu(50)
95
119
 
96
120
                property bool active: searchField.text != "" || searchField.activeFocus
97
121
                property var popover: null
98
122
 
99
 
                anchors.right: headerContainer.right
 
123
                anchors.right: textContainer.right
100
124
                height: header.height
101
125
 
102
126
                state:
117
141
 
118
142
                function openPopover() {
119
143
                    if (searchHistory.count > 0) {
120
 
                        searchContainer.popover = PopupUtils.open(popoverComponent, pointerPositioner,
 
144
                        searchContainer.popover = PopupUtils.open(popoverComponent, searchField,
121
145
                                                                  {
 
146
                                                                      "pointerTarget": pointerPositioner,
122
147
                                                                      "contentWidth": searchField.width,
123
148
                                                                      "edgeMargins": units.gu(1)
124
149
                                                                  }
145
170
                    anchors.fill: parent
146
171
                    anchors.margins: units.gu(1)
147
172
 
148
 
                    inputMethodHints: Qt.ImhNoPredictiveText
149
173
                    hasClearButton: false
150
174
 
151
175
                    primaryItem: AbstractButton {
232
256
                states: [
233
257
                    State {
234
258
                        name: "wide"
235
 
                        AnchorChanges { target: itemContainer; anchors.top: headerContainer.top }
236
 
                        AnchorChanges { target: searchContainer; anchors.left: undefined; anchors.top: itemContainer.top }
 
259
                        AnchorChanges { target: textContainer; anchors.top: headerContainer.top }
 
260
                        AnchorChanges { target: searchContainer; anchors.left: undefined; anchors.top: textContainer.top }
237
261
                    },
238
262
                    State {
239
263
                        name: "narrow"
240
264
                        PropertyChanges { target: searchField; highlighted: true }
241
 
                        AnchorChanges { target: itemContainer; anchors.top: searchContainer.bottom }
 
265
                        AnchorChanges { target: textContainer; anchors.top: searchContainer.bottom }
242
266
                        AnchorChanges { target: searchContainer; anchors.left: headerContainer.left; anchors.top: headerContainer.top }
243
267
                    },
244
268
                    State {
276
300
                            ParallelAnimation {
277
301
                                NumberAnimation { targets: [searchContainer, searchField]; property: "width"; duration: 200; easing.type: Easing.InOutQuad }
278
302
                                PropertyAction  { target: primaryImage; property: "source" }
279
 
                                AnchorAnimation { targets: [searchContainer, itemContainer]; duration: 200; easing.type: Easing.InOutQuad }
 
303
                                AnchorAnimation { targets: [searchContainer, textContainer]; duration: 200; easing.type: Easing.InOutQuad }
280
304
                            }
281
305
                            ScriptAction { script: if (searchContainer.popoverShouldOpen) { searchContainer.openPopover(); } }
282
306
                        }
285
309
                        to: "inactive"
286
310
                        ScriptAction { script: if (searchContainer.popoverShouldClose) { searchContainer.closePopover(); } }
287
311
                        NumberAnimation { targets: [searchContainer, searchField] ; property: "width"; duration: 200; easing.type: Easing.InOutQuad }
288
 
                        AnchorAnimation { targets: [searchContainer, itemContainer]; duration: 200; easing.type: Easing.InOutQuad }
 
312
                        AnchorAnimation { targets: [searchContainer, textContainer]; duration: 200; easing.type: Easing.InOutQuad }
289
313
                    },
290
314
                    Transition {
291
315
                        to: "narrowActive"
292
316
                        SequentialAnimation {
293
317
                            ParallelAnimation {
294
318
                                NumberAnimation { targets: [searchContainer, searchField] ; property: "width"; duration: 200; easing.type: Easing.OutQuad }
295
 
                                AnchorAnimation { targets: [searchContainer, itemContainer]; duration: 200; easing.type: Easing.InOutQuad }
 
319
                                AnchorAnimation { targets: [searchContainer, textContainer]; duration: 200; easing.type: Easing.InOutQuad }
296
320
                            }
297
321
                            ScriptAction { script: if (searchContainer.popoverShouldOpen) { searchContainer.openPopover(); } }
298
322
                        }
301
325
                        to: "narrowInactive"
302
326
                        ScriptAction { script: if (searchContainer.popoverShouldClose) { searchContainer.closePopover(); } }
303
327
                        NumberAnimation { targets: [searchContainer, searchField] ; property: "width"; duration: 200; easing.type: Easing.OutQuad }
304
 
                        AnchorAnimation { targets: [searchContainer, itemContainer]; duration: 200; easing.type: Easing.InOutQuad }
 
328
                        AnchorAnimation { targets: [searchContainer, textContainer]; duration: 200; easing.type: Easing.InOutQuad }
305
329
                    }
306
330
                ]
307
331