diff options
author | Simon Hausmann <simon.hausmann@nokia.com> | 2012-01-17 14:10:57 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-17 16:12:53 +0100 |
commit | 6e24833dc92d20e422e21dc59806ee4df6421164 (patch) | |
tree | 5ad3d246f61f132fefa7d9835398a390caa9eb59 /src/plugins | |
parent | 9fa2b641ba6ff4f4b3f474b87ddb642cfa5c3d83 (diff) |
Support current screen orientation changes on Harmattan
Subscribe to the corresponding property via DBus and report it
through QWindowSystemInterface::handleScreenOrientationChanged.
Change-Id: Ibd2901de798866e177aba898374ee2b9877310ed
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src/plugins')
-rw-r--r-- | src/plugins/generic/generic.pro | 3 | ||||
-rw-r--r-- | src/plugins/generic/meego/contextkitproperty.cpp | 85 | ||||
-rw-r--r-- | src/plugins/generic/meego/contextkitproperty.h | 66 | ||||
-rw-r--r-- | src/plugins/generic/meego/main.cpp | 75 | ||||
-rw-r--r-- | src/plugins/generic/meego/meego.pro | 15 | ||||
-rw-r--r-- | src/plugins/generic/meego/qmeegointegration.cpp | 81 | ||||
-rw-r--r-- | src/plugins/generic/meego/qmeegointegration.h | 72 | ||||
-rw-r--r-- | src/plugins/plugins.pro | 2 |
8 files changed, 398 insertions, 1 deletions
diff --git a/src/plugins/generic/generic.pro b/src/plugins/generic/generic.pro new file mode 100644 index 0000000000..68c7636940 --- /dev/null +++ b/src/plugins/generic/generic.pro @@ -0,0 +1,3 @@ +TEMPLATE = subdirs + +linux-g++-maemo: SUBDIRS += meego diff --git a/src/plugins/generic/meego/contextkitproperty.cpp b/src/plugins/generic/meego/contextkitproperty.cpp new file mode 100644 index 0000000000..1b9a1dc73f --- /dev/null +++ b/src/plugins/generic/meego/contextkitproperty.cpp @@ -0,0 +1,85 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "contextkitproperty.h" + +#include <QDBusReply> +#include <QDebug> + +static QString objectPathForProperty(const QString& property) +{ + QString path = property; + if (!path.startsWith(QLatin1Char('/'))) { + path.replace(QLatin1Char('.'), QLatin1Char('/')); + path.prepend(QLatin1String("/org/maemo/contextkit/")); + } + return path; +} + +QContextKitProperty::QContextKitProperty(const QString& serviceName, const QString& propertyName) + : propertyInterface(serviceName, objectPathForProperty(propertyName), + QLatin1String("org.maemo.contextkit.Property"), QDBusConnection::systemBus()) +{ + propertyInterface.call("Subscribe"); + connect(&propertyInterface, SIGNAL(ValueChanged(QVariantList, qulonglong)), + this, SLOT(cacheValue(QVariantList, qulonglong))); + + QDBusMessage reply = propertyInterface.call("Get"); + if (reply.type() == QDBusMessage::ReplyMessage) + cachedValue = qdbus_cast<QList<QVariant> >(reply.arguments().value(0)).value(0); +} + +QContextKitProperty::~QContextKitProperty() +{ + propertyInterface.call("Unsubscribe"); +} + +QVariant QContextKitProperty::value() const +{ + return cachedValue; +} + +void QContextKitProperty::cacheValue(const QVariantList& values, qulonglong) +{ + cachedValue = values.value(0); + emit valueChanged(cachedValue); +} + diff --git a/src/plugins/generic/meego/contextkitproperty.h b/src/plugins/generic/meego/contextkitproperty.h new file mode 100644 index 0000000000..faea51f259 --- /dev/null +++ b/src/plugins/generic/meego/contextkitproperty.h @@ -0,0 +1,66 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef CONTEXTKITPROPERTY_H +#define CONTEXTKITPROPERTY_H + +#include <QDBusInterface> + +class QContextKitProperty : public QObject +{ + Q_OBJECT +public: + QContextKitProperty(const QString& serviceName, const QString& propertyName); + ~QContextKitProperty(); + + QVariant value() const; + +signals: + void valueChanged(const QVariant& value); + +private slots: + void cacheValue(const QVariantList& values, qulonglong); + +private: + QDBusInterface propertyInterface; + QVariant cachedValue; +}; + +#endif // CONTEXTKITPROPERTY_H diff --git a/src/plugins/generic/meego/main.cpp b/src/plugins/generic/meego/main.cpp new file mode 100644 index 0000000000..48adeea7bd --- /dev/null +++ b/src/plugins/generic/meego/main.cpp @@ -0,0 +1,75 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include <qgenericplugin_qpa.h> +#include "qmeegointegration.h" + +QT_BEGIN_NAMESPACE + +class QMeeGoIntegrationPlugin : public QGenericPlugin +{ +public: + QMeeGoIntegrationPlugin(); + + QStringList keys() const; + QObject* create(const QString &key, const QString &specification); +}; + +QMeeGoIntegrationPlugin::QMeeGoIntegrationPlugin() + : QGenericPlugin() +{ +} + +QStringList QMeeGoIntegrationPlugin::keys() const +{ + return QStringList() << QLatin1String("MeeGoIntegration"); +} + +QObject* QMeeGoIntegrationPlugin::create(const QString &key, const QString &specification) +{ + if (!key.compare(QLatin1String("MeeGoIntegration"), Qt::CaseInsensitive)) + return new QMeeGoIntegration(); + return 0; +} + +Q_EXPORT_PLUGIN2(qmeegointegrationplugin, QMeeGoIntegrationPlugin) + +QT_END_NAMESPACE diff --git a/src/plugins/generic/meego/meego.pro b/src/plugins/generic/meego/meego.pro new file mode 100644 index 0000000000..928bb49d6c --- /dev/null +++ b/src/plugins/generic/meego/meego.pro @@ -0,0 +1,15 @@ +TARGET = qmeegointegration +load(qt_plugin) + +QTDIR_build:DESTDIR = $$QT_BUILD_TREE/plugins/generic + +target.path = $$[QT_INSTALL_PLUGINS]/generic +INSTALLS += target + +SOURCES = qmeegointegration.cpp \ + main.cpp \ + contextkitproperty.cpp +HEADERS = qmeegointegration.h \ + contextkitproperty.h + +QT = core-private gui-private dbus diff --git a/src/plugins/generic/meego/qmeegointegration.cpp b/src/plugins/generic/meego/qmeegointegration.cpp new file mode 100644 index 0000000000..4d029ef178 --- /dev/null +++ b/src/plugins/generic/meego/qmeegointegration.cpp @@ -0,0 +1,81 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmeegointegration.h" + +#include <QDebug> +#include <QDBusConnection> +#include <QDBusArgument> +#include <qguiapplication.h> +#include <qwindowsysteminterface_qpa.h> + +QMeeGoIntegration::QMeeGoIntegration() + : screenTopEdge(QStringLiteral("com.nokia.SensorService"), QStringLiteral("Screen.TopEdge")) +{ + connect(&screenTopEdge, SIGNAL(valueChanged(QVariant)), + this, SLOT(updateScreenOrientation(QVariant))); + updateScreenOrientation(screenTopEdge.value()); +} + +QMeeGoIntegration::~QMeeGoIntegration() +{ +} + +void QMeeGoIntegration::updateScreenOrientation(const QVariant& topEdgeValue) +{ + QString edge = topEdgeValue.toString(); + Qt::ScreenOrientation orientation = Qt::UnknownOrientation; + + // ### FIXME: This isn't perfect. We should obey the video_route (tv connected) and + // the keyboard slider. + + if (edge == QLatin1String("top")) + orientation = Qt::LandscapeOrientation; + else if (edge == QLatin1String("left")) + orientation = Qt::PortraitOrientation; + else if (edge == QLatin1String("right")) + orientation = Qt::InvertedPortraitOrientation; + else if (edge == QLatin1String("bottom")) + orientation = Qt::InvertedLandscapeOrientation; + + QWindowSystemInterface::handleScreenOrientationChange(QGuiApplication::primaryScreen(), orientation); +} + diff --git a/src/plugins/generic/meego/qmeegointegration.h b/src/plugins/generic/meego/qmeegointegration.h new file mode 100644 index 0000000000..de3b54ffe7 --- /dev/null +++ b/src/plugins/generic/meego/qmeegointegration.h @@ -0,0 +1,72 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the plugins of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU General +** Public License version 3.0 as published by the Free Software Foundation +** and appearing in the file LICENSE.GPL included in the packaging of this +** file. Please review the following information to ensure the GNU General +** Public License version 3.0 requirements will be met: +** http://www.gnu.org/copyleft/gpl.html. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMEEGOINTEGRATION_H +#define QMEEGOINTEGRATION_H + +#include <QObject> +#include <QDBusInterface> + +#include "contextkitproperty.h" + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +class QMeeGoIntegration : public QObject +{ + Q_OBJECT +public: + QMeeGoIntegration(); + ~QMeeGoIntegration(); + +private Q_SLOTS: + void updateScreenOrientation(const QVariant& topEdgeValue); + +private: + QContextKitProperty screenTopEdge; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QMEEGOINTEGRATION_H diff --git a/src/plugins/plugins.pro b/src/plugins/plugins.pro index d88db04f28..8880da3709 100644 --- a/src/plugins/plugins.pro +++ b/src/plugins/plugins.pro @@ -9,4 +9,4 @@ unix { !contains(QT_CONFIG, no-gui): SUBDIRS *= imageformats !isEmpty(QT.widgets.name): SUBDIRS += accessible -SUBDIRS += platforms platforminputcontexts printsupport +SUBDIRS += platforms platforminputcontexts printsupport generic |