~ken-vandine/ubuntu-system-settings/no_s_i_d

« back to all changes in this revision

Viewing changes to src/qml/CategorySection.qml

  • Committer: Bileto Bot
  • Author(s): Ken VanDine
  • Date: 2016-07-22 14:38:13 UTC
  • mfrom: (1556.3.32 slotsLayout)
  • Revision ID: ci-train-bot@canonical.com-20160722143813-ht9e4766lm0ie5fa
Ported to use Slots layout and updated visuals (LP: #1596529)

Approved by: Jonas G. Drange

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * This file is part of system-settings
 
3
 *
 
4
 * Copyright (C) 2015-2016 Canonical Ltd.
 
5
 *
 
6
 * Contact: Ken VanDine <ken.vandine@canonical.com>
 
7
 *
 
8
 * This program is free software: you can redistribute it and/or modify it
 
9
 * under the terms of the GNU General Public License version 3, as published
 
10
 * by the Free Software Foundation.
 
11
 *
 
12
 * This program is distributed in the hope that it will be useful, but
 
13
 * WITHOUT ANY WARRANTY; without even the implied warranties of
 
14
 * MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
 
15
 * PURPOSE.  See the GNU General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU General Public License along
 
18
 * with this program.  If not, see <http://www.gnu.org/licenses/>.
 
19
 */
 
20
 
1
21
import QtQuick 2.4
 
22
import SystemSettings 1.0
 
23
import SystemSettings.ListItems 1.0 as SettingsListItems
2
24
import Ubuntu.Components 1.3
3
 
import Ubuntu.Components.ListItems 1.3 as ListItem
 
25
 
4
26
 
5
27
Column {
6
28
    anchors {
14
36
 
15
37
    objectName: "categoryGrid-" + category
16
38
 
17
 
    ListItem.Standard {
 
39
    SettingsItemTitle {
18
40
        id: header
19
 
 
20
 
        highlightWhenPressed: false
21
 
        showDivider: false
22
41
        text: categoryName
23
42
        visible: repeater.count > 0
24
43
    }
25
44
 
26
 
    Grid {
27
 
        property int itemWidth: units.gu(12)
28
 
 
29
 
        // The amount of whitespace, including column spacing
30
 
        property int space: parent.width - columns * itemWidth
31
 
 
32
 
        // The column spacing is 1/n of the left/right margins
33
 
        property int n: 4
34
 
 
35
 
        columnSpacing: space / ((2 * n) + (columns - 1))
36
 
        rowSpacing: units.gu(3)
37
 
        width: (columns * itemWidth) + columnSpacing * (columns - 1)
38
 
        anchors.horizontalCenter: parent.horizontalCenter
39
 
        columns: {
40
 
            var items = Math.floor(parent.width / itemWidth)
41
 
            var count = repeater.count
42
 
            return count < items ? count : items
 
45
    Column {
 
46
        id: col
 
47
        anchors {
 
48
            left: parent.left
 
49
            right: parent.right
43
50
        }
44
51
 
45
52
        Repeater {
49
56
 
50
57
            delegate: Loader {
51
58
                id: loader
52
 
                width: parent.itemWidth
 
59
                anchors {
 
60
                    left: col.left
 
61
                    right: col.right
 
62
                }
53
63
                sourceComponent: model.item.entryComponent
54
64
                active: model.item.visible
55
65
                Connections {
66
76
            }
67
77
        }
68
78
    }
69
 
    ListItem.ThinDivider { visible: header.visible }
70
79
}