2 * Copyright (C) 2016 Canonical, Ltd.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 3.
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details.
13 * You should have received a copy of the GNU General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 import AccountsService 0.1
19 import GlobalShortcut 1.0
20 import Unity.Application 0.1
25 property GlobalShortcut shortcutNext: GlobalShortcut {
26 shortcut: Qt.MetaModifier|Qt.Key_Space
27 onTriggered: root.nextKeymap()
28 active: root.keymapCount > 1
31 property GlobalShortcut shortcutPrevious: GlobalShortcut {
32 shortcut: Qt.MetaModifier|Qt.ShiftModifier|Qt.Key_Space
33 onTriggered: root.previousKeymap()
34 active: root.keymapCount > 1
37 readonly property var keymaps: AccountsService.keymaps
38 readonly property int keymapCount: keymaps.length
39 property int currentKeymapIndex: 0
40 readonly property string currentKeymap: keymaps[currentKeymapIndex]
42 function nextKeymap() {
45 if (currentKeymapIndex !== -1 && currentKeymapIndex < keymapCount - 1) {
46 nextIndex = currentKeymapIndex + 1;
48 currentKeymapIndex = nextIndex;
51 function previousKeymap() {
52 var prevIndex = keymapCount - 1;
54 if (currentKeymapIndex > 0) {
55 prevIndex = currentKeymapIndex - 1;
57 currentKeymapIndex = prevIndex;
60 property Binding surfaceKeymapBinding: Binding {
61 target: MirFocusController.focusedSurface
63 value: root.currentKeymap