Changeset View
Changeset View
Standalone View
Standalone View
applets/kimpanel/package/contents/ui/main.qml
Show All 16 Lines | |||||
17 | */ | 17 | */ | ||
18 | 18 | | |||
19 | import QtQuick 2.0 | 19 | import QtQuick 2.0 | ||
20 | import QtQuick.Layouts 1.1 | 20 | import QtQuick.Layouts 1.1 | ||
21 | import org.kde.plasma.plasmoid 2.0 | 21 | import org.kde.plasma.plasmoid 2.0 | ||
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 | import org.kde.plasma.workspace.keyboardlayout 1.0 | ||||
25 | 26 | | |||
26 | Item { | 27 | Item { | ||
27 | id: kimpanel | 28 | id: kimpanel | ||
28 | property int visibleButtons: 0 | 29 | property int visibleButtons: 0 | ||
29 | 30 | | |||
30 | property bool vertical: plasmoid.formFactor === PlasmaCore.Types.Vertical | 31 | property bool vertical: plasmoid.formFactor === PlasmaCore.Types.Vertical | ||
31 | 32 | | |||
32 | LayoutMirroring.enabled: !vertical && Qt.application.layoutDirection === Qt.RightToLeft | 33 | LayoutMirroring.enabled: !vertical && Qt.application.layoutDirection === Qt.RightToLeft | ||
33 | LayoutMirroring.childrenInherit: true | 34 | LayoutMirroring.childrenInherit: true | ||
34 | 35 | | |||
35 | Layout.minimumWidth: vertical ? units.iconSizes.small : items.implicitWidth | 36 | Layout.minimumWidth: vertical ? units.iconSizes.small : items.implicitWidth | ||
36 | Layout.minimumHeight: !vertical ? units.iconSizes.small : items.implicitHeight | 37 | Layout.minimumHeight: !vertical ? units.iconSizes.small : items.implicitHeight | ||
37 | Layout.preferredHeight: Layout.minimumHeight | 38 | Layout.preferredHeight: Layout.minimumHeight | ||
38 | Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation | 39 | Plasmoid.preferredRepresentation: Plasmoid.fullRepresentation | ||
39 | 40 | | |||
40 | InputPanel { } | 41 | InputPanel { } | ||
41 | 42 | | |||
42 | Flow { | 43 | Flow { | ||
43 | id: items | 44 | id: items | ||
44 | width: parent.width | 45 | width: parent.width | ||
45 | height: parent.height | 46 | height: parent.height | ||
46 | x: (parent.width - childrenRect.width) / 2 | 47 | anchors.centerIn: parent | ||
davidedmundson: anchors.fill | |||||
47 | y: (parent.height - childrenRect.height) / 2 | | |||
48 | flow: kimpanel.vertical ? Flow.LeftToRight : Flow.TopToBottom | 48 | flow: kimpanel.vertical ? Flow.LeftToRight : Flow.TopToBottom | ||
49 | 49 | | |||
50 | property int iconSize: Math.min(units.iconSizeHints.panel, units.roundToIconSize(Math.min(width, height))) | 50 | property int iconSize: units.roundToIconSize(Math.min(width, height)) | ||
51 | | ||||
52 | StatusIcon { | ||||
53 | readonly property QtObject kl: KeyboardLayout { | ||||
54 | id: layout | ||||
55 | function nextLayout() { | ||||
56 | var layouts = layout.layouts; | ||||
57 | var index = (layouts.indexOf(layout.currentLayout)+1) % layouts.length; | ||||
58 | layout.currentLayout = layouts[index]; | ||||
59 | } | ||||
60 | } | ||||
61 | | ||||
62 | width: visible ? items.iconSize : 0 | ||||
63 | height: items.iconSize | ||||
64 | visible: list.count === 0 | ||||
65 | label: layout.currentLayout.substr(0, 2).toLowerCase() | ||||
66 | tip: layout.currentLayout | ||||
67 | onTriggered: if (button === Qt.LeftButton) { | ||||
68 | layout.nextLayout() | ||||
69 | } | ||||
70 | } | ||||
51 | 71 | | |||
52 | Repeater { | 72 | Repeater { | ||
53 | model: ListModel { | 73 | model: ListModel { | ||
54 | id: list | 74 | id: list | ||
55 | dynamicRoles: true | 75 | dynamicRoles: true | ||
56 | } | 76 | } | ||
57 | 77 | | |||
58 | delegate: Item { | 78 | delegate: StatusIcon { | ||
59 | id: iconDelegate | | |||
60 | width: items.iconSize | | |||
61 | height: items.iconSize | | |||
62 | StatusIcon { | | |||
63 | id: statusIcon | 79 | id: statusIcon | ||
64 | anchors.centerIn: parent | | |||
65 | width: items.iconSize | | |||
66 | height: items.iconSize | | |||
67 | label: model.label | 80 | label: model.label | ||
68 | tip: model.tip | 81 | tip: model.tip | ||
69 | icon: model.icon | 82 | icon: model.icon | ||
70 | hint: model.hint | 83 | hint: model.hint | ||
71 | onTriggered : { | 84 | onTriggered : { | ||
72 | if (button === Qt.LeftButton) { | 85 | if (button === Qt.LeftButton) { | ||
73 | clickHandler(model.key); | 86 | clickHandler(model.key); | ||
74 | // clickHandler will trigger the menu, but we have to wait for | 87 | // clickHandler will trigger the menu, but we have to wait for | ||
75 | // the menu data. So we have to set the visual parent ahead. | 88 | // the menu data. So we have to set the visual parent ahead. | ||
76 | actionMenu.visualParent = statusIcon; | 89 | actionMenu.visualParent = statusIcon; | ||
77 | } else { | 90 | } else { | ||
78 | contextMenu.open(statusIcon, {key: model.key, label: model.label}); | 91 | contextMenu.open(statusIcon, {key: model.key, label: model.label}); | ||
79 | } | 92 | } | ||
80 | } | 93 | } | ||
81 | } | 94 | } | ||
82 | } | 95 | } | ||
83 | } | 96 | } | ||
84 | } | | |||
85 | 97 | | |||
86 | function clickHandler(key) { | 98 | function clickHandler(key) { | ||
87 | var service = dataEngine.serviceForSource("statusbar"); | 99 | var service = dataEngine.serviceForSource("statusbar"); | ||
88 | var operation = service.operationDescription("TriggerProperty"); | 100 | var operation = service.operationDescription("TriggerProperty"); | ||
89 | operation.key = key; | 101 | operation.key = key; | ||
90 | service.startOperationCall(operation); | 102 | service.startOperationCall(operation); | ||
91 | } | 103 | } | ||
92 | 104 | | |||
▲ Show 20 Lines • Show All 122 Lines • Show Last 20 Lines |
anchors.fill