Don't show virtual keyboard SNI when no virtual keyboard is selected in the KCM
Not choosing any virtual keyboard is a valid option. In this case do not show the SNI since it isn't very useful then and takes up some space in the system tray. BUG: 437171
This commit is contained in:
parent
a18cb8998e
commit
99b84a321a
2 changed files with 37 additions and 35 deletions
|
@ -81,27 +81,8 @@ 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();
|
updateSni();
|
||||||
connect(m_sni, &KStatusNotifierItem::activateRequested, this,
|
|
||||||
[this] {
|
|
||||||
setEnabled(!m_enabled);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
connect(this, &InputMethod::enabledChanged, this, &InputMethod::updateSni);
|
connect(this, &InputMethod::enabledChanged, this, &InputMethod::updateSni);
|
||||||
|
|
||||||
new VirtualKeyboardDBus(this);
|
new VirtualKeyboardDBus(this);
|
||||||
|
@ -516,21 +497,42 @@ void InputMethod::adoptInputMethodContext()
|
||||||
|
|
||||||
void InputMethod::updateSni()
|
void InputMethod::updateSni()
|
||||||
{
|
{
|
||||||
if (!m_sni) {
|
if (!m_inputMethodCommand.isEmpty()) {
|
||||||
return;
|
if (!m_sni) {
|
||||||
}
|
qCDebug(KWIN_VIRTUALKEYBOARD) << "Registering the SNI";
|
||||||
if (m_inputMethodCommand.isEmpty()) {
|
m_sni.reset(new KStatusNotifierItem(QStringLiteral("kwin-virtual-keyboard"), this));
|
||||||
m_sni->setIconByName(QStringLiteral("input-keyboard-virtual-on"));
|
|
||||||
m_sni->setOverlayIconByName(QStringLiteral("emblem-unavailable"));
|
connect(m_sni.get(), &KStatusNotifierItem::activateRequested, this,
|
||||||
m_sni->setTitle(i18n("No Virtual Keyboard configured"));
|
[this] {
|
||||||
} else if (m_enabled) {
|
setEnabled(!m_enabled);
|
||||||
m_sni->setIconByName(QStringLiteral("input-keyboard-virtual-on"));
|
}
|
||||||
m_sni->setTitle(i18n("Virtual Keyboard: enabled"));
|
);
|
||||||
m_sni->setOverlayIconByName({});
|
}
|
||||||
|
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);
|
||||||
|
|
||||||
|
QMenu *sniMenu = new QMenu;
|
||||||
|
sniMenu->addAction(i18n("Configure virtual keyboards..."), this, [] {
|
||||||
|
QProcess::startDetached("systemsettings5", {"kcm_virtualkeyboard"});
|
||||||
|
});
|
||||||
|
|
||||||
|
m_sni->setContextMenu(sniMenu);
|
||||||
|
|
||||||
|
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({});
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
m_sni->setIconByName(QStringLiteral("input-keyboard-virtual-off"));
|
m_sni.reset();
|
||||||
m_sni->setTitle(i18n("Virtual Keyboard: disabled"));
|
|
||||||
m_sni->setOverlayIconByName({});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ private:
|
||||||
|
|
||||||
bool m_enabled = false;
|
bool m_enabled = false;
|
||||||
bool m_active = false;
|
bool m_active = false;
|
||||||
KStatusNotifierItem *m_sni = nullptr;
|
QScopedPointer<KStatusNotifierItem> m_sni;
|
||||||
QPointer<AbstractClient> m_inputClient;
|
QPointer<AbstractClient> m_inputClient;
|
||||||
QPointer<AbstractClient> m_trackedClient;
|
QPointer<AbstractClient> m_trackedClient;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue