File indexing completed on 2024-11-24 04:19:36

0001 #include "inputdevices.h"
0002 #include "inputdevicesadaptor.h"
0003 #include <QDBusInterface>
0004 #include "settingsstore.h"
0005 
0006 InputDevices::InputDevices(QObject *parent) : QObject(parent)
0007 {
0008     qDebug( " INIT INPUT_DEVICES MODULE");
0009 
0010     new InputDevicesAdaptor(this);
0011     if(!QDBusConnection::sessionBus().registerObject(QStringLiteral("/InputDevices"), this))
0012     {
0013         qDebug() << "FAILED TO REGISTER INPUT_DEVICES DBUS OBJECT";
0014         return;
0015     }
0016 
0017     MauiMan::SettingsStore settings;
0018     settings.beginModule(QStringLiteral("InputDevices"));
0019     m_keyboardLayout = settings.load(QStringLiteral("KeyboardLayout"), m_keyboardLayout).toString();
0020     m_keyboardModel = settings.load(QStringLiteral("KeyboardModel"), m_keyboardModel).toString();
0021     m_keyboardOptions = settings.load(QStringLiteral("KeyboardOptions"), m_keyboardOptions).toString();
0022     m_keyboardRules = settings.load(QStringLiteral("KeyboardRules"), m_keyboardRules).toString();
0023     m_keyboardVariant = settings.load(QStringLiteral("KeyboardVariant"), m_keyboardVariant).toString();
0024     settings.endModule();
0025 }
0026 
0027 QString InputDevices::keyboardLayout() const
0028 {
0029     return m_keyboardLayout;
0030 }
0031 
0032 QString InputDevices::keyboardModel() const
0033 {
0034     return m_keyboardModel;
0035 }
0036 
0037 QString InputDevices::keyboardVariant() const
0038 {
0039     return m_keyboardVariant;
0040 }
0041 
0042 QString InputDevices::keyboardOptions() const
0043 {
0044     return m_keyboardOptions;
0045 }
0046 
0047 QString InputDevices::keyboardRules() const
0048 {
0049     return m_keyboardRules;
0050 }
0051 
0052 void InputDevices::setKeyboardLayout(const QString &keyboardLayout)
0053 {
0054     if (m_keyboardLayout == keyboardLayout)
0055         return;
0056 
0057     m_keyboardLayout = keyboardLayout;
0058     Q_EMIT keyboardLayoutChanged(m_keyboardLayout);
0059 }
0060 
0061 void InputDevices::setKeyboardModel(const QString &keyboardModel)
0062 {
0063     if (m_keyboardModel == keyboardModel)
0064         return;
0065 
0066     m_keyboardModel = keyboardModel;
0067     Q_EMIT keyboardModelChanged(m_keyboardModel);
0068 }
0069 
0070 void InputDevices::setKeyboardVariant(const QString &keyboardVariant)
0071 {
0072     if (m_keyboardVariant == keyboardVariant)
0073         return;
0074 
0075     m_keyboardVariant = keyboardVariant;
0076     Q_EMIT keyboardVariantChanged(m_keyboardVariant);
0077 }
0078 
0079 void InputDevices::setKeyboardOptions(const QString &keyboardOptions)
0080 {
0081     if (m_keyboardOptions == keyboardOptions)
0082         return;
0083 
0084     m_keyboardOptions = keyboardOptions;
0085     Q_EMIT keyboardOptionsChanged(m_keyboardOptions);
0086 }
0087 
0088 void InputDevices::setKeyboardRules(const QString &keyboardRules)
0089 {
0090     if (m_keyboardRules == keyboardRules)
0091         return;
0092 
0093     m_keyboardRules = keyboardRules;
0094     Q_EMIT keyboardRulesChanged(m_keyboardRules);
0095 }