diff --git a/components/workspace/KeyboardLayoutButton.qml b/components/workspace/KeyboardLayoutButton.qml deleted file mode 100644 index 17bf87ec8d6aa9ba8e2ce6c9643eaf0b34e555fa..0000000000000000000000000000000000000000 --- a/components/workspace/KeyboardLayoutButton.qml +++ /dev/null @@ -1,50 +0,0 @@ -/* - * SPDX-FileCopyrightText: 2014 Daniel Vrátil - * SPDX-FileCopyrightText: 2020 Andrey Butirsky - * SPDX-License-Identifier: GPL-2.0-or-later - */ - -import QtQuick 2.12 -import org.kde.plasma.components 3.0 as PlasmaComponents3 -import org.kde.plasma.workspace.keyboardlayout 1.0 - -PlasmaComponents3.ToolButton { - property alias keyboardLayout: keyboardLayout - readonly property bool hasMultipleKeyboardLayouts: keyboardLayout.layoutsList.length > 1 - readonly property var layoutNames: keyboardLayout.layoutsList.length ? keyboardLayout.layoutsList[keyboardLayout.layout] - : { shortName: "", displayName: "", longName: "" } - - text: layoutNames.longName - visible: hasMultipleKeyboardLayouts - - Accessible.name: i18ndc("plasma_lookandfeel_org.kde.lookandfeel", "Button to change keyboard layout", "Switch layout") - icon.name: "input-keyboard" - - onClicked: keyboardLayout.switchToNextLayout() - - MouseArea { - anchors.fill: parent - acceptedButtons: Qt.NoButton - - property int wheelDelta: 0 - - onWheel: { - // Magic number 120 for common "one click" - // See: https://qt-project.org/doc/qt-5/qml-qtquick-wheelevent.html#angleDelta-prop - var delta = wheel.angleDelta.y || wheel.angleDelta.x; - wheelDelta += delta; - while (wheelDelta >= 120) { - wheelDelta -= 120; - keyboardLayout.switchToPreviousLayout(); - } - while (wheelDelta <= -120) { - wheelDelta += 120; - keyboardLayout.switchToNextLayout(); - } - } - } - - KeyboardLayout { - id: keyboardLayout - } -} diff --git a/components/workspace/KeyboardLayoutSwitcher.qml b/components/workspace/KeyboardLayoutSwitcher.qml new file mode 100644 index 0000000000000000000000000000000000000000..aa194a57178e8c09c4bf1da7e31184b7c1253067 --- /dev/null +++ b/components/workspace/KeyboardLayoutSwitcher.qml @@ -0,0 +1,38 @@ +/* + * SPDX-FileCopyrightText: 2014 Daniel Vrátil + * SPDX-FileCopyrightText: 2020 Andrey Butirsky + * SPDX-License-Identifier: GPL-2.0-or-later + */ + +import QtQuick 2.12 +import org.kde.plasma.workspace.keyboardlayout 1.0 + +MouseArea { + property alias keyboardLayout: keyboardLayout + readonly property bool hasMultipleKeyboardLayouts: keyboardLayout.layoutsList.length > 1 + readonly property var layoutNames: keyboardLayout.layoutsList.length ? keyboardLayout.layoutsList[keyboardLayout.layout] + : { shortName: "", displayName: "", longName: "" } + + onClicked: keyboardLayout.switchToNextLayout() + + property int wheelDelta: 0 + + onWheel: { + // Magic number 120 for common "one click" + // See: https://qt-project.org/doc/qt-5/qml-qtquick-wheelevent.html#angleDelta-prop + var delta = wheel.angleDelta.y || wheel.angleDelta.x; + wheelDelta += delta; + while (wheelDelta >= 120) { + wheelDelta -= 120; + keyboardLayout.switchToPreviousLayout(); + } + while (wheelDelta <= -120) { + wheelDelta += 120; + keyboardLayout.switchToNextLayout(); + } + } + + KeyboardLayout { + id: keyboardLayout + } +} diff --git a/components/workspace/qmldir b/components/workspace/qmldir index a9ae39d24832085a648dc950935d9ba20d6471a7..9e70915ae813ad706363a6b1e092b37bd08f03ce 100644 --- a/components/workspace/qmldir +++ b/components/workspace/qmldir @@ -1,4 +1,4 @@ module org.kde.plasma.workspace.components BatteryIcon 2.0 BatteryIcon.qml -KeyboardLayoutButton 2.0 KeyboardLayoutButton.qml +KeyboardLayoutSwitcher 2.0 KeyboardLayoutSwitcher.qml diff --git a/lookandfeel/contents/lockscreen/LockScreenUi.qml b/lookandfeel/contents/lockscreen/LockScreenUi.qml index 1112b8397f633d0b37879bbc6f459ccff835dc08..5ed060d9b3fd4dd2cdf0d0f036de96a577c95a79 100644 --- a/lookandfeel/contents/lockscreen/LockScreenUi.qml +++ b/lookandfeel/contents/lockscreen/LockScreenUi.qml @@ -517,7 +517,21 @@ PlasmaCore.ColorScope { visible: inputPanel.status == Loader.Ready } - PW.KeyboardLayoutButton { + PlasmaComponents3.ToolButton { + Accessible.description: i18ndc("plasma_lookandfeel_org.kde.lookandfeel", "Button to change keyboard layout", "Switch layout") + icon.name: "input-keyboard" + + PW.KeyboardLayoutSwitcher { + id: keyboardLayoutSwitcher + + anchors.fill: parent + acceptedButtons: Qt.NoButton + } + + text: keyboardLayoutSwitcher.layoutNames.longName + onClicked: keyboardLayoutSwitcher.keyboardLayout.switchToNextLayout() + + visible: keyboardLayoutSwitcher.hasMultipleKeyboardLayouts } Item {