File indexing completed on 2024-10-27 04:24:10

0001 #pragma once
0002 #include <QObject>
0003 #include "mauiman_export.h"
0004 
0005 class QDBusInterface;
0006 namespace MauiMan
0007 {
0008     class SettingsStore;
0009     
0010     /**
0011      * @brief The InputDevicesManager class exposes all the system input devices properties
0012      */
0013     class MAUIMAN_EXPORT InputDevicesManager : public QObject
0014     {
0015         Q_OBJECT
0016         /**
0017          * The preferred keyboard language layout.
0018          */
0019         Q_PROPERTY(QString keyboardLayout READ keyboardLayout WRITE setKeyboardLayout NOTIFY keyboardLayoutChanged)
0020         
0021         /**
0022          * The preferred keyboard model
0023          */
0024         Q_PROPERTY(QString keyboardModel READ keyboardModel WRITE setKeyboardModel NOTIFY keyboardModelChanged)
0025         
0026         /**
0027          * The preferred keyboard layout variant.
0028          */
0029         Q_PROPERTY(QString keyboardVariant READ keyboardVariant WRITE setKeyboardVariant NOTIFY keyboardVariantChanged)
0030         
0031         /**
0032          * The keyboard layout options.
0033          */
0034         Q_PROPERTY(QString keyboardOptions READ keyboardOptions WRITE setKeyboardOptions NOTIFY keyboardOptionsChanged)
0035         
0036         /**
0037          * The keyboard layout custom rules.
0038          */
0039         Q_PROPERTY(QString keyboardRules READ keyboardRules WRITE setKeyboardRules NOTIFY keyboardRulesChanged)
0040         
0041     public:
0042         
0043         /**
0044          * The InputDevices module default values.
0045          */
0046         struct DefaultValues
0047         {
0048             static inline const QString keyboardLayout =  QStringLiteral("us");
0049             static inline const QString keyboardModel =  QStringLiteral("");
0050             static inline const QString keyboardOptions =  QStringLiteral("grp:shifts_toggle,compose:ralt,ctrl:nocaps");
0051             static inline const QString keyboardVariant =  QStringLiteral("");
0052             static inline const QString keyboardRules =  QStringLiteral("");
0053         };
0054         explicit InputDevicesManager(QObject *parent = nullptr);
0055         
0056         QString keyboardLayout() const;
0057         void setKeyboardLayout(QString keyboardLayout);
0058         
0059         QString keyboardModel() const;
0060         void setKeyboardModel(QString keyboardModel);
0061         
0062         QString keyboardVariant() const;
0063         void setKeyboardVariant(QString keyboardVariant);
0064         
0065         QString keyboardOptions() const;
0066         void setKeyboardOptions(QString keyboardOptions);
0067         
0068         QString keyboardRules() const;
0069         void setKeyboardRules(QString keyboardRules);
0070         
0071     private Q_SLOTS:
0072         void onKeyboardLayoutChanged(const QString &keyboardLayout);
0073         void onKeyboardModelChanged(const QString &keyboardModel);
0074         void onKeyboardOptionsChanged(const QString &keyboardOptions);
0075         void onKeyboardRulesChanged(const QString &keyboardRules);
0076         void onKeyboardVariantChanged (const QString &keyboardVariant);
0077         
0078     private:
0079         #if !defined Q_OS_ANDROID
0080         QDBusInterface *m_interface = nullptr;
0081         #endif
0082         MauiMan::SettingsStore *m_settings;
0083         
0084         void sync(const QString &key, const QVariant &value);
0085         void setConnections();
0086         void loadSettings();
0087         
0088         QString m_keyboardLayout = InputDevicesManager::DefaultValues::keyboardLayout;
0089         QString m_keyboardModel = InputDevicesManager::DefaultValues::keyboardModel;
0090         QString m_keyboardVariant = InputDevicesManager::DefaultValues::keyboardVariant;
0091         QString m_keyboardOptions = InputDevicesManager::DefaultValues::keyboardOptions;
0092         QString m_keyboardRules = InputDevicesManager::DefaultValues::keyboardRules;
0093         
0094     Q_SIGNALS:
0095         void keyboardLayoutChanged(QString keyboardLayout);
0096         void keyboardModelChanged(QString keyboardModel);
0097         void keyboardVariantChanged(QString keyboardVariant);
0098         void keyboardOptionsChanged(QString keyboardOptions);
0099         void keyboardRulesChanged(QString keyboardRules);
0100     };
0101 }