17#include "orientationlock.h"
19#include <QDBusConnection>
20#include <QDBusInterface>
22OrientationLock::OrientationLock(QObject *parent)
25 , m_savedOrientation(Qt::PortraitOrientation)
27 m_systemSettings = g_settings_new(
"com.lomiri.touch.system");
28 g_signal_connect(m_systemSettings,
"changed::rotation-lock",
29 G_CALLBACK(OrientationLock::onEnabledChangedProxy),
this);
30 m_enabled = g_settings_get_boolean(m_systemSettings,
"rotation-lock");
33OrientationLock::~OrientationLock()
35 g_signal_handlers_disconnect_by_data(m_systemSettings,
this);
36 g_object_unref(m_systemSettings);
39bool OrientationLock::enabled()
const
44Qt::ScreenOrientation OrientationLock::savedOrientation()
const
46 return m_savedOrientation;
49void OrientationLock::onEnabledChangedProxy(GSettings *,
const gchar *, gpointer data)
52 _this->onEnabledChanged();
55void OrientationLock::onEnabledChanged()
57 const bool enabled = g_settings_get_boolean(m_systemSettings,
"rotation-lock");
58 if (m_enabled != enabled) {
60 Q_EMIT enabledChanged();
64void OrientationLock::setSavedOrientation(
const Qt::ScreenOrientation orientation)
66 if (orientation == m_savedOrientation) {
70 m_savedOrientation = orientation;
73 Q_EMIT savedOrientationChanged();
The OrientationLock class exports orientation lock related properties to QML It has two properties: