2017-06-10 04:02:00 -04:00
|
|
|
#include "tvirtualkeyboard.h"
|
|
|
|
|
2019-02-12 05:55:58 -05:00
|
|
|
tVirtualKeyboard::tVirtualKeyboard() : QObject(nullptr) {
|
2018-07-26 04:15:43 -04:00
|
|
|
#ifdef T_OS_UNIX_NOT_MAC
|
2017-06-10 04:02:00 -04:00
|
|
|
keyboardInterface = new QDBusInterface("org.thesuite.tskbd", "/org/thesuite/tskbd", "org.thesuite.tskbd");
|
|
|
|
QDBusConnection::sessionBus().connect("org.thesuite.tskbd", "/org/thesuite/tskbd", "org.thesuite.tskbd", "keyboardVisibleChanged", this, SIGNAL(keyboardVisibleChanged(bool)));
|
2018-07-26 04:15:43 -04:00
|
|
|
#endif
|
2017-06-10 04:02:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
tVirtualKeyboard* tVirtualKeyboard::instance() {
|
|
|
|
static tVirtualKeyboard* appInst;
|
2019-02-12 05:55:58 -05:00
|
|
|
if (appInst == nullptr) {
|
2017-06-10 04:02:00 -04:00
|
|
|
appInst = new tVirtualKeyboard;
|
|
|
|
}
|
|
|
|
|
|
|
|
return appInst;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool tVirtualKeyboard::isKeyboardRunning() {
|
2018-07-26 04:15:43 -04:00
|
|
|
#ifdef T_OS_UNIX_NOT_MAC
|
2017-06-10 04:02:00 -04:00
|
|
|
return QDBusConnection::sessionBus().interface()->registeredServiceNames().value().contains("org.thesuite.tskbd");
|
2018-07-26 04:15:43 -04:00
|
|
|
#else
|
|
|
|
return false;
|
|
|
|
#endif
|
2017-06-10 04:02:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void tVirtualKeyboard::hideKeyboard() {
|
2018-07-26 04:15:43 -04:00
|
|
|
#ifdef T_OS_UNIX_NOT_MAC
|
2017-06-10 04:02:00 -04:00
|
|
|
if (isKeyboardRunning()) {
|
|
|
|
keyboardInterface->call(QDBus::Block, "hideKeyboard");
|
|
|
|
}
|
2018-07-26 04:15:43 -04:00
|
|
|
#endif
|
2017-06-10 04:02:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void tVirtualKeyboard::showKeyboard() {
|
2018-07-26 04:15:43 -04:00
|
|
|
#ifdef T_OS_UNIX_NOT_MAC
|
2017-06-10 04:02:00 -04:00
|
|
|
if (isKeyboardRunning()) {
|
|
|
|
keyboardInterface->call(QDBus::Block, "showKeyboard");
|
|
|
|
}
|
2018-07-26 04:15:43 -04:00
|
|
|
#endif
|
2017-06-10 04:02:00 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
int tVirtualKeyboard::height() {
|
2018-07-26 04:15:43 -04:00
|
|
|
#ifdef T_OS_UNIX_NOT_MAC
|
2017-06-10 04:02:00 -04:00
|
|
|
if (isKeyboardRunning()) {
|
|
|
|
return keyboardInterface->call(QDBus::Block, "height").arguments().first().toInt();
|
|
|
|
} else {
|
|
|
|
return -1;
|
|
|
|
}
|
2018-07-26 04:15:43 -04:00
|
|
|
#else
|
|
|
|
return -1;
|
|
|
|
#endif
|
2017-06-10 04:02:00 -04:00
|
|
|
}
|
2018-08-27 08:02:18 -04:00
|
|
|
|
|
|
|
bool tVirtualKeyboard::keyboardVisible() {
|
|
|
|
#ifdef T_OS_UNIX_NOT_MAC
|
|
|
|
if (isKeyboardRunning()) {
|
|
|
|
return keyboardInterface->call(QDBus::Block, "keyboardVisible").arguments().first().toBool();
|
|
|
|
} else {
|
|
|
|
return false;
|
|
|
|
}
|
2018-08-27 08:29:47 -04:00
|
|
|
#else
|
|
|
|
return false;
|
2018-08-27 08:02:18 -04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void tVirtualKeyboard::setKeyboardType(QString type) {
|
|
|
|
#ifdef T_OS_UNIX_NOT_MAC
|
|
|
|
if (isKeyboardRunning()) {
|
|
|
|
keyboardInterface->call(QDBus::NoBlock, "setKeyboardType", type);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2018-08-27 08:29:47 -04:00
|
|
|
|
|
|
|
void tVirtualKeyboard::setPredictive(bool predictive) {
|
|
|
|
#ifdef T_OS_UNIX_NOT_MAC
|
|
|
|
if (isKeyboardRunning()) {
|
|
|
|
keyboardInterface->call(QDBus::NoBlock, "setPredictive", predictive);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void tVirtualKeyboard::setHidden(bool hidden) {
|
|
|
|
#ifdef T_OS_UNIX_NOT_MAC
|
|
|
|
if (isKeyboardRunning()) {
|
|
|
|
keyboardInterface->call(QDBus::NoBlock, "setHidden", hidden);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void tVirtualKeyboard::setSensitive(bool sensitive) {
|
|
|
|
#ifdef T_OS_UNIX_NOT_MAC
|
|
|
|
if (isKeyboardRunning()) {
|
|
|
|
keyboardInterface->call(QDBus::NoBlock, "setSensitive", sensitive);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void tVirtualKeyboard::setAutoUppercase(bool autoUpperCase) {
|
|
|
|
#ifdef T_OS_UNIX_NOT_MAC
|
|
|
|
if (isKeyboardRunning()) {
|
|
|
|
keyboardInterface->call(QDBus::NoBlock, "setAutoUpperCase", autoUpperCase);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
2018-10-10 05:26:54 -04:00
|
|
|
|
|
|
|
void tVirtualKeyboard::setEnterKeyType(QString type) {
|
|
|
|
#ifdef T_OS_UNIX_NOT_MAC
|
|
|
|
if (isKeyboardRunning()) {
|
|
|
|
keyboardInterface->call(QDBus::NoBlock, "setEnterKeyType", type);
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|