1#include "screenmanager.h"
3#include "settingsstore.h"
4#include "mauimanutils.h"
8#if !defined Q_OS_ANDROID
9#include <QDBusInterface>
17 qDebug(
" INIT SCREEN MANAGER");
19#if !defined Q_OS_ANDROID
21 if(server->serverRunning())
23 this->setConnections();
26 connect(server, &MauiManUtils::serverRunningChanged, [
this](
bool state)
30 this->setConnections();
43void ScreenManager::setScaleFactor(
double scaleFactor)
49 sync(QStringLiteral(
"setScaleFactor"), m_scaleFactor);
50 m_settings->save(QStringLiteral(
"ScaleFactor"), m_scaleFactor);
51 Q_EMIT scaleFactorChanged(m_scaleFactor);
59void ScreenManager::setOrientation(uint orientation)
65 sync(QStringLiteral(
"setOrientation"), m_orientation);
66 m_settings->save(QStringLiteral(
"Orientation"), m_orientation);
67 Q_EMIT orientationChanged(m_orientation);
70void ScreenManager::onScaleFactorChanged(
double scale)
72 if (m_scaleFactor == scale)
75 m_scaleFactor = scale;
76 Q_EMIT scaleFactorChanged(m_scaleFactor);
79void ScreenManager::onOrientationChanged(uint orientation)
85 Q_EMIT orientationChanged(m_orientation);
88void ScreenManager::sync(
const QString &key,
const QVariant &value)
90#if !defined Q_OS_ANDROID
91 if (m_interface && m_interface->isValid())
93 m_interface->call(key, value);
101void ScreenManager::setConnections()
103#if !defined Q_OS_ANDROID
106 m_interface->disconnect();
107 m_interface->deleteLater();
108 m_interface =
nullptr;
111 m_interface =
new QDBusInterface (QStringLiteral(
"org.mauiman.Manager"),
112 QStringLiteral(
"/Screen"),
113 QStringLiteral(
"org.mauiman.Screen"),
115 if (m_interface->isValid())
117 connect(m_interface, SIGNAL(scaleFactorChanged(
double)),
this, SLOT(onScaleFactorChanged(
double)));
118 connect(m_interface, SIGNAL(orientationChanged(uint)),
this, SLOT(onOrientationChanged(uint)));
124void ScreenManager::loadSettings()
126 m_settings->beginModule(QStringLiteral(
"Screen"));
128#if !defined Q_OS_ANDROID
130 if(m_interface && m_interface->isValid())
132 m_scaleFactor = m_interface->property(
"scaleFactor").toDouble();
133 m_orientation = m_interface->property(
"orientation").toUInt();
138 m_scaleFactor = m_settings->load(QStringLiteral(
"ScaleFactor"), m_scaleFactor).toDouble();
139 m_orientation = m_settings->load(QStringLiteral(
"Orientation"), m_orientation).toUInt();
double scaleFactor
The preferred scale factor for the main screen.
uint orientation
The preferred orientation of the main screen.
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()
QMetaObject::Connection connect(const QObject *sender, PointerToMemberFunction signal, Functor functor)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)