2 * Copyright (C) 2014 Canonical, Ltd.
4 * This program is free software: you can redistribute it and/or modify it under
5 * the terms of the GNU Lesser General Public License version 3, as published by
6 * the Free Software Foundation.
8 * This program is distributed in the hope that it will be useful, but WITHOUT
9 * ANY WARRANTY; without even the implied warranties of MERCHANTABILITY,
10 * SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
13 * You should have received a copy of the GNU Lesser General Public License
14 * along with this program. If not, see <http://www.gnu.org/licenses/>.
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.ubuntu.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 */*settings*/, const gchar */*key*/, gpointer data)
51 OrientationLock* _this = static_cast<OrientationLock*>(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;
72 //TODO - save value with dbus to persist over sessions
73 Q_EMIT savedOrientationChanged();
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list