This file is indexed.

/usr/lib/x86_64-linux-gnu/qt5/qml/Ubuntu/Components/Themes/Ambiance/1.3/SectionsStyle.qml is in ubuntu-ui-toolkit-theme 1.3.1918+16.04.20160404-0ubuntu1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
/*
 * Copyright 2016 Canonical Ltd.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU Lesser General Public License as published by
 * the Free Software Foundation; version 3.
 *
 * 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 Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
import QtQuick 2.4
import QtQuick.Window 2.2
import Ubuntu.Components 1.3
import QtGraphicalEffects 1.0
import Ubuntu.Components.Private 1.3

Item {
    id: sectionsStyle

    implicitWidth: sectionsListView.contentWidth + 2 * listViewContainer.listViewMargins
    implicitHeight: Screen.height > units.gu(50) ? units.gu(4) : units.gu(3)

    /*!
      The foreground color of unselected sections.
     */
    property color sectionColor: enabled
                                 ? theme.palette.normal.backgroundTertiaryText
                                 : theme.palette.disabled.backgroundTertiaryText

    /*!
      The foreground color of underline rectangle of unselected sections.
     */
    property color underlineColor: theme.palette.normal.base

    /*!
      The foreground color of the selected section.
     */
    property color selectedSectionColor: enabled
                                         ? theme.palette.selected.backgroundTertiaryText
                                         : theme.palette.selectedDisabled.backgroundTertiaryText

    /*!
      The background color for the pressed section button.
     */
    property color pressedBackgroundColor: theme.palette.highlighted.background

    /*!
      The size of text in the buttons.
     */
    property int textSize: Label.Medium

    /*!
      The spacing on the left and right sides of the label
      inside a section button.
     */
    property real horizontalLabelSpacing: units.gu(2)

    /*!
      The height of the bar underlining the sections.
     */
    property real underlineHeight: units.dp(2)

    // We don't clip listview on purpose, so we have to clip here to prevent Sections element
    // from painting outside its area.
    clip: true

    //This item is needed for the OpacityMask feature. It is needed to make sure that when we
    //bring a list element into view, that element won't be covered by the opacity mask. So we
    //disable clipping on the list but we give it margins. This way when an item is repositioned
    //to be within the listview, that item will not be positioned under the opacity mask. (which is
    //what would have happened if the listview were filling the parent)
    Item {
        id: listViewContainer
        anchors.fill: parent

        property real listViewMargins: units.gu(2)

        //We need to set this to 0.0 when OpacityMask will draw this listview for us.
        //we don't set visible: false because we still want to get the input events!
        opacity: 1.0

        ListView {
            id: sectionsListView
            objectName: "sections_listview"

            property bool animateContentX: false
            activeFocusOnTab: false // FIXME: Enable proper focus handling

            // Position the selected item correctly.
            // For a scrollable ListView, if the item was already fully visible,
            //  no repositioning is needed. If the item was (partially) invisible,
            //  position it so that it becomes fully visible.
            // If the ListView is not scrollable, the first item will be aligned with
            //  the left of the ListView.
            function positionItem(item) {
                if (item !== null) {
                    //stop the flick before doing computations
                    if (moving) {
                        return;
                    }
                    if (dragging || flicking) {
                        cancelFlick();
                    }
                    if (contentXAnim.running) {
                        contentXAnim.stop();
                    }

                    contentXAnim.from = contentX;
                    //make sure we don't overshoot bounds
                    if (sectionsListView.contentWidth <= sectionsListView.width) {
                        // No scrolling, position the sections on the left.
                        contentXAnim.to = originX;
                    } else {
                        // Position the selected Item so that it is fully visible.
                        contentXAnim.to = MathUtils.clamp(contentX, originX, originX + contentWidth - width);
                    }
                    if (contentXAnim.from !== contentXAnim.to) {
                        contentXAnim.start();
                    }
                }
            }

            anchors {
                fill: parent
                leftMargin: listViewContainer.listViewMargins
                rightMargin: listViewContainer.listViewMargins
            }

            //this is just to disable keyboard navigation to avoid messing with contentX/contentWidth while
            //the view is moving
            focus: !moving

            onWidthChanged: positionItem(currentItem)
            //make sure that the currentItem is in the middle when everything is initialized
            Component.onCompleted: positionItem(currentItem)

            orientation: ListView.Horizontal
            boundsBehavior: Flickable.StopAtBounds

            model: styledItem.model

            //We need this to make sure that we have delegates for the whole width, since we have
            //clip disabled.
            displayMarginBeginning: listViewContainer.listViewMargins
            displayMarginEnd: listViewContainer.listViewMargins

            currentIndex: styledItem.selectedIndex
            onCurrentIndexChanged: {
                styledItem.selectedIndex = currentIndex;
            }
            onCurrentItemChanged: {
                //adjust contentX so that the item is kept in the middle
                //don't use ListView.ApplyRange because that does an awkward animation when you select an item
                //*while* the current item is outside of screen
                positionItem(currentItem);
            }

            highlightFollowsCurrentItem: false
            highlight: Item {
                //show the highlight on top of the delegate
                z: 2
                x: sectionsListView.currentItem ? sectionsListView.currentItem.x : -width
                width: sectionsListView.currentItem ? sectionsListView.currentItem.width : 0
                height: sectionsListView.currentItem ? sectionsListView.currentItem.height : 0

                Rectangle {
                    anchors {
                        bottom: parent.bottom
                        left: parent.left
                        right: parent.right
                    }
                    height: sectionsStyle.underlineHeight
                    color: sectionsStyle.selectedSectionColor
                }
                Behavior on x { UbuntuNumberAnimation {} }
            }

            delegate: AbstractButton {
                id: sectionButton
                activeFocusOnTab: false
                objectName: "section_button_" + index
                width: label.width + 2 * sectionsStyle.horizontalLabelSpacing
                height: sectionsStyle.height
                property bool selected: index === styledItem.selectedIndex
                onClicked: {
                    styledItem.selectedIndex = index;
                    sectionsListView.forceActiveFocus();
                }

                // Background pressed highlight
                Rectangle {
                    visible: parent.pressed
                    anchors.fill: parent
                    color: sectionsStyle.pressedBackgroundColor
                }

                // Section title
                Label {
                    id: label
                    objectName: "section_button_label_" + index
                    // modelData may be either a string, or an Action
                    text: modelData.hasOwnProperty("text") ? modelData.text : modelData
                    textSize: sectionsStyle.textSize
                    font.weight: Font.Light
                    anchors {
                        baseline: underline.bottom
                        baselineOffset: sectionsStyle.height < units.gu(4) ? -units.gu(1) : -units.gu(2)
                        horizontalCenter: parent.horizontalCenter
                    }

                    color: sectionButton.selected ?
                               sectionsStyle.selectedSectionColor :
                               sectionsStyle.sectionColor

                    Behavior on color {
                        ColorAnimation { duration: UbuntuAnimation.SlowDuration }
                    }
                }

                // Section title underline
                Rectangle {
                    id: underline
                    anchors {
                        bottom: parent.bottom
                        left: parent.left
                        right: parent.right
                    }
                    height: sectionsStyle.underlineHeight
                    color: sectionsStyle.underlineColor
                }
            }

            SmoothedAnimation {
                objectName: "sections_scroll_animation"
                id: contentXAnim
                target: sectionsListView
                property: "contentX"
                duration: UbuntuAnimation.FastDuration
                velocity: units.gu(10)
            }
        }
    }

    MouseArea {
        // Detect hovering over the left and right areas to show the scrolling chevrons.
        id: hoveringArea

        property real iconsDisabledOpacity: 0.3

        anchors.fill: parent
        hoverEnabled: true

        property bool pressedLeft: false
        property bool pressedRight: false
        onPressed: {
            pressedLeft = leftIcon.contains(mouse);
            pressedRight = rightIcon.contains(mouse);
            mouse.accepted = pressedLeft || pressedRight;
        }
        onClicked: {
            // positionViewAtIndex() does not provide animation
            var scrollDirection = 0;
            if (pressedLeft && leftIcon.contains(mouse)) {
                scrollDirection = -1;
            } else if (pressedRight && rightIcon.contains(mouse)) {
                scrollDirection = 1;
            } else {
                // User pressed on the left or right icon, and then released inside of the
                // MouseArea but outside of the icon that was pressed.
                return;
            }
            if (contentXAnim.running) contentXAnim.stop();
            var newContentX = sectionsListView.contentX + (sectionsListView.width * scrollDirection);
            contentXAnim.from = sectionsListView.contentX;
            // make sure we don't overshoot bounds
            contentXAnim.to = MathUtils.clamp(
                        newContentX,
                        0.0, // estimation of originX is some times wrong when scrolling towards the beginning
                        sectionsListView.originX + sectionsListView.contentWidth - sectionsListView.width);
            contentXAnim.start();
        }

        Icon {
            id: leftIcon
            objectName: "left_scroll_icon"
            // return whether the pressed event was done inside the area of the icon
            function contains(mouse) {
                return (mouse.x < listViewContainer.listViewMargins &&
                        !sectionsListView.atXBeginning);
            }
            anchors {
                left: parent.left
                leftMargin: (listViewContainer.listViewMargins - width) / 2
                bottom: parent.bottom
                bottomMargin: sectionsStyle.height < units.gu(4) ? units.gu(1) : units.gu(2)
            }
            width: units.gu(1)
            height: units.gu(1)
            visible: false
            rotation: 180
            opacity: visible
                     ? sectionsListView.atXBeginning ? hoveringArea.iconsDisabledOpacity : 1.0
                     : 0.0
            name: "chevron"
            Behavior on opacity {
                UbuntuNumberAnimation {
                    duration: UbuntuAnimation.FastDuration
                }
            }
        }

        Icon {
            id: rightIcon
            objectName: "right_scroll_icon"
            // return whether the pressed event was done inside the area of the icon
            function contains(mouse) {
                return (mouse.x > (hoveringArea.width - listViewContainer.listViewMargins) &&
                        !sectionsListView.atXEnd);
            }
            anchors {
                right: parent.right
                rightMargin: (listViewContainer.listViewMargins - width) / 2
                bottom: parent.bottom
                bottomMargin: sectionsStyle.height < units.gu(4) ? units.gu(1) : units.gu(2)
            }
            width: units.gu(1)
            height: units.gu(1)
            visible: false
            opacity: visible
                     ? sectionsListView.atXEnd ? hoveringArea.iconsDisabledOpacity : 1.0
                     : 0.0
            name: "chevron"
            Behavior on opacity {
                UbuntuNumberAnimation {
                    duration: UbuntuAnimation.FastDuration
                }
            }
        }
    }

    LinearGradient {
        id: gradient

        visible: false
        anchors.fill: parent
        start: Qt.point(0,0)
        end: Qt.point(width,0)

        property real gradientWidth: listViewContainer.listViewMargins / gradient.width
        //the width is gradientWidth, but we want the gradient to actually start/finish at gradientSplitPosition
        //just to leave some margin.
        property real gradientSplitPosition: 2/3 * gradientWidth

        gradient: Gradient {
            //left gradient
            GradientStop { position: 0.0 ; color: Qt.rgba(1,1,1,0) }
            GradientStop { position: gradient.gradientSplitPosition ; color: Qt.rgba(1,1,1,0) }
            GradientStop { position: gradient.gradientWidth; color: Qt.rgba(1,1,1,1) }
            //right gradient
            GradientStop { position: 1.0 - gradient.gradientWidth; color: Qt.rgba(1,1,1,1) }
            GradientStop { position: 1.0 - gradient.gradientSplitPosition; color: Qt.rgba(1,1,1,0) }
            GradientStop { position: 1.0; color: Qt.rgba(1,1,1,0) }
        }

            Rectangle {
                // full opacity for the underline at the bottom in the mask below
                anchors {
                    left: parent.left
                    right: parent.right
                    bottom: parent.bottom
                }
                height: sectionsStyle.underlineHeight
                color: "white"
            }
    }

    OpacityMask {
        id: mask
        anchors.fill: parent
        visible: false
        source: listViewContainer
        maskSource: gradient
    }

    states: [
        State {
            name: "hovering"
            when: hoveringArea.containsMouse
            PropertyChanges { target: mask; visible: true }
            PropertyChanges { target: listViewContainer; opacity: 0.0 }
            PropertyChanges { target: leftIcon; visible: true; }
            PropertyChanges { target: rightIcon; visible: true; }
        }
    ]
}