@@ -43,7 +43,7 @@ Indicators.IndicatorBase {
45 id: itemLeftLabel
45 id: itemLeftLabel
46− width: guRoundUp(implicitWidth)
46+ width: paintedWidth + units.gu(1)
47 objectName: "leftLabel"
47 objectName: "leftLabel"
48 color: Theme.palette.selected.backgroundText
48 color: Theme.palette.selected.backgroundText
49 opacity: 0.8
49 opacity: 0.8
@@ -51,6 +51,7 @@ Indicators.IndicatorBase {
51 fontSize: "medium"
51 fontSize: "medium"
52 anchors.verticalCenter: parent.verticalCenter
52 anchors.verticalCenter: parent.verticalCenter
53 visible: text != ""
53 visible: text != ""
54+ horizontalAlignment: Text.AlignHCenter
@@ -63,20 +64,67 @@ Indicators.IndicatorBase {
63 model: indicatorWidget.icons
64 model: indicatorWidget.icons
66− width: guRoundUp(itemImage.width) + units.gu(1)
67+ width: itemImage.width + units.gu(1)
67 anchors { top: parent.top; bottom: parent.bottom }
68 anchors { top: parent.top; bottom: parent.bottom }
71+ FIXME: should use Icon and the theme system
72+ There is an Icon component in the SDK that the colorization is copied from.
73+ We can't use it here unfortunately due to lack of support for image source
74+ URIs and keeping aspect ratio.
77+ http://launchpad.net/bugs/1284235
78+ http://launchpad.net/bugs/1284233
70 id: itemImage
82 id: itemImage
71 objectName: "itemImage"
83 objectName: "itemImage"
72− // FIXME: Should be dynamic width, see http://pad.lv/1284235
73− width: indicatorWidget.iconSize
74 height: indicatorWidget.iconSize
84 height: indicatorWidget.iconSize
85+ sourceSize.height: height
75 anchors.centerIn: parent
86 anchors.centerIn: parent
77− // FIXME: Icon needs to accept source, see http://pad.lv/1284233
88+ onSourceChanged: console.debug(source)
91+ property string iconPath: "/usr/share/icons/suru/status/scalable/%1.svg"
78− name: modelData.replace("image://theme/", "")
92+ property var icons: modelData.replace("image://theme/", "").split(",")
93+ property int fallback: 0
95+ onStatusChanged: if (status == Image.Error && fallback < icons.length - 1) fallback += 1;
97+ // Needed to not introduce a binding loop on source
98+ onFallbackChanged: updateSource()
99+ Component.onCompleted: updateSource()
100+ onIconsChanged: updateSource()
102+ function updateSource() {
103+ source = icons.length > 0 ? iconPath.arg(icons[fallback]) : "";
110+ anchors.fill: itemImage
112+ property Image source: itemImage.status == Image.Ready ? itemImage : null
79− color: "#CCCCCC"
113+ property color keyColorOut: "#CCCCCC"
114+ property color keyColorIn: "#808080"
115+ property real threshold: 0.1
118+ varying highp vec2 qt_TexCoord0;
119+ uniform sampler2D source;
120+ uniform highp vec4 keyColorOut;
121+ uniform highp vec4 keyColorIn;
122+ uniform lowp float threshold;
123+ uniform lowp float qt_Opacity;
125+ lowp vec4 sourceColor = texture2D(source, qt_TexCoord0);
126+ gl_FragColor = mix(vec4(keyColorOut.rgb, 1.0) * sourceColor.a, sourceColor, step(threshold, distance(sourceColor.rgb / sourceColor.a, keyColorIn.rgb))) * qt_Opacity;
@@ -84,7 +132,7 @@ Indicators.IndicatorBase {
86 id: itemRightLabel
134 id: itemRightLabel
87− width: guRoundUp(implicitWidth)
135+ width: paintedWidth + units.gu(1)
88 objectName: "rightLabel"
136 objectName: "rightLabel"
89 color: Theme.palette.selected.backgroundText
137 color: Theme.palette.selected.backgroundText
90 opacity: 0.8
138 opacity: 0.8
@@ -92,20 +140,10 @@ Indicators.IndicatorBase {
92 fontSize: "medium"
140 fontSize: "medium"
93 anchors.verticalCenter: parent.verticalCenter
141 anchors.verticalCenter: parent.verticalCenter
94 visible: text != ""
142 visible: text != ""
143+ horizontalAlignment: Text.AlignHCenter
98− // TODO: Use toolkit function https://bugs.launchpad.net/ubuntu-ui-toolkit/+bug/1242575
99− function guRoundUp(width) {
103− var gu1 = units.gu(1.0);
104− var mod = (width % gu1);
106− return mod == 0 ? width : width + (gu1 - mod);
109 onRootActionStateChanged: {
147 onRootActionStateChanged: {
110 if (rootActionState == undefined) {
148 if (rootActionState == undefined) {
111 leftLabel = "";
149 leftLabel = "";