Commit 4ffc72cd authored by Aleix Pol Gonzalez's avatar Aleix Pol Gonzalez 🐧 Committed by Aleix Pol Gonzalez
Browse files

screen locker: Integrate the virtual keyboard on wayland

Use the system's virtual keyboard instead of relying on
QtVirtualKeyboard specifically for the lock screen.
It means less code (when we can remove the virtual keyboard part),
better integration and one dependency less.
parent 52261737
......@@ -2,8 +2,8 @@ set(keyboardlayoutplugin_SRCS
keyboardlayout.cpp
keyboardlayoutplugin.cpp
layoutnames.cpp
layoutnames.h
)
virtualkeyboard.cpp
)
ecm_qt_declare_logging_category(keyboardlayoutplugin_SRCS HEADER debug.h
IDENTIFIER KEYBOARD_LAYOUT
......@@ -14,6 +14,7 @@ set_source_files_properties(org.kde.KeyboardLayouts.xml
PROPERTIES INCLUDE layoutnames.h)
qt5_add_dbus_interface(keyboardlayoutplugin_SRCS "org.kde.KeyboardLayouts.xml" keyboard_layout_interface)
qt5_add_dbus_interface(keyboardlayoutplugin_SRCS "${KWIN_VIRTUALKEYBOARD_INTERFACE}" virtualkeyboard_interface)
add_library(keyboardlayoutplugin SHARED ${keyboardlayoutplugin_SRCS})
......
......@@ -22,6 +22,7 @@
#include "keyboardlayoutplugin.h"
#include "keyboardlayout.h"
#include "virtualkeyboard.h"
#include <QQmlEngine>
......@@ -30,4 +31,7 @@ void KeyboardLayoutPlugin::registerTypes(const char *uri)
Q_ASSERT(uri == QLatin1String("org.kde.plasma.workspace.keyboardlayout"));
qmlRegisterType<KeyboardLayout>(uri, 1, 0, "KeyboardLayout");
qmlRegisterSingletonType<OrgKdeKwinVirtualKeyboardInterface>(uri, 1, 0, "KWinVirtualKeyboard", [](QQmlEngine *, QJSEngine *) -> QObject * {
return new KwinVirtualKeyboardInterface;
});
}
/*
* SPDX-FileCopyrightText: 2021 Aleix Pol Gonzalez <aleixpol@kde.org>
*
* SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#include "virtualkeyboard.h"
KwinVirtualKeyboardInterface::KwinVirtualKeyboardInterface()
: OrgKdeKwinVirtualKeyboardInterface(QStringLiteral("org.kde.KWin"), QStringLiteral("/VirtualKeyboard"), QDBusConnection::sessionBus())
{
}
/*
* SPDX-FileCopyrightText: 2021 Aleix Pol Gonzalez <aleixpol@kde.org>
*
* SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
#pragma once
#include "virtualkeyboard_interface.h"
class KwinVirtualKeyboardInterface : public OrgKdeKwinVirtualKeyboardInterface
{
Q_OBJECT
Q_PROPERTY(bool active READ active WRITE setActive NOTIFY activeChanged)
Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
public:
KwinVirtualKeyboardInterface();
};
/*
* SPDX-FileCopyrightText: 2021 Aleix Pol Gonzalez <aleixpol@kde.org>
*
* SPDX-License-Identifier: LGPL-2.1-only OR LGPL-3.0-only OR LicenseRef-KDE-Accepted-LGPL
*/
import QtQuick 2.15
import org.kde.plasma.workspace.keyboardlayout 1.0 as Keyboards
Item {
id: inputPanel
readonly property bool active: Qt.inputMethod.visible
property bool activated: false
visible: Qt.inputMethod.visible
x: Qt.inputMethod.keyboardRectangle.x
y: Qt.inputMethod.keyboardRectangle.y
height: Qt.inputMethod.keyboardRectangle.height
width: Qt.inputMethod.keyboardRectangle.width
onActivatedChanged: if (activated) {
Keyboards.KWinVirtualKeyboard.enabled = true
}
}
......@@ -328,14 +328,13 @@ PlasmaCore.ColorScope {
function showHide() {
state = state == "hidden" ? "visible" : "hidden";
}
Component.onCompleted: inputPanel.source = "../components/VirtualKeyboard.qml"
Component.onCompleted: {
inputPanel.source = Qt.platform.pluginName.includes("wayland") ? "../components/VirtualKeyboard_wayland.qml" : "../components/VirtualKeyboard.qml"
}
onKeyboardActiveChanged: {
if (keyboardActive) {
state = "visible";
// Otherwise the password field loses focus and virtual keyboard
// keystrokes get eaten
mainBlock.mainPasswordBox.forceActiveFocus();
} else {
state = "hidden";
}
......@@ -517,7 +516,12 @@ PlasmaCore.ColorScope {
PlasmaComponents3.ToolButton {
text: i18ndc("plasma_lookandfeel_org.kde.lookandfeel", "Button to show/hide virtual keyboard", "Virtual Keyboard")
icon.name: inputPanel.keyboardActive ? "input-keyboard-virtual-on" : "input-keyboard-virtual-off"
onClicked: inputPanel.showHide()
onClicked: {
// Otherwise the password field loses focus and virtual keyboard
// keystrokes get eaten
mainBlock.mainPasswordBox.forceActiveFocus();
inputPanel.showHide()
}
visible: inputPanel.status == Loader.Ready
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment