1#include "accessibilitymanager.h"
2#include "settingsstore.h"
3#include "mauimanutils.h"
7#if !defined Q_OS_ANDROID
8#include <QDBusInterface>
13AccessibilityManager::AccessibilityManager(
QObject *parent) :
QObject(parent)
16 qDebug(
" INIT ACCESSIBILITY MANAGER");
18#if !defined Q_OS_ANDROID
20 if(server->serverRunning())
22 this->setConnections();
25 connect(server, &MauiManUtils::serverRunningChanged, [
this](
bool state)
29 this->setConnections();
42void AccessibilityManager::setSingleClick(
bool singleClick)
49 sync(QStringLiteral(
"setSingleClick"), m_singleClick);
50 m_settings->
save(QStringLiteral(
"SingleClick"), m_singleClick);
52 Q_EMIT singleClickChanged(m_singleClick);
55void AccessibilityManager::onSingleClickChanged(
bool singleClick)
61 Q_EMIT singleClickChanged(m_singleClick);
64void AccessibilityManager::onScrollBarPolicyChanged(uint scrollBarPolicy)
70 Q_EMIT scrollBarPolicyChanged(m_scrollBarPolicy);
73void AccessibilityManager::onPlaySoundsChanged(
bool playSounds)
79 Q_EMIT playSoundsChanged(m_playSounds);
82void AccessibilityManager::sync(
const QString &key,
const QVariant &value)
84#if !defined Q_OS_ANDROID
85 if (m_interface && m_interface->
isValid())
87 m_interface->
call(key, value);
92void AccessibilityManager::setConnections()
94#if !defined Q_OS_ANDROID
99 m_interface =
nullptr;
102 m_interface =
new QDBusInterface(QStringLiteral(
"org.mauiman.Manager"),
103 QStringLiteral(
"/Accessibility"),
104 QStringLiteral(
"org.mauiman.Accessibility"),
109 connect(m_interface, SIGNAL(singleClickChanged(
bool)),
this, SLOT(onSingleClickChanged(
bool)));
110 connect(m_interface, SIGNAL(playSoundsChanged(
bool)),
this, SLOT(onPlaySoundsChanged(
bool)));
111 connect(m_interface, SIGNAL(scrollBarPolicyChanged(uint)),
this, SLOT(onScrollBarPolicyChanged(uint)));
116void AccessibilityManager::loadSettings()
118 m_settings->
beginModule(QStringLiteral(
"Accessibility"));
120#if !defined Q_OS_ANDROID
121 if(m_interface && m_interface->
isValid())
124 m_scrollBarPolicy = m_interface->
property(
"scrollBarPolicy").
toUInt();
130 m_singleClick = m_settings->
load(QStringLiteral(
"SingleClick"), m_singleClick).
toBool();
131 m_scrollBarPolicy = m_settings->
load(QStringLiteral(
"ScrollBarPolicy"), m_scrollBarPolicy).
toUInt();
132 m_playSounds = m_settings->
load(QStringLiteral(
"PlaySounds"), m_playSounds).
toBool();
137 return m_scrollBarPolicy;
140void AccessibilityManager::setScrollBarPolicy(uint newScrollBarPolicy)
142 if (m_scrollBarPolicy == newScrollBarPolicy)
145 m_scrollBarPolicy = newScrollBarPolicy;
147 sync(QStringLiteral(
"setScrollBarPolicy"), m_scrollBarPolicy);
148 m_settings->
save(QStringLiteral(
"ScrollBarPolicy"), m_scrollBarPolicy);
150 Q_EMIT scrollBarPolicyChanged(m_scrollBarPolicy);
158void AccessibilityManager::setPlaySounds(
bool newPlaySounds)
160 if (m_playSounds == newPlaySounds)
163 m_playSounds = newPlaySounds;
165 sync(QStringLiteral(
"setPlaySounds"), m_playSounds);
166 m_settings->
save(QStringLiteral(
"PlaySounds"), m_playSounds);
168 Q_EMIT playSoundsChanged(m_playSounds);
bool singleClick
Whether to open items with a single click.
uint scrollBarPolicy
The policy for showing the scroll bars.
bool playSounds
Whether the user prefers the application to emit notification or alarm sounds.
The SettingsStore class Allows to store and read settings for MauiMan from the local conf file.
void save(const QString &key, const QVariant &value)
Save a conf value entry to the local file.
void beginModule(const QString &module)
Set up the module section to write to.
QVariant load(const QString &key, const QVariant &defaultValue)
Load the value of a conf entry, with a possible default value.
The MauiMan name-space contains all of the available modules for configuring the Maui Applications an...
QDBusMessage call(QDBus::CallMode mode, const QString &method, Args &&... args)
bool isValid() const const
QDBusConnection sessionBus()
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
bool disconnect(const QMetaObject::Connection &connection)
QVariant property(const char *name) const const
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
bool toBool() const const
uint toUInt(bool *ok) const const