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>
This commit is contained in:
parent
9fa2b641ba
commit
6e24833dc9
3
src/plugins/generic/generic.pro
Normal file
3
src/plugins/generic/generic.pro
Normal file
@ -0,0 +1,3 @@
|
||||
TEMPLATE = subdirs
|
||||
|
||||
linux-g++-maemo: SUBDIRS += meego
|
85
src/plugins/generic/meego/contextkitproperty.cpp
Normal file
85
src/plugins/generic/meego/contextkitproperty.cpp
Normal file
@ -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);
|
||||
}
|
||||
|
66
src/plugins/generic/meego/contextkitproperty.h
Normal file
66
src/plugins/generic/meego/contextkitproperty.h
Normal file
@ -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
|
75
src/plugins/generic/meego/main.cpp
Normal file
75
src/plugins/generic/meego/main.cpp
Normal file
@ -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
|
15
src/plugins/generic/meego/meego.pro
Normal file
15
src/plugins/generic/meego/meego.pro
Normal file
@ -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
|
81
src/plugins/generic/meego/qmeegointegration.cpp
Normal file
81
src/plugins/generic/meego/qmeegointegration.cpp
Normal file
@ -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);
|
||||
}
|
||||
|
72
src/plugins/generic/meego/qmeegointegration.h
Normal file
72
src/plugins/generic/meego/qmeegointegration.h
Normal file
@ -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
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user