Files
plasma-keyboard/virtualkeyboard/virtualkeyboardcontext.cpp
Devin Lin 48d38c6bea Introduce virtual keyboard input engine and layout framework
This is the first step in
https://invent.kde.org/plasma/plasma-keyboard/-/merge_requests/109
(please see it for context and rationale), and
introduces a basic input engine and layout framework.

The virtual keyboard library and engine are in /virtualkeyboard:
- /virtualkeyboard/components - QML components for building keyboard layouts and the keyboard itself
- /virtualkeyboard/inputbackend.h - generic input "backend" for sending events from the vkbd, currently just for input-method-v1 but could be for xdg-remote-desktop?
- /virtualkeyboard/inputengine.h - internal input method "state"
- /virtualkeyboard/keyboardcontroller.h - internal virtual keyboard panel "state"
- /virtualkeyboard/keyboardpackageresolver.h - utilities to find and parse keyboard "layout packages"
- /virtualkeyboard/textcomposers/abstracttextcomposer.h - abstract interface that implements event handling from the keyboard layout and talks to InputEngine for the final "text" (needed for CJK, text prediction)
- /virtualkeyboard/textcomposers/directtextcomposer.h - directly enters text (enough for most layouts)

For an example keyboard package (not included in this MR), please see https://invent.kde.org/plasma/plasma-keyboard/-/tree/e8e33ef2103c545decaed556a43907349e789fb8/layouts/en (shared layouts in https://invent.kde.org/plasma/plasma-keyboard/-/tree/e8e33ef2103c545decaed556a43907349e789fb8/layouts/defaultplugin)
- Metadata is in metadata.json, which lists the locales the package is
  meant for, and what layouts it provides
- Each keyboard layout has predefined "required" layouts: main, symbols,
  digits, numbers and dialpad
- Each keyboard layout can define which form factors to show up for (ex.
  desktop ones won't show up in the mobile kcm keyboard selector by default)
2026-09-22 23:51:19 -04:00

36 lines
976 B
C++

/*
SPDX-FileCopyrightText: 2026 Devin Lin <devin@kde.org>
SPDX-License-Identifier: GPL-2.0-only OR GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
*/
#include "virtualkeyboardcontext.h"
#include "inputbackend.h"
#include "inputengine.h"
#include "keyboardcontroller.h"
#include "keyboardpackageresolver.h"
VirtualKeyboardContext::VirtualKeyboardContext(InputBackend *inputBackend, QObject *parent)
: QObject(parent)
, m_inputEngine(new InputEngine(inputBackend, this))
, m_keyboardPackageResolver(new KeyboardPackageResolver(this))
, m_keyboardController(new KeyboardController(m_inputEngine, m_keyboardPackageResolver, this))
{
}
InputEngine *VirtualKeyboardContext::inputEngine() const
{
return m_inputEngine;
}
KeyboardController *VirtualKeyboardContext::keyboardController() const
{
return m_keyboardController;
}
KeyboardPackageResolver *VirtualKeyboardContext::keyboardPackageResolver() const
{
return m_keyboardPackageResolver;
}