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);
95void AccessibilityManager::setConnections()
97#if !defined Q_OS_ANDROID
102 m_interface =
nullptr;
105 m_interface =
new QDBusInterface(QStringLiteral(
"org.mauiman.Manager"),
106 QStringLiteral(
"/Accessibility"),
107 QStringLiteral(
"org.mauiman.Accessibility"),
112 connect(m_interface, SIGNAL(singleClickChanged(
bool)),
this, SLOT(onSingleClickChanged(
bool)));
113 connect(m_interface, SIGNAL(playSoundsChanged(
bool)),
this, SLOT(onPlaySoundsChanged(
bool)));
114 connect(m_interface, SIGNAL(scrollBarPolicyChanged(uint)),
this, SLOT(onScrollBarPolicyChanged(uint)));
119void AccessibilityManager::loadSettings()
121 m_settings->
beginModule(QStringLiteral(
"Accessibility"));
123#if !defined Q_OS_ANDROID
124 if(m_interface && m_interface->
isValid())
127 m_scrollBarPolicy = m_interface->
property(
"scrollBarPolicy").
toUInt();
133 m_singleClick = m_settings->
load(QStringLiteral(
"SingleClick"), m_singleClick).
toBool();
134 m_scrollBarPolicy = m_settings->
load(QStringLiteral(
"ScrollBarPolicy"), m_scrollBarPolicy).
toUInt();
135 m_playSounds = m_settings->
load(QStringLiteral(
"PlaySounds"), m_playSounds).
toBool();
140 return m_scrollBarPolicy;
143void AccessibilityManager::setScrollBarPolicy(uint newScrollBarPolicy)
145 if (m_scrollBarPolicy == newScrollBarPolicy)
148 m_scrollBarPolicy = newScrollBarPolicy;
150 sync(QStringLiteral(
"setScrollBarPolicy"), m_scrollBarPolicy);
151 m_settings->
save(QStringLiteral(
"ScrollBarPolicy"), m_scrollBarPolicy);
153 Q_EMIT scrollBarPolicyChanged(m_scrollBarPolicy);
161void AccessibilityManager::setPlaySounds(
bool newPlaySounds)
163 if (m_playSounds == newPlaySounds)
166 m_playSounds = newPlaySounds;
168 sync(QStringLiteral(
"setPlaySounds"), m_playSounds);
169 m_settings->
save(QStringLiteral(
"PlaySounds"), m_playSounds);
171 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