inputmethod: Make sure the menu is only created when we create the SNI

It always does the same anyway, this way we make sure we don't leak
This commit is contained in:
Aleix Pol 2021-07-19 18:24:42 +02:00
parent 0169bca6e0
commit 638174ae09

View file

@ -514,6 +514,13 @@ void InputMethod::updateSni()
setEnabled(!m_enabled);
}
);
QMenu *sniMenu = new QMenu;
sniMenu->addAction(i18n("Configure virtual keyboards..."), this, [] {
QProcess::startDetached("systemsettings5", {"kcm_virtualkeyboard"});
});
m_sni->setContextMenu(sniMenu);
}
m_sni->setStandardActionsEnabled(false);
m_sni->setCategory(KStatusNotifierItem::Hardware);
@ -521,13 +528,6 @@ void InputMethod::updateSni()
m_sni->setTitle(i18n("Virtual Keyboard"));
m_sni->setToolTipTitle(i18n("Whether to show the virtual keyboard on demand."));
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"));