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

inputmethod: improve the integration of the SNI

* Adds a context menu to choose virtual keyboards.
* Notifies when there is no virtual keyboard selected.
parent 050ce242
......@@ -32,6 +32,7 @@
#include <QDBusConnection>
#include <QDBusPendingCall>
#include <QDBusMessage>
#include <QMenu>
#include <linux/input-event-codes.h>
#include <xkbcommon/xkbcommon-keysyms.h>
......@@ -81,11 +82,20 @@ void InputMethod::init()
}
qCDebug(KWIN_VIRTUALKEYBOARD) << "Registering the SNI";
QMenu *sniMenu = new QMenu;
sniMenu->addAction(i18n("Configure virtual keyboards..."), this, [] {
QProcess::startDetached("systemsettings5", {"kcm_virtualkeyboard"});
});
m_sni = new KStatusNotifierItem(QStringLiteral("kwin-virtual-keyboard"), this);
m_sni->setStandardActionsEnabled(false);
m_sni->setCategory(KStatusNotifierItem::Hardware);
m_sni->setStatus(KStatusNotifierItem::Passive);
m_sni->setTitle(i18n("Virtual Keyboard"));
m_sni->setToolTipTitle(i18n("Whether to show the virtual keyboard on demand."));
m_sni->setStandardActionsEnabled(false);
m_sni->setContextMenu(sniMenu);
updateSni();
connect(m_sni, &KStatusNotifierItem::activateRequested, this,
[this] {
......@@ -508,14 +518,19 @@ void InputMethod::updateSni()
if (!m_sni) {
return;
}
if (m_enabled) {
if (m_inputMethodCommand.isEmpty()) {
m_sni->setIconByName(QStringLiteral("input-keyboard-virtual-on"));
m_sni->setOverlayIconByName(QStringLiteral("emblem-unavailable"));
m_sni->setTitle(i18n("No Virtual Keyboard configured"));
} else if (m_enabled) {
m_sni->setIconByName(QStringLiteral("input-keyboard-virtual-on"));
m_sni->setTitle(i18n("Virtual Keyboard: enabled"));
m_sni->setOverlayIconByName({});
} else {
m_sni->setIconByName(QStringLiteral("input-keyboard-virtual-off"));
m_sni->setTitle(i18n("Virtual Keyboard: disabled"));
m_sni->setOverlayIconByName({});
}
m_sni->setToolTipTitle(i18n("Whether to show the virtual keyboard on demand."));
}
void InputMethod::updateInputPanelState()
......@@ -547,6 +562,7 @@ void InputMethod::setInputMethodCommand(const QString &command)
if (m_enabled) {
startInputMethod();
}
updateSni();
}
void InputMethod::stopInputMethod()
......
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