Merge branch 'qml' of https://vcs.maemo.org/git/situare into qml
authorSami Rämö <sami.ramo@ixonos.com>
Mon, 22 Nov 2010 13:07:05 +0000 (15:07 +0200)
committerSami Rämö <sami.ramo@ixonos.com>
Mon, 22 Nov 2010 13:07:05 +0000 (15:07 +0200)
src/engine/engine.cpp
src/engine/engine.h
src/qmlui/FriendsView.qml
src/qmlui/Map.qml
src/qmlui/declarativeview.cpp [deleted file]
src/qmlui/declarativeview.h [deleted file]
src/src.pro

index 6fa53e1..b292819 100644 (file)
 #include "mce.h"
 #include "network/networkaccessmanager.h"
 #include "situareservice/situareservice.h"
-#include "qmlui/declarativeview.h"
 #include "ui/mainwindow.h"
 #include "qmlui/geomap.h"
 #include "qmlui/rotation.h"
 #include "qmlui/loginlogic.h"
 #include <qdeclarative.h>
+#include <QDeclarativeView>
 #include <QDeclarativeContext>
 #include <QApplication>
 #include <QDesktopWidget>
 #include "qmlui/userimageprovider.h"
 #include "updatelocation.h"
 
+#ifdef Q_WS_MAEMO_5
+#include <QX11Info>
+#include <X11/Xatom.h>
+#include <X11/Xlib.h>
+#endif
+
 const QString SETTINGS_GPS_ENABLED = "GPS_ENABLED"; ///< GPS setting
 const QString SETTINGS_AUTO_CENTERING_ENABLED = "AUTO_CENTERING_ENABLED";///< Auto centering setting
 const int DEFAULT_ZOOM_LEVEL_WHEN_GPS_IS_AVAILABLE = 12;  ///< Default zoom level when GPS available
@@ -75,7 +81,7 @@ public:
     Profile profile;
     UpdateLocation updateLocation;
 
-    DeclarativeView* ui;
+    QDeclarativeView* ui;
 
     int progressIndicatorCount;
 
@@ -107,6 +113,32 @@ public:
         q->m_ui->toggleProgressIndicator(value);
 #endif
     }
+
+    void grabZoomKeys(bool grab)
+    {
+#ifdef QML_UI
+#ifdef Q_WS_MAEMO_5
+        // Can't grab keys unless we have a window id
+        if (!ui->winId())
+            return;
+
+        unsigned long val = (grab) ? 1 : 0;
+        Atom atom = XInternAtom(QX11Info::display(), "_HILDON_ZOOM_KEY_ATOM", False);
+        if (!atom)
+            return;
+
+        XChangeProperty (QX11Info::display(),
+                         ui->winId(),
+                         atom,
+                         XA_INTEGER,
+                         32,
+                         PropModeReplace,
+                         reinterpret_cast<unsigned char *>(&val),
+                         1);
+#endif
+#endif
+        Q_UNUSED(grab);
+    }
 };
 
 SituareEngine::SituareEngine()
@@ -190,7 +222,8 @@ SituareEngine::SituareEngine()
 
     Q_D(SituareEngine);
 
-    d->ui = new DeclarativeView(QApplication::desktop());
+    d->ui = new QDeclarativeView(QApplication::desktop());
+    d->grabZoomKeys(true);
 #ifdef Q_WS_MAEMO_5
 //    d->ui->setAttribute(Qt::WA_Maemo5AutoOrientation, true);
 #endif
@@ -216,10 +249,6 @@ SituareEngine::SituareEngine()
     geoMap->setFriendModels(&d->friendModel, &d->friendProxyModel);
     geoMap->setRouteModel(&d->routeModel);
 
-    connect(d->ui, SIGNAL(zoomIn()), geoMap, SLOT(zoomIn()));
-    connect(d->ui, SIGNAL(zoomOut()), geoMap, SLOT(zoomOut()));
-
-
     connect(d->ui->engine()->networkAccessManager(),
             SIGNAL(sslErrors(QNetworkReply*, QList<QSslError>)),
             m_facebookAuthenticator, SLOT(sslErrors(QNetworkReply*, QList<QSslError>)));
@@ -248,6 +277,9 @@ SituareEngine::~SituareEngine()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
+    Q_D(SituareEngine);
+    d->grabZoomKeys(false);
+
     delete m_ui;
 
     QSettings settings(SETTINGS_ORGANIZATION_NAME, SETTINGS_APPLICATION_NAME);
index fa2e4e7..dcc9889 100644 (file)
@@ -153,6 +153,14 @@ public slots:
       */
     void routeFromTo(double fromLatitude, double fromLongitude, double toLatitude, double toLongitude);
 
+    /**
+    * @brief Shows contact dialog.
+    *
+    * Calls MainWindow showContactDialog with contact guid defined by contact's Facebook ID.
+    * @param facebookId contact's facebookId
+    */
+    void showContactDialog(const QString &facebookId);
+
 private:
     /**
     * @brief Read settings and determine whether to use GPS and autocentering.
@@ -292,14 +300,6 @@ private slots:
     void setPowerSaving(bool enabled);
 
     /**
-    * @brief Shows contact dialog.
-    *
-    * Calls MainWindow showContactDialog with contact guid defined by contact's Facebook ID.
-    * @param facebookId contact's facebookId
-    */
-    void showContactDialog(const QString &facebookId);
-
-    /**
     * @brief Automatic update interval timer timeout.
     *
     * Requests update location if user has moved.
index 444c4f7..961fcd2 100644 (file)
@@ -25,9 +25,9 @@ ListBase {
         Row {
             Image {
                 id: routeButton
-                source: "qrc:/res/images/route_to_friend.png"
+                source: routeButtonArea.pressed ? "qrc:/res/images/route_to_friend_s.png" : "qrc:/res/images/route_to_friend.png"
                 MouseArea {
-                    id: mouseArea
+                    id: routeButtonArea
                     anchors.fill: parent
                     onClicked: {
                         engine.routeFromTo(map.gpsLocationLatitude, map.gpsLocationLongitude, latitude, longitude);
@@ -36,7 +36,14 @@ ListBase {
             }
             Image {
                 id: contactButton
-                source: "qrc:/res/images/contact.png"
+                source: contactButtonArea.pressed ? "qrc:/res/images/contact_s.png" : "qrc:/res/images/contact.png"
+                MouseArea {
+                    id: contactButtonArea
+                    anchors.fill: parent
+                    onClicked: {
+                        engine.showContactDialog(userId);
+                    }
+                }
             }
         }
     }
index eb92bf2..8d9fbc2 100644 (file)
@@ -98,6 +98,13 @@ Item {
             }
         }
 
+        Keys.onPressed: {
+            if (event.key == Qt.Key_F7)
+                map.zoomIn()
+            else if (event.key == Qt.Key_F8)
+                map.zoomOut()
+        }
+
         Image {
             id: sight
             x: parent.width/2 - width/2
diff --git a/src/qmlui/declarativeview.cpp b/src/qmlui/declarativeview.cpp
deleted file mode 100644 (file)
index e49dab7..0000000
+++ /dev/null
@@ -1,65 +0,0 @@
-#include "declarativeview.h"
-#include <QDebug>
-#include <QKeyEvent>
-#ifdef Q_WS_MAEMO_5
-#include <QtMaemo5/QMaemo5InformationBox>
-#include <QtGui/QX11Info>
-#include <X11/Xatom.h>
-#include <X11/Xlib.h>
-#endif // Q_WS_MAEMO_5
-
-DeclarativeView::DeclarativeView(QWidget *parent) :
-    QDeclarativeView(parent)
-{
-    grabZoomKeys(true);
-}
-
-DeclarativeView::~DeclarativeView()
-{
-    grabZoomKeys(false);
-}
-
-void DeclarativeView::keyPressEvent(QKeyEvent* event)
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-    switch (event->key()) {
-    case Qt::Key_F7:
-        event->accept();
-        emit zoomIn();
-        break;
-
-    case Qt::Key_F8:
-        event->accept();
-        emit zoomOut();
-        break;
-    }
-    QDeclarativeView::keyPressEvent(event);
-}
-
-void DeclarativeView::grabZoomKeys(bool grab)
-{
-    qDebug() << __PRETTY_FUNCTION__;
-
-#ifdef Q_WS_MAEMO_5
-    // Can't grab keys unless we have a window id
-    if (!winId())
-        return;
-
-    unsigned long val = (grab) ? 1 : 0;
-    Atom atom = XInternAtom(QX11Info::display(), "_HILDON_ZOOM_KEY_ATOM", False);
-    if (!atom)
-        return;
-
-    XChangeProperty (QX11Info::display(),
-                     winId(),
-                     atom,
-                     XA_INTEGER,
-                     32,
-                     PropModeReplace,
-                     reinterpret_cast<unsigned char *>(&val),
-                     1);
-#else
-    Q_UNUSED(grab);
-#endif // Q_WS_MAEMO_5
-}
diff --git a/src/qmlui/declarativeview.h b/src/qmlui/declarativeview.h
deleted file mode 100644 (file)
index 8af9575..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-#ifndef DECLARATIVEVIEW_H
-#define DECLARATIVEVIEW_H
-
-#include <QDeclarativeView>
-
-class DeclarativeView : public QDeclarativeView
-{
-    Q_OBJECT
-
-public:
-    explicit DeclarativeView(QWidget *parent = 0);
-    virtual ~DeclarativeView();
-
-    virtual void keyPressEvent(QKeyEvent *event);
-
-signals:
-    void zoomIn();
-    void zoomOut();
-
-private:
-    void grabZoomKeys(bool grab);
-};
-
-#endif // DECLARATIVEVIEW_H
index 4faf42e..f3ce005 100644 (file)
@@ -94,8 +94,7 @@ SOURCES += main.cpp \
     engine/updatelocation.cpp \
     user/friendmodel.cpp \
     user/profile.cpp \
-    qmlui/userimageprovider.cpp \
-    qmlui/declarativeview.cpp
+    qmlui/userimageprovider.cpp
 
 HEADERS += application.h \
     common.h \
@@ -189,8 +188,7 @@ HEADERS += application.h \
     engine/updatelocation.h \
     user/friendmodel.h \
     user/profile.h \
-    qmlui/userimageprovider.h \
-    qmlui/declarativeview.h
+    qmlui/userimageprovider.h
 
 OTHER_FILES += qmlui/Main.qml \
     qmlui/Dialog.qml \