KeyboardLayoutButton.qml 1.19 KB
Newer Older
1 2 3 4 5
/*
 * SPDX-FileCopyrightText: 2014 Daniel Vrátil <dvratil@redhat.com>
 * SPDX-FileCopyrightText: 2020 Andrey Butirsky <butirsky@gmail.com>
 * SPDX-License-Identifier: GPL-2.0-or-later
 */
6

7
import QtQuick 2.12
8
import org.kde.plasma.components 3.0 as PlasmaComponents3
9
import org.kde.plasma.workspace.keyboardlayout 1.0
10

11
PlasmaComponents3.ToolButton {
12
    property alias keyboardLayout: keyboardLayout
13 14
    readonly property bool hasMultipleKeyboardLayouts: keyboardLayout.layoutsList.length > 1
    readonly property var layoutNames: keyboardLayout.layoutsList[keyboardLayout.layout]
15

16
    text: layoutNames.longName
17
    visible: hasMultipleKeyboardLayouts
18

19 20
    Accessible.name: i18ndc("plasma_lookandfeel_org.kde.lookandfeel", "Button to change keyboard layout", "Switch layout")
    icon.name: "input-keyboard"
21

22
    onClicked: keyboardLayout.switchToNextLayout()
23

24 25 26 27 28
    MouseArea {
        anchors.fill: parent
        acceptedButtons: Qt.NoButton
        onWheel: {
            if (wheel.angleDelta.y > 0) {
29
                keyboardLayout.switchToPreviousLayout()
30 31
            } else {
                keyboardLayout.switchToNextLayout()
32 33 34 35
            }
        }
    }

36
    KeyboardLayout {
37
        id: keyboardLayout
38 39
    }
}