1#include "inputdevicesmanager.h"
2#include "settingsstore.h"
3#include "mauimanutils.h"
7#if !defined Q_OS_ANDROID
8#include <QDBusInterface>
12InputDevicesManager::InputDevicesManager(
QObject *parent) :
QObject(parent)
15 qDebug(
" INIT ACCESSIBILITY MANAGER");
17#if !defined Q_OS_ANDROID
19 if(server->serverRunning())
21 this->setConnections();
24 connect(server, &MauiManUtils::serverRunningChanged, [
this](
bool state)
28 this->setConnections();
39 return m_keyboardLayout;
44 return m_keyboardModel;
49 return m_keyboardVariant;
54 return m_keyboardOptions;
59 return m_keyboardRules;
62void MauiMan::InputDevicesManager::setKeyboardLayout(
QString keyboardLayout)
64 if (m_keyboardLayout == keyboardLayout)
67 m_keyboardLayout = keyboardLayout;
68 sync(QStringLiteral(
"setKeyboardLayout"), m_keyboardLayout);
69 m_settings->save(QStringLiteral(
"KeyboardLayout"), m_keyboardLayout);
70 Q_EMIT keyboardLayoutChanged(m_keyboardLayout);
73void MauiMan::InputDevicesManager::setKeyboardModel(
QString keyboardModel)
75 if (m_keyboardModel == keyboardModel)
78 m_keyboardModel = keyboardModel;
79 sync(QStringLiteral(
"setKeyboardModel"), m_keyboardModel);
80 m_settings->save(QStringLiteral(
"KeyboardModel"), m_keyboardModel);
81 Q_EMIT keyboardModelChanged(m_keyboardModel);
84void MauiMan::InputDevicesManager::setKeyboardVariant(
QString keyboardVariant)
86 if (m_keyboardVariant == keyboardVariant)
89 m_keyboardVariant = keyboardVariant;
90 sync(QStringLiteral(
"setKeyboardVariant"), m_keyboardVariant);
91 m_settings->save(QStringLiteral(
"KeyboardVariant"), m_keyboardVariant);
92 Q_EMIT keyboardVariantChanged(m_keyboardVariant);
95void MauiMan::InputDevicesManager::setKeyboardOptions(
QString keyboardOptions)
97 if (m_keyboardOptions == keyboardOptions)
100 m_keyboardOptions = keyboardOptions;
101 sync(QStringLiteral(
"setKeyboardOptions"), m_keyboardOptions);
102 m_settings->save(QStringLiteral(
"KeyboardOptions"), m_keyboardOptions);
103 Q_EMIT keyboardOptionsChanged(m_keyboardOptions);
106void MauiMan::InputDevicesManager::setKeyboardRules(
QString keyboardRules)
108 if (m_keyboardRules == keyboardRules)
111 m_keyboardRules = keyboardRules;
112 sync(QStringLiteral(
"setKeyboardRules"), m_keyboardRules);
113 m_settings->save(QStringLiteral(
"KeyboardRules"), m_keyboardRules);
114 Q_EMIT keyboardRulesChanged(m_keyboardRules);
117void MauiMan::InputDevicesManager::onKeyboardLayoutChanged(
const QString &keyboardLayout)
119 if (m_keyboardLayout == keyboardLayout)
122 m_keyboardLayout = keyboardLayout;
123 Q_EMIT keyboardLayoutChanged(m_keyboardLayout);
126void MauiMan::InputDevicesManager::onKeyboardModelChanged(
const QString &keyboardModel)
128 if (m_keyboardModel == keyboardModel)
131 m_keyboardModel = keyboardModel;
132 Q_EMIT keyboardModelChanged(m_keyboardModel);
135void MauiMan::InputDevicesManager::onKeyboardOptionsChanged(
const QString &keyboardOptions)
137 if (m_keyboardOptions == keyboardOptions)
140 m_keyboardOptions = keyboardOptions;
141 Q_EMIT keyboardOptionsChanged(m_keyboardOptions);
144void MauiMan::InputDevicesManager::onKeyboardRulesChanged(
const QString &keyboardRules)
146 if (m_keyboardRules == keyboardRules)
149 m_keyboardRules = keyboardRules;
150 Q_EMIT keyboardRulesChanged(m_keyboardRules);
153void MauiMan::InputDevicesManager::onKeyboardVariantChanged(
const QString &keyboardVariant)
155 if (m_keyboardVariant == keyboardVariant)
158 m_keyboardVariant = keyboardVariant;
159 Q_EMIT keyboardVariantChanged(m_keyboardVariant);
162void MauiMan::InputDevicesManager::sync(
const QString &key,
const QVariant &value)
164#if !defined Q_OS_ANDROID
165 if (m_interface && m_interface->isValid())
167 m_interface->call(key, value);
175void MauiMan::InputDevicesManager::setConnections()
177#if !defined Q_OS_ANDROID
180 m_interface->disconnect();
181 m_interface->deleteLater();
182 m_interface =
nullptr;
185 m_interface =
new QDBusInterface (QStringLiteral(
"org.mauiman.Manager"),
186 QStringLiteral(
"/InputDevices"),
187 QStringLiteral(
"org.mauiman.InputDevices"),
189 if (m_interface->isValid())
191 connect(m_interface, SIGNAL(keyboardLayoutChanged(
double)),
this, SLOT(onKeyboardLayoutChanged(
QString)));
192 connect(m_interface, SIGNAL(keyboardModelChanged(
double)),
this, SLOT(onKeyboardModelChanged(
QString)));
193 connect(m_interface, SIGNAL(keyboardRulesChanged(
double)),
this, SLOT(onKeyboardRulesChanged(
QString)));
194 connect(m_interface, SIGNAL(keyboardOptionsChanged(
double)),
this, SLOT(onKeyboardOptionsChanged(
QString)));
195 connect(m_interface, SIGNAL(keyboardVariantChanged(
double)),
this, SLOT(onKeyboardVariantChanged(
QString)));
201void MauiMan::InputDevicesManager::loadSettings()
203 m_settings->beginModule(QStringLiteral(
"InputDevices"));
205#if !defined Q_OS_ANDROID
207 if(m_interface && m_interface->isValid())
209 m_keyboardLayout = m_interface->property(
"keyboardLayout").toString();
210 m_keyboardModel = m_interface->property(
"keyboardModel").toString();
211 m_keyboardOptions = m_interface->property(
"keyboardOptions").toString();
212 m_keyboardRules = m_interface->property(
"keyboardRules").toString();
213 m_keyboardVariant = m_interface->property(
"keyboardVariant").toString();
218 m_keyboardLayout = m_settings->load(QStringLiteral(
"KeyboardLayout"), m_keyboardLayout).toString();
219 m_keyboardModel = m_settings->load(QStringLiteral(
"KeyboardModel"), m_keyboardModel).toString();
220 m_keyboardOptions = m_settings->load(QStringLiteral(
"KeyboardOptions"), m_keyboardOptions).toString();
221 m_keyboardRules = m_settings->load(QStringLiteral(
"KeyboardRules"), m_keyboardRules).toString();
222 m_keyboardVariant = m_settings->load(QStringLiteral(
"KeyboardVariant"), m_keyboardVariant).toString();
The SettingsStore class Allows to store and read settings for MauiMan from the local conf file.
The MauiMan name-space contains all of the available modules for configuring the Maui Applications an...
QDBusConnection sessionBus()
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)