~om26er/unity8/launcher_integration_test

« back to all changes in this revision

Viewing changes to qml/Panel/Indicators/DefaultIndicatorWidget.qml

  • Committer: Omer Akram
  • Date: 2014-07-03 13:24:52 UTC
  • mfrom: (984.1.14 unity8)
  • Revision ID: om26er@ubuntu.com-20140703132452-zi2e9z465998ezjb
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
19
19
 
20
20
import QtQuick 2.0
21
21
import Ubuntu.Components 0.1
 
22
import Ubuntu.Settings.Components 0.1
22
23
import Unity.Indicators 0.1 as Indicators
23
24
 
24
25
Indicators.IndicatorBase {
25
26
    id: indicatorWidget
26
27
 
27
 
    property int iconSize: height
 
28
    property int iconSize: units.gu(2)
28
29
    property alias leftLabel: itemLeftLabel.text
29
30
    property alias rightLabel: itemRightLabel.text
30
31
    property var icons: undefined
34
35
 
35
36
    Row {
36
37
        id: itemRow
37
 
        width: childrenRect.width
38
38
        objectName: "itemRow"
39
39
        anchors {
40
40
            top: parent.top
44
44
 
45
45
        Label {
46
46
            id: itemLeftLabel
47
 
            width: guRoundUp(implicitWidth)
 
47
            width: contentWidth + units.gu(1)
48
48
            objectName: "leftLabel"
49
49
            color: Theme.palette.selected.backgroundText
50
50
            opacity: 0.8
52
52
            fontSize: "medium"
53
53
            anchors.verticalCenter: parent.verticalCenter
54
54
            visible: text != ""
 
55
            horizontalAlignment: Text.AlignHCenter
55
56
        }
56
57
 
57
58
        Row {
58
 
            width: childrenRect.width
59
59
            anchors {
60
60
                top: parent.top
61
61
                bottom: parent.bottom
65
65
                model: indicatorWidget.icons
66
66
 
67
67
                Item {
68
 
                    width: guRoundUp(itemImage.width)
69
 
                    height: indicatorWidget.iconSize
 
68
                    width: itemImage.width + units.gu(1)
 
69
                    anchors { top: parent.top; bottom: parent.bottom }
70
70
 
71
 
                    Image {
 
71
                    StatusIcon {
72
72
                        id: itemImage
73
 
                        objectName: "itemImage"
74
 
                        visible: source != ""
 
73
                        height: indicatorWidget.iconSize
 
74
                        anchors.centerIn: parent
75
75
                        source: modelData
76
 
                        height: parent.height
77
 
                        anchors.horizontalCenter: parent.horizontalCenter
78
 
                        fillMode: Image.PreserveAspectFit
79
 
 
80
 
                        sourceSize {
81
 
                            width: indicatorWidget.iconSize
82
 
                            height: indicatorWidget.iconSize
83
 
                        }
 
76
                        sets: ["status", "actions"]
 
77
                        color: "#CCCCCC"
84
78
                    }
85
79
                }
86
80
            }
88
82
 
89
83
        Label {
90
84
            id: itemRightLabel
91
 
            width: guRoundUp(implicitWidth)
 
85
            width: contentWidth + units.gu(1)
92
86
            objectName: "rightLabel"
93
87
            color: Theme.palette.selected.backgroundText
94
88
            opacity: 0.8
96
90
            fontSize: "medium"
97
91
            anchors.verticalCenter: parent.verticalCenter
98
92
            visible: text != ""
99
 
        }
100
 
    }
101
 
 
102
 
    // TODO: Use toolkit function https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1242575
103
 
    function guRoundUp(width) {
104
 
        if (width == 0) {
105
 
            return 0;
106
 
        }
107
 
        var gu1 = units.gu(1.0);
108
 
        var mod = (width % gu1);
109
 
 
110
 
        return mod == 0 ? width : width + (gu1 - mod);
 
93
            horizontalAlignment: Text.AlignHCenter
 
94
        }
111
95
    }
112
96
 
113
97
    onRootActionStateChanged: {