Commit 17d11b7b authored by Kai Koehne's avatar Kai Koehne
Browse files

Update qmlobserver with latest qmlviewer patches

Update qmlobserver with changes in qmlviewer until 376e636eccedb8d8bb.
parent 77e3bfe8
......@@ -14,5 +14,36 @@
<string>@TYPEINFO@</string>
<key>CFBundleExecutable</key>
<string>@EXECUTABLE@</string>
<key>UTExportedTypeDeclarations</key>
<array>
<dict>
<key>UTTypeIdentifier</key>
<string>com.nokia.qt.qml</string>
<key>UTTypeDescription</key>
<string>Qt Markup Language</string>
<key>UTTypeConformsTo</key>
<array>
<string>public.plain-text</string>
</array>
<key>UTTypeTagSpecification</key>
<dict>
<key>public.filename-extension</key>
<array>
<string>qml</string>
</array>
</dict>
</dict>
</array>
<key>CFBundleDocumentTypes</key>
<array>
<dict>
<key>LSItemContentTypes</key>
<array>
<string>com.nokia.qt.qml</string>
</array>
<key>CFBundleTypeRole</key>
<string>Viewer</string>
</dict>
</array>
</dict>
</plist>
......@@ -39,12 +39,12 @@
**
****************************************************************************/
import Qt 4.7
import QtQuick 1.0
import Qt.labs.folderlistmodel 1.0
Rectangle {
id: root
property bool keyPressed: false
property bool showFocusHighlight: false
property variant folders: folders1
property variant view: view1
width: 320
......@@ -95,6 +95,19 @@ Rectangle {
view.focus = true;
folders.folder = path;
}
function keyPressed(key) {
switch (key) {
case Qt.Key_Up:
case Qt.Key_Down:
case Qt.Key_Left:
case Qt.Key_Right:
root.showFocusHighlight = true;
break;
default:
// do nothing
break;
}
}
Component {
id: folderDelegate
......@@ -113,6 +126,7 @@ Rectangle {
Rectangle {
id: highlight; visible: false
anchors.fill: parent
color: palette.highlight
gradient: Gradient {
GradientStop { id: t1; position: 0.0; color: palette.highlight }
GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) }
......@@ -128,12 +142,16 @@ Rectangle {
text: fileName
anchors.leftMargin: 54
font.pixelSize: 32
color: (wrapper.ListView.isCurrentItem && root.keyPressed) ? palette.highlightedText : palette.windowText
color: (wrapper.ListView.isCurrentItem && root.showFocusHighlight) ? palette.highlightedText : palette.windowText
elide: Text.ElideRight
}
MouseArea {
id: mouseRegion
anchors.fill: parent
onPressed: {
root.showFocusHighlight = false;
wrapper.ListView.view.currentIndex = index;
}
onClicked: { if (folders == wrapper.ListView.view.model) launch() }
}
states: [
......@@ -155,7 +173,15 @@ Rectangle {
width: parent.width
model: folders1
delegate: folderDelegate
highlight: Rectangle { color: palette.highlight; visible: root.keyPressed && view1.count != 0 }
highlight: Rectangle {
color: palette.highlight
visible: root.showFocusHighlight && view1.count != 0
gradient: Gradient {
GradientStop { id: t1; position: 0.0; color: palette.highlight }
GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) }
}
width: view1.currentItem == null ? 0 : view1.currentItem.width
}
highlightMoveSpeed: 1000
pressDelay: 100
focus: true
......@@ -186,7 +212,7 @@ Rectangle {
NumberAnimation { properties: "x"; duration: 250 }
}
]
Keys.onPressed: { root.keyPressed = true; }
Keys.onPressed: root.keyPressed(event.key)
}
ListView {
......@@ -197,7 +223,15 @@ Rectangle {
width: parent.width
model: folders2
delegate: folderDelegate
highlight: Rectangle { color: palette.highlight; visible: root.keyPressed && view2.count != 0 }
highlight: Rectangle {
color: palette.highlight
visible: root.showFocusHighlight && view2.count != 0
gradient: Gradient {
GradientStop { id: t1; position: 0.0; color: palette.highlight }
GradientStop { id: t2; position: 1.0; color: Qt.lighter(palette.highlight) }
}
width: view1.currentItem == null ? 0 : view1.currentItem.width
}
highlightMoveSpeed: 1000
pressDelay: 100
states: [
......@@ -225,11 +259,11 @@ Rectangle {
NumberAnimation { properties: "x"; duration: 250 }
}
]
Keys.onPressed: { root.keyPressed = true; }
Keys.onPressed: root.keyPressed(event.key)
}
Keys.onPressed: {
root.keyPressed = true;
root.keyPressed(event.key);
if (event.key == Qt.Key_Return || event.key == Qt.Key_Select || event.key == Qt.Key_Right) {
view.currentItem.launch();
event.accepted = true;
......
<RCC>
<qresource prefix="/browser">
<file>Browser.qml</file>
<file>images/up.png</file>
<file>images/folder.png</file>
<file>images/titlebar.sci</file>
<file>images/titlebar.png</file>
</qresource>
</RCC>
......@@ -53,6 +53,11 @@ public:
return m_orientation;
}
void pauseListening() {
}
void resumeListening() {
}
void setOrientation(Orientation o) {
if (o != m_orientation) {
m_orientation = o;
......
......@@ -63,6 +63,9 @@ public:
virtual Orientation orientation() const = 0;
virtual void setOrientation(Orientation) = 0;
virtual void pauseListening() = 0;
virtual void resumeListening() = 0;
static DeviceOrientation *instance();
signals:
......
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the tools applications of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, 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.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "deviceorientation.h"
#include <QtDBus>
#include <QDebug>
#define ORIENTATION_SERVICE "com.nokia.SensorService"
#define ORIENTATION_PATH "/org/maemo/contextkit/Screen/TopEdge"
#define CONTEXT_INTERFACE "org.maemo.contextkit.Property"
#define CONTEXT_CHANGED "ValueChanged"
#define CONTEXT_SUBSCRIBE "Subscribe"
#define CONTEXT_UNSUBSCRIBE "Unsubscribe"
#define CONTEXT_GET "Get"
class HarmattanOrientation : public DeviceOrientation
{
Q_OBJECT
public:
HarmattanOrientation()
: o(UnknownOrientation), sensorEnabled(false)
{
resumeListening();
// connect to the orientation change signal
bool ok = QDBusConnection::systemBus().connect(ORIENTATION_SERVICE, ORIENTATION_PATH,
CONTEXT_INTERFACE,
CONTEXT_CHANGED,
this,
SLOT(deviceOrientationChanged(QList<QVariant>,quint64)));
// qDebug() << "connection OK" << ok;
QDBusMessage reply = QDBusConnection::systemBus().call(
QDBusMessage::createMethodCall(ORIENTATION_SERVICE, ORIENTATION_PATH,
CONTEXT_INTERFACE, CONTEXT_GET));
if (reply.type() != QDBusMessage::ErrorMessage) {
QList<QVariant> args;
qvariant_cast<QDBusArgument>(reply.arguments().at(0)) >> args;
deviceOrientationChanged(args, 0);
}
}
~HarmattanOrientation()
{
// unsubscribe from the orientation sensor
if (sensorEnabled)
QDBusConnection::systemBus().call(
QDBusMessage::createMethodCall(ORIENTATION_SERVICE, ORIENTATION_PATH,
CONTEXT_INTERFACE, CONTEXT_UNSUBSCRIBE));
}
inline Orientation orientation() const
{
return o;
}
void setOrientation(Orientation)
{
}
void pauseListening() {
if (sensorEnabled) {
// unsubscribe from the orientation sensor
QDBusConnection::systemBus().call(
QDBusMessage::createMethodCall(ORIENTATION_SERVICE, ORIENTATION_PATH,
CONTEXT_INTERFACE, CONTEXT_UNSUBSCRIBE));
sensorEnabled = false;
}
}
void resumeListening() {
if (!sensorEnabled) {
// subscribe to the orientation sensor
QDBusMessage reply = QDBusConnection::systemBus().call(
QDBusMessage::createMethodCall(ORIENTATION_SERVICE, ORIENTATION_PATH,
CONTEXT_INTERFACE, CONTEXT_SUBSCRIBE));
if (reply.type() == QDBusMessage::ErrorMessage) {
qWarning("Unable to retrieve device orientation: %s", qPrintable(reply.errorMessage()));
} else {
sensorEnabled = true;
}
}
}
private Q_SLOTS:
void deviceOrientationChanged(QList<QVariant> args,quint64)
{
if (args.count() == 0)
return;
Orientation newOrientation = toOrientation(args.at(0).toString());
if (newOrientation != o) {
o = newOrientation;
emit orientationChanged();
}
// qDebug() << "orientation" << args.at(0).toString();
}
private:
static Orientation toOrientation(const QString &nativeOrientation)
{
if (nativeOrientation == "top")
return Landscape;
else if (nativeOrientation == "left")
return Portrait;
else if (nativeOrientation == "bottom")
return LandscapeInverted;
else if (nativeOrientation == "right")
return PortraitInverted;
return UnknownOrientation;
}
private:
Orientation o;
bool sensorEnabled;
};
DeviceOrientation* DeviceOrientation::instance()
{
static HarmattanOrientation *o = new HarmattanOrientation;
return o;
}
#include "deviceorientation_harmattan.moc"
......@@ -50,23 +50,9 @@ class MaemoOrientation : public DeviceOrientation
Q_OBJECT
public:
MaemoOrientation()
: o(UnknownOrientation)
: o(UnknownOrientation), sensorEnabled(false)
{
// enable the orientation sensor
QDBusConnection::systemBus().call(
QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH,
MCE_REQUEST_IF, MCE_ACCELEROMETER_ENABLE_REQ));
// query the initial orientation
QDBusMessage reply = QDBusConnection::systemBus().call(
QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH,
MCE_REQUEST_IF, MCE_DEVICE_ORIENTATION_GET));
if (reply.type() == QDBusMessage::ErrorMessage) {
qWarning("Unable to retrieve device orientation: %s", qPrintable(reply.errorMessage()));
} else {
o = toOrientation(reply.arguments().value(0).toString());
}
resumeListening();
// connect to the orientation change signal
QDBusConnection::systemBus().connect(QString(), MCE_SIGNAL_PATH, MCE_SIGNAL_IF,
MCE_DEVICE_ORIENTATION_SIG,
......@@ -91,6 +77,40 @@ public:
{
}
void pauseListening() {
if (sensorEnabled) {
// disable the orientation sensor
QDBusConnection::systemBus().call(
QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH,
MCE_REQUEST_IF, MCE_ACCELEROMETER_DISABLE_REQ));
sensorEnabled = false;
}
}
void resumeListening() {
if (!sensorEnabled) {
// enable the orientation sensor
QDBusConnection::systemBus().call(
QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH,
MCE_REQUEST_IF, MCE_ACCELEROMETER_ENABLE_REQ));
QDBusMessage reply = QDBusConnection::systemBus().call(
QDBusMessage::createMethodCall(MCE_SERVICE, MCE_REQUEST_PATH,
MCE_REQUEST_IF, MCE_DEVICE_ORIENTATION_GET));
if (reply.type() == QDBusMessage::ErrorMessage) {
qWarning("Unable to retrieve device orientation: %s", qPrintable(reply.errorMessage()));
} else {
Orientation orientation = toOrientation(reply.arguments().value(0).toString());
if (o != orientation) {
o = orientation;
emit orientationChanged();
}
sensorEnabled = true;
}
}
}
private Q_SLOTS:
void deviceOrientationChanged(const QString &newOrientation)
{
......@@ -116,6 +136,7 @@ private:
private:
Orientation o;
bool sensorEnabled;
};
DeviceOrientation* DeviceOrientation::instance()
......
/****************************************************************************
**
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the tools applications of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:LGPL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Lesser General Public License Usage
** Alternatively, 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.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
**
**
**
**
**
**
**
**
** $QT_END_LICENSE$
**
****************************************************************************/
#include "deviceorientation.h"
#include <e32base.h>
#include <sensrvchannelfinder.h>
#include <sensrvdatalistener.h>
#include <sensrvchannel.h>
#include <sensrvorientationsensor.h>
class SymbianOrientation : public DeviceOrientation, public MSensrvDataListener
{
Q_OBJECT
public:
SymbianOrientation()
: DeviceOrientation(), m_current(UnknownOrientation), m_sensorChannel(0), m_channelOpen(false)
{
TRAP_IGNORE(initL());
if (!m_sensorChannel)
qWarning("No valid sensors found.");
}
~SymbianOrientation()
{
if (m_sensorChannel) {
m_sensorChannel->StopDataListening();
m_sensorChannel->CloseChannel();
delete m_sensorChannel;
}
}
void initL()
{
CSensrvChannelFinder *channelFinder = CSensrvChannelFinder::NewLC();
RSensrvChannelInfoList channelInfoList;
CleanupClosePushL(channelInfoList);
TSensrvChannelInfo searchConditions;
searchConditions.iChannelType = KSensrvChannelTypeIdOrientationData;
channelFinder->FindChannelsL(channelInfoList, searchConditions);
for (int i = 0; i < channelInfoList.Count(); ++i) {
TRAPD(error, m_sensorChannel = CSensrvChannel::NewL(channelInfoList[i]));
if (!error)
TRAP(error, m_sensorChannel->OpenChannelL());
if (!error) {
TRAP(error, m_sensorChannel->StartDataListeningL(this, 1, 1, 0));
m_channelOpen = true;
break;
}
if (error) {
delete m_sensorChannel;
m_sensorChannel = 0;
}
}
channelInfoList.Close();
CleanupStack::Pop(&channelInfoList);
CleanupStack::PopAndDestroy(channelFinder);
}
Orientation orientation() const
{
return m_current;
}
void setOrientation(Orientation) { }
private:
DeviceOrientation::Orientation m_current;
CSensrvChannel *m_sensorChannel;
bool m_channelOpen;
void pauseListening() {
if (m_sensorChannel && m_channelOpen) {
m_sensorChannel->StopDataListening();
m_sensorChannel->CloseChannel();
m_channelOpen = false;
}
}
void resumeListening() {
if (m_sensorChannel && !m_channelOpen) {
TRAPD(error, m_sensorChannel->OpenChannelL());
if (!error) {
TRAP(error, m_sensorChannel->StartDataListeningL(this, 1, 1, 0));
if (!error) {
m_channelOpen = true;
}
}
if (error) {
delete m_sensorChannel;
m_sensorChannel = 0;
}
}
}
void DataReceived(CSensrvChannel &channel, TInt count, TInt dataLost)
{
Q_UNUSED(dataLost)
if (channel.GetChannelInfo().iChannelType == KSensrvChannelTypeIdOrientationData) {
TSensrvOrientationData data;
for (int i = 0; i < count; ++i) {
TPckgBuf<TSensrvOrientationData> dataBuf;
channel.GetData(dataBuf);
data = dataBuf();
Orientation orientation = UnknownOrientation;
switch (data.iDeviceOrientation) {
case TSensrvOrientationData::EOrientationDisplayUp:
orientation = Portrait;
break;
case TSensrvOrientationData::EOrientationDisplayRightUp:
orientation = Landscape;
break;
case TSensrvOrientationData::EOrientationDisplayLeftUp:
orientation = LandscapeInverted;
break;
case TSensrvOrientationData::EOrientationDisplayDown:
orientation = PortraitInverted;
break;
case TSensrvOrientationData::EOrientationUndefined:
case TSensrvOrientationData::EOrientationDisplayUpwards:
case TSensrvOrientationData::EOrientationDisplayDownwards: