Changeset View
Changeset View
Standalone View
Standalone View
applets/kimpanel/package/contents/ui/StatusIcon.qml
Show All 26 Lines | 26 | Item { | |||
---|---|---|---|---|---|
27 | id: statusIcon | 27 | id: statusIcon | ||
28 | property string icon; | 28 | property string icon; | ||
29 | property string label; | 29 | property string label; | ||
30 | property string tip; | 30 | property string tip; | ||
31 | property string hint; | 31 | property string hint; | ||
32 | signal triggered(variant button); | 32 | signal triggered(variant button); | ||
33 | property int iconSize: units.roundToIconSize(Math.min(parent.width, parent.height)) | 33 | property int iconSize: units.roundToIconSize(Math.min(parent.width, parent.height)) | ||
34 | 34 | | |||
35 | width: iconSize | ||||
36 | height: iconSize | ||||
35 | opacity: 'disable' == hint ? 0.3 : 1 | 37 | opacity: 'disable' == hint ? 0.3 : 1 | ||
36 | 38 | | |||
37 | function extractLabelString(l) { | 39 | function extractLabelString(l) { | ||
38 | if (l.length >= 2 && l.charCodeAt(0) < 127 && l.charCodeAt(1) < 127) { | 40 | if (l.length >= 2 && l.charCodeAt(0) < 127 && l.charCodeAt(1) < 127) { | ||
39 | return l.substring(0, 2); | 41 | return l.substring(0, 2); | ||
40 | } else { | 42 | } else { | ||
41 | return l.substring(0, 1); | 43 | return l.substring(0, 1); | ||
42 | } | 44 | } | ||
43 | } | 45 | } | ||
44 | 46 | | |||
45 | function iconPath(p) { | | |||
46 | if (p.length > 0) { | | |||
47 | if (p[0] === '/') { | | |||
48 | return p; | | |||
49 | } else { | | |||
50 | return "image://icon/" + p; | | |||
51 | } | | |||
52 | } | | |||
53 | return p; | | |||
54 | } | | |||
55 | | ||||
56 | PlasmaCore.IconItem { | 47 | PlasmaCore.IconItem { | ||
57 | id: imageIcon | 48 | id: imageIcon | ||
58 | anchors.centerIn: parent | 49 | anchors.fill: parent | ||
59 | width: iconSize | | |||
60 | height: iconSize | | |||
61 | scale: mouseArea.pressed ? 0.9 : 1 | 50 | scale: mouseArea.pressed ? 0.9 : 1 | ||
62 | source: statusIcon.icon | 51 | source: statusIcon.icon | ||
63 | visible: statusIcon.icon.length > 0 | 52 | visible: statusIcon.icon.length > 0 | ||
64 | animated: false | 53 | animated: false | ||
65 | // active: mouseArea.containsMouse | 54 | // active: mouseArea.containsMouse | ||
66 | } | 55 | } | ||
67 | PlasmaComponents.Label { | 56 | PlasmaComponents.Label { | ||
68 | id: textIcon | 57 | id: textIcon | ||
69 | anchors.centerIn: parent | 58 | anchors.fill: parent | ||
70 | width: iconSize | | |||
71 | height: iconSize | | |||
72 | scale: (mouseArea.pressed ? 0.9 : 1) | 59 | scale: (mouseArea.pressed ? 0.9 : 1) | ||
73 | // a reasonable large size to make Text.Fit work | 60 | // a reasonable large size to make Text.Fit work | ||
74 | minimumPointSize: 0 | 61 | minimumPointSize: theme.smallestFont.pointSize | ||
75 | font.pointSize: 1024 | 62 | font.pointSize: 1024 | ||
76 | fontSizeMode: Text.Fit | 63 | fontSizeMode: Text.Fit | ||
77 | verticalAlignment: Text.AlignVCenter | 64 | verticalAlignment: Text.AlignVCenter | ||
78 | horizontalAlignment: Text.AlignHCenter | 65 | horizontalAlignment: Text.AlignHCenter | ||
79 | text: extractLabelString(label) | 66 | text: extractLabelString(label) | ||
80 | visible: icon.length == 0 | 67 | visible: icon.length == 0 | ||
81 | } | 68 | } | ||
82 | 69 | | |||
Show All 17 Lines |