inputmethod: Add a property to tell whether an input method is running

This commit is contained in:
Aleix Pol 2021-07-22 17:38:13 +02:00
parent f431b6ad96
commit 278da74eab
4 changed files with 18 additions and 0 deletions

View file

@ -605,6 +605,7 @@ void InputMethod::stopInputMethod()
}
m_inputMethodProcess->deleteLater();
m_inputMethodProcess = nullptr;
Q_EMIT availableChanged();
}
void InputMethod::startInputMethod()
@ -657,6 +658,7 @@ void InputMethod::startInputMethod()
}
}
});
Q_EMIT availableChanged();
}
bool InputMethod::isActive() const
{
@ -697,4 +699,9 @@ bool InputMethod::isVisible() const
return m_inputClient && m_inputClient->isShown(false);
}
bool InputMethod::isAvailable() const
{
return m_inputMethodProcess;
}
}

View file

@ -52,6 +52,7 @@ public:
void hide();
void show();
bool isVisible() const;
bool isAvailable() const;
void setInputMethodCommand(const QString &path);
@ -59,6 +60,7 @@ Q_SIGNALS:
void activeChanged(bool active);
void enabledChanged(bool enabled);
void visibleChanged();
void availableChanged();
private Q_SLOTS:
void clientAdded(AbstractClient* client);

View file

@ -23,6 +23,7 @@ VirtualKeyboardDBus::VirtualKeyboardDBus(InputMethod *parent)
connect(parent, &InputMethod::activeChanged, this, &VirtualKeyboardDBus::activeChanged);
connect(parent, &InputMethod::enabledChanged, this, &VirtualKeyboardDBus::enabledChanged);
connect(parent, &InputMethod::visibleChanged, this, &VirtualKeyboardDBus::visibleChanged);
connect(parent, &InputMethod::availableChanged, this, &VirtualKeyboardDBus::availableChanged);
}
VirtualKeyboardDBus::~VirtualKeyboardDBus() = default;
@ -52,4 +53,9 @@ bool VirtualKeyboardDBus::isVisible() const
return m_inputMethod->isVisible();
}
bool VirtualKeyboardDBus::isAvailable() const
{
return m_inputMethod->isAvailable();
}
}

View file

@ -18,6 +18,7 @@ class KWIN_EXPORT VirtualKeyboardDBus : public QObject
{
Q_OBJECT
Q_CLASSINFO("D-Bus Interface", "org.kde.kwin.VirtualKeyboard")
Q_PROPERTY(bool available READ isAvailable NOTIFY availableChanged)
Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged)
Q_PROPERTY(bool active READ isActive WRITE setActive NOTIFY activeChanged)
Q_PROPERTY(bool visible READ isVisible NOTIFY visibleChanged)
@ -28,6 +29,7 @@ public:
bool isVisible() const;
bool isActive() const;
bool isAvailable() const;
void setEnabled(bool enabled);
void setActive(bool active);
@ -35,6 +37,7 @@ Q_SIGNALS:
Q_SCRIPTABLE void enabledChanged();
Q_SCRIPTABLE void activeChanged();
Q_SCRIPTABLE void visibleChanged();
Q_SCRIPTABLE void availableChanged();
private:
InputMethod *const m_inputMethod;