Changeset View
Changeset View
Standalone View
Standalone View
applets/kimpanel/package/contents/ui/main.qml
Show All 21 Lines | |||||
22 | import org.kde.plasma.core 2.0 as PlasmaCore | 22 | import org.kde.plasma.core 2.0 as PlasmaCore | ||
23 | import org.kde.plasma.components 2.0 as PlasmaComponents | 23 | import org.kde.plasma.components 2.0 as PlasmaComponents | ||
24 | import org.kde.kquickcontrolsaddons 2.0 | 24 | import org.kde.kquickcontrolsaddons 2.0 | ||
25 | 25 | | |||
26 | Item { | 26 | Item { | ||
27 | id: kimpanel | 27 | id: kimpanel | ||
28 | property int visibleButtons: 0 | 28 | property int visibleButtons: 0 | ||
29 | 29 | | |||
30 | Layout.minimumWidth: vertical ? 0 : height * visibleButtons | | |||
31 | Layout.minimumHeight: vertical ? width * visibleButtons : 0 | | |||
32 | Layout.preferredWidth: Layout.minimumWidth | | |||
33 | Layout.preferredHeight: Layout.minimumHeight | | |||
34 | | ||||
35 | property bool vertical: plasmoid.formFactor == PlasmaCore.Types.Vertical | 30 | property bool vertical: plasmoid.formFactor == PlasmaCore.Types.Vertical | ||
36 | 31 | | |||
32 | LayoutMirroring.enabled: !vertical && Qt.application.layoutDirection === Qt.RightToLeft | ||||
33 | LayoutMirroring.childrenInherit: true | ||||
34 | | ||||
35 | Layout.minimumWidth: vertical ? units.iconSizes.small : items.implicitWidth | ||||
36 | Layout.minimumHeight: !vertical ? units.iconSizes.small : items.implicitHeight | ||||
37 | Layout.preferredHeight: Layout.minimumHeight | ||||
37 | Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation | 38 | Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation | ||
38 | 39 | | |||
39 | InputPanel { } | 40 | InputPanel { } | ||
40 | 41 | | |||
41 | GridView { | 42 | Flow { | ||
42 | id: items | 43 | id: items | ||
43 | property int itemWidth: !kimpanel.vertical ? Math.floor(parent.width/visibleButtons) : parent.width | 44 | width: parent.width | ||
44 | property int itemHeight: kimpanel.vertical ? Math.floor(parent.height/visibleButtons) : parent.height | 45 | height: parent.height | ||
45 | property int iconSize: Math.min(itemWidth, itemHeight) | 46 | x: (parent.width - childrenRect.width) / 2 | ||
46 | anchors.fill: parent | 47 | y: (parent.height - childrenRect.height) / 2 | ||
47 | cellWidth: itemWidth | 48 | flow: kimpanel.vertical ? Flow.LeftToRight : Flow.TopToBottom | ||
48 | cellHeight: itemHeight | | |||
49 | interactive: false | | |||
50 | 49 | | |||
50 | property int iconSize: Math.min(units.iconSizeHints.panel, units.roundToIconSize(Math.min(width, height))) | ||||
51 | | ||||
52 | Repeater { | ||||
51 | model: ListModel { | 53 | model: ListModel { | ||
52 | id: list | 54 | id: list | ||
53 | dynamicRoles: true | 55 | dynamicRoles: true | ||
54 | } | 56 | } | ||
55 | 57 | | |||
56 | delegate: Item { | 58 | delegate: Item { | ||
57 | id: iconDelegate | 59 | id: iconDelegate | ||
58 | width: items.itemWidth | 60 | width: items.iconSize | ||
59 | height: items.itemHeight | 61 | height: items.iconSize | ||
60 | StatusIcon { | 62 | StatusIcon { | ||
61 | id: statusIcon | 63 | id: statusIcon | ||
62 | anchors.centerIn: parent | 64 | anchors.centerIn: parent | ||
63 | width: items.iconSize | 65 | width: items.iconSize | ||
64 | height: items.iconSize | 66 | height: items.iconSize | ||
65 | label: model.label | 67 | label: model.label | ||
66 | tip: model.tip | 68 | tip: model.tip | ||
67 | icon: model.icon | 69 | icon: model.icon | ||
68 | hint: model.hint | 70 | hint: model.hint | ||
69 | onTriggered : { | 71 | onTriggered : { | ||
70 | if (button == Qt.LeftButton) { | 72 | if (button == Qt.LeftButton) { | ||
71 | clickHandler(model.key) | 73 | clickHandler(model.key) | ||
72 | } else { | 74 | } else { | ||
73 | contextMenu.open(statusIcon, {key: model.key, label: model.label}); | 75 | contextMenu.open(statusIcon, {key: model.key, label: model.label}); | ||
74 | } | 76 | } | ||
75 | } | 77 | } | ||
76 | } | 78 | } | ||
77 | } | 79 | } | ||
78 | } | 80 | } | ||
81 | } | ||||
79 | 82 | | |||
80 | function clickHandler(key) { | 83 | function clickHandler(key) { | ||
81 | var service = dataEngine.serviceForSource("statusbar"); | 84 | var service = dataEngine.serviceForSource("statusbar"); | ||
82 | var operation = service.operationDescription("TriggerProperty"); | 85 | var operation = service.operationDescription("TriggerProperty"); | ||
83 | operation.key = key; | 86 | operation.key = key; | ||
84 | service.startOperationCall(operation); | 87 | service.startOperationCall(operation); | ||
85 | } | 88 | } | ||
86 | 89 | | |||
▲ Show 20 Lines • Show All 122 Lines • Show Last 20 Lines |