Added distance indicator button
authorKatri Kaikkonen <katri.kaikkonen@ixonos.com>
Thu, 22 Jul 2010 06:42:24 +0000 (09:42 +0300)
committerKatri Kaikkonen <katri.kaikkonen@ixonos.com>
Thu, 22 Jul 2010 06:42:24 +0000 (09:42 +0300)
src/engine/engine.cpp
src/engine/engine.h
src/src.pro
src/ui/indicatorbutton.cpp [new file with mode: 0644]
src/ui/indicatorbutton.h [new file with mode: 0644]
src/ui/mainwindow.cpp
src/ui/mainwindow.h
src/ui/panelcommon.h
src/ui/userinfopanel.h

index 601ac66..86f3f15 100644 (file)
@@ -46,7 +46,7 @@ const int MIN_UPDATE_INTERVAL_MSECS = 5*60*1000;
 
 SituareEngine::SituareEngine(QMainWindow *parent)
     : QObject(parent),
-      m_autoCenteringEnabled(false),
+//      m_autoCenteringEnabled(false),
       m_automaticUpdateFirstStart(true),
       m_automaticUpdateRequest(false),
       m_userMoved(false),
@@ -117,24 +117,24 @@ SituareEngine::~SituareEngine()
 
     QSettings settings(DIRECTORY_NAME, FILE_NAME);
     settings.setValue(SETTINGS_GPS_ENABLED, m_gps->isRunning());
-    settings.setValue(SETTINGS_AUTO_CENTERING_ENABLED, m_autoCenteringEnabled);
+//    settings.setValue(SETTINGS_AUTO_CENTERING_ENABLED, m_autoCenteringEnabled);
 }
 
-void SituareEngine::changeAutoCenteringSetting(bool enabled)
-{
-    qDebug() << __PRETTY_FUNCTION__;
+//void SituareEngine::changeAutoCenteringSetting(bool enabled)
+//{
+//    qDebug() << __PRETTY_FUNCTION__;
 
-    m_autoCenteringEnabled = enabled;
-    enableAutoCentering(enabled);
-}
+//    m_autoCenteringEnabled = enabled;
+//    enableAutoCentering(enabled);
+//}
 
-void SituareEngine::disableAutoCentering()
-{
-    qDebug() << __PRETTY_FUNCTION__;
+//void SituareEngine::disableAutoCentering()
+//{
+//    qDebug() << __PRETTY_FUNCTION__;
 
-    changeAutoCenteringSetting(false);
-    m_ui->buildInformationBox(tr("Auto centering disabled"));
-}
+//    changeAutoCenteringSetting(false);
+//    m_ui->buildInformationBox(tr("Auto centering disabled"));
+//}
 
 void SituareEngine::displayStateChanged(bool enabled)
 {
@@ -142,20 +142,20 @@ void SituareEngine::displayStateChanged(bool enabled)
 
     m_gps->enablePowerSave(!enabled);
 
-    if (m_autoCenteringEnabled)
-        enableAutoCentering(enabled);
+//    if (m_autoCenteringEnabled)
+//        enableAutoCentering(enabled);
 }
 
-void SituareEngine::enableAutoCentering(bool enabled)
-{
-    qDebug() << __PRETTY_FUNCTION__;
+//void SituareEngine::enableAutoCentering(bool enabled)
+//{
+//    qDebug() << __PRETTY_FUNCTION__;
 
-    m_ui->setAutoCenteringButtonEnabled(enabled);
-    m_mapEngine->setAutoCentering(enabled);
+//    m_ui->setAutoCenteringButtonEnabled(enabled);
+//    m_mapEngine->setAutoCentering(enabled);
 
-    if (enabled)
-        m_gps->requestLastPosition();
-}
+//    if (enabled)
+//        m_gps->requestLastPosition();
+//}
 
 void SituareEngine::enableGPS(bool enabled)
 {
@@ -169,7 +169,7 @@ void SituareEngine::enableGPS(bool enabled)
 
         if (enabled && !m_gps->isRunning()) {
             m_gps->start();
-            enableAutoCentering(m_autoCenteringEnabled);
+//            enableAutoCentering(m_autoCenteringEnabled);
             m_gps->requestLastPosition();
 
             if(m_ui->loginState())
@@ -177,7 +177,7 @@ void SituareEngine::enableGPS(bool enabled)
         }
         else if (!enabled && m_gps->isRunning()) {
             m_gps->stop();
-            enableAutoCentering(false);
+//            enableAutoCentering(false);
             enableAutomaticLocationUpdate(false);
         }
     }
@@ -334,7 +334,7 @@ void SituareEngine::initializeGpsAndAutocentering()
 
     QSettings settings(DIRECTORY_NAME, FILE_NAME);
     QVariant gpsEnabled = settings.value(SETTINGS_GPS_ENABLED);
-    QVariant autoCenteringEnabled = settings.value(SETTINGS_AUTO_CENTERING_ENABLED);
+//    QVariant autoCenteringEnabled = settings.value(SETTINGS_AUTO_CENTERING_ENABLED);
 
     if (m_gps->isInitialized()) {
 
@@ -343,20 +343,20 @@ void SituareEngine::initializeGpsAndAutocentering()
             connect(m_gps, SIGNAL(position(QPointF,qreal)),
                     this, SLOT(setFirstStartZoomLevel(QPointF,qreal)));
 
-            changeAutoCenteringSetting(true);
+//            changeAutoCenteringSetting(true);
             enableGPS(true);
 
             m_ui->buildInformationBox(tr("GPS enabled"));
             m_ui->buildInformationBox(tr("Auto centering enabled"));
 
         } else { // Normal start
-            changeAutoCenteringSetting(autoCenteringEnabled.toBool());
+//            changeAutoCenteringSetting(autoCenteringEnabled.toBool());
             enableGPS(gpsEnabled.toBool());
 
             if (gpsEnabled.toBool())
                 m_ui->buildInformationBox(tr("GPS enabled"));
 
-            if (gpsEnabled.toBool() && autoCenteringEnabled.toBool())
+            if (gpsEnabled.toBool()) /*&& autoCenteringEnabled.toBool())*/
                 m_ui->buildInformationBox(tr("Auto centering enabled"));
         }
     } else {
@@ -489,8 +489,8 @@ void SituareEngine::setFirstStartZoomLevel(QPointF latLonCoordinate, qreal accur
     Q_UNUSED(latLonCoordinate);
     Q_UNUSED(accuracy);
 
-    if (m_autoCenteringEnabled) // autocentering is disabled when map is scrolled
-        m_mapEngine->setZoomLevel(DEFAULT_ZOOM_LEVEL_WHEN_GPS_IS_AVAILABLE);
+//    if (m_autoCenteringEnabled) // autocentering is disabled when map is scrolled
+//        m_mapEngine->setZoomLevel(DEFAULT_ZOOM_LEVEL_WHEN_GPS_IS_AVAILABLE);
 
     disconnect(m_gps, SIGNAL(position(QPointF,qreal)),
                this, SLOT(setFirstStartZoomLevel(QPointF,qreal)));
@@ -570,8 +570,8 @@ void SituareEngine::signalsFromMainWindow()
             m_mapEngine, SLOT(zoomOut()));
 
     // signals from menu buttons
-    connect(m_ui, SIGNAL(autoCenteringTriggered(bool)),
-            this, SLOT(changeAutoCenteringSetting(bool)));
+//    connect(m_ui, SIGNAL(autoCenteringTriggered(bool)),
+//            this, SLOT(changeAutoCenteringSetting(bool)));
 
     connect(m_ui, SIGNAL(gpsTriggered(bool)),
             this, SLOT(enableGPS(bool)));
@@ -614,8 +614,8 @@ void SituareEngine::signalsFromMapEngine()
     connect(m_mapEngine, SIGNAL(zoomLevelChanged(int)),
             m_ui, SIGNAL(zoomLevelChanged(int)));
 
-    connect(m_mapEngine, SIGNAL(mapScrolledManually()),
-            this, SLOT(disableAutoCentering()));
+//    connect(m_mapEngine, SIGNAL(mapScrolledManually()),
+//            this, SLOT(disableAutoCentering()));
 
     connect(m_mapEngine, SIGNAL(maxZoomLevelReached()),
             m_ui, SIGNAL(maxZoomLevelReached()));
index 88c738c..4914942 100644 (file)
@@ -185,12 +185,12 @@ private slots:
     *
     * @param enabled true if enabled, false otherwise
     */
-    void changeAutoCenteringSetting(bool enabled);
+//    void changeAutoCenteringSetting(bool enabled);
 
     /**
     * @brief Slot for disabling automatic centering when map is scrolled manually
     */
-    void disableAutoCentering();
+//    void disableAutoCentering();
 
     /**
     * @brief Slot for display state changed.
@@ -206,7 +206,7 @@ private slots:
     *
     * @param enabled true if auto centering was enabled, false otherwise
     */
-    void enableAutoCentering(bool enabled);
+//    void enableAutoCentering(bool enabled);
 
     /**
     * @brief Slot for gps enabling.
@@ -283,7 +283,7 @@ signals:
  * DATA MEMBERS
  ******************************************************************************/
 private:
-    bool m_autoCenteringEnabled;        ///< Auto centering flag
+//    bool m_autoCenteringEnabled;        ///< Auto centering flag
     bool m_automaticUpdateFirstStart;   ///< Automatic location update first start flag
     bool m_automaticUpdateRequest;      ///< Flag for automatic update request
     bool m_userMoved;                   ///< Flag for user move
index 577dca8..ff30302 100644 (file)
@@ -53,7 +53,8 @@ SOURCES += main.cpp \
     ui/zoombuttonpanel.cpp \
     user/user.cpp \
     ui/fullscreenbutton.cpp \
-    engine/mce.cpp
+    engine/mce.cpp \
+    ui/indicatorbutton.cpp
 HEADERS += common.h \
     engine/engine.h \
     facebookservice/facebookauthentication.h \
@@ -104,7 +105,8 @@ HEADERS += common.h \
     ui/zoombuttonpanel.h \
     user/user.h \
     ui/fullscreenbutton.h \
-    engine/mce.h
+    engine/mce.h \
+    ui/indicatorbutton.h
 QT += network \
     webkit
 
diff --git a/src/ui/indicatorbutton.cpp b/src/ui/indicatorbutton.cpp
new file mode 100644 (file)
index 0000000..dfe0f23
--- /dev/null
@@ -0,0 +1,204 @@
+/*
+   Situare - A location system for Facebook
+   Copyright (C) 2010  Ixonos Plc. Authors:
+
+       Kaj Wallin - kaj.wallin@ixonos.com
+       Katri Kaikkonen - katri.kaikkonen@ixonos.com
+
+   Situare is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as published by the Free Software Foundation.
+
+   Situare is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Situare; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+   USA.
+*/
+#include <QDebug>
+#include <QPainter>
+#include <QSettings>
+
+#include "indicatorbutton.h"
+#include "math.h"
+#include "common.h"
+#include "panelcommon.h"
+
+const int ROUNDING_RADIUS = 9;  ///< Roundness of the rounded edge
+const qreal OPACITY = 0.13;     ///< Opacity of the background in percents
+const int BUTTON_WIDTH = 66;    ///< Button width
+const int BUTTON_HEIGHT = 66;   ///< Button height
+
+IndicatorButton::IndicatorButton(QWidget *parent)
+    : QToolButton(parent),
+      m_isDraggable(false)
+{
+    setIcon(QIcon::fromTheme(QLatin1String("general_fullsize")));
+    setFixedSize(BUTTON_WIDTH, BUTTON_HEIGHT);
+
+    QPalette pal = palette();
+    QColor backgroundColor = pal.color(backgroundRole());
+    backgroundColor.setAlpha(floor(OPACITY * 255));
+    pal.setColor(backgroundRole(), backgroundColor);
+    setPalette(pal);
+
+    setAutoFillBackground(true);
+
+    m_dragStartTimer = new QTimer(this);
+    m_dragStartTimer->setSingleShot(true);
+    m_dragStartTimer->setInterval(DRAG_INIT_TIME);
+
+    m_forceReleaseTimer = new QTimer(this);
+    m_forceReleaseTimer->setSingleShot(true);
+    m_forceReleaseTimer->setInterval(FORCE_RELEASE_TIME);
+
+    connect(this, SIGNAL(pressed()),
+            m_dragStartTimer, SLOT(start()));
+    connect(this, SIGNAL(released()),
+            m_dragStartTimer, SLOT(stop()));
+
+    connect(m_dragStartTimer, SIGNAL(timeout()),
+            this, SLOT(timerExpired()));
+    connect(m_forceReleaseTimer, SIGNAL(timeout()),
+            this, SLOT(forceMouseRelease()));
+
+    connect(this, SIGNAL(triggered(bool)),
+        this, SIGNAL(autoCenteringTriggered(bool)));
+
+    // Create mask to round the corners of the background
+    QRegion maskbase(rect());
+
+    // left top corner
+    QRegion leftTopBase(QRect(0, 0, ROUNDING_RADIUS, ROUNDING_RADIUS));
+    QRegion leftTopRounding(QRect(0, 0, 2 * ROUNDING_RADIUS, 2 * ROUNDING_RADIUS), QRegion::Ellipse);
+    QRegion leftTopClipped = leftTopBase.subtract(leftTopRounding);
+
+    // right top corner
+    QRegion rightTopBase(QRect(rect().width() - ROUNDING_RADIUS, 0,
+                                    rect().width(), ROUNDING_RADIUS));
+    QRegion rightTopRounding(QRect(rect().width() - 2 * ROUNDING_RADIUS, 0,
+                                      2 * ROUNDING_RADIUS, 2 * ROUNDING_RADIUS), QRegion::Ellipse);
+    QRegion rightTopClipped = rightTopBase.subtract(rightTopRounding);
+
+    // left bottom corner
+    QRegion leftBottomBase(QRect(0, rect().height() - ROUNDING_RADIUS,
+                                    ROUNDING_RADIUS, rect().height()));
+    QRegion leftBottomRounding(QRect(0, rect().height() - 2 * ROUNDING_RADIUS,
+                                      2 * ROUNDING_RADIUS, 2 * ROUNDING_RADIUS), QRegion::Ellipse);
+    QRegion leftBottomClipped = leftBottomBase.subtract(leftBottomRounding);
+
+    // right bottom corner
+    QRegion rightBottomBase(QRect(rect().width() - ROUNDING_RADIUS, rect().height()- ROUNDING_RADIUS,
+                                    rect().height() - ROUNDING_RADIUS, rect().width()- ROUNDING_RADIUS));
+    QRegion rightBottomRounding(QRect(rect().width() - 2 * ROUNDING_RADIUS, rect().height() - 2 * ROUNDING_RADIUS,
+                                      2 * ROUNDING_RADIUS, 2 * ROUNDING_RADIUS), QRegion::Ellipse);
+    QRegion rightBottomClipped = rightBottomBase.subtract(rightBottomRounding);
+
+    QRegion cutter = leftTopClipped.unite(rightTopClipped.unite(leftBottomClipped.unite(rightBottomClipped)));
+
+    QRegion mask = maskbase.subtract(cutter);
+
+    setMask(mask);
+}
+
+void IndicatorButton::mousePressEvent(QMouseEvent *event)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    if (event->button() == Qt::LeftButton) {
+        m_dragPosition = event->pos();
+    }
+    m_dragStartTimer->start();
+    QWidget::mousePressEvent(event);
+}
+
+void IndicatorButton::mouseMoveEvent(QMouseEvent *event)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    if(m_isDraggable) {
+        if (event->buttons() & Qt::LeftButton) {
+            QPoint newLocation = mapToParent(event->pos()) - m_dragPosition;
+
+            if (newLocation.x() < SIDEBAR_WIDTH)
+                newLocation.rx() = SIDEBAR_WIDTH;
+            else if (newLocation.x() > m_screenSize.width() - width() - SIDEBAR_WIDTH)
+                newLocation.rx() =  m_screenSize.width() - width() - SIDEBAR_WIDTH;
+
+            if (newLocation.y() < 0)
+                newLocation.ry() = 0;
+            else if (newLocation.y() > m_screenSize.height() - height())
+                newLocation.ry() = m_screenSize.height() - height();
+
+            move(newLocation);
+        }
+    } else
+        if(!rect().contains(event->pos()))
+            m_dragStartTimer->stop();
+
+    QWidget::mouseMoveEvent(event);
+}
+
+void IndicatorButton::mouseReleaseEvent(QMouseEvent *event)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_dragStartTimer->stop();
+
+    Q_UNUSED(event);
+    if(m_isDraggable) {
+        setDraggable(false);
+//        QSettings settings(DIRECTORY_NAME, FILE_NAME);
+//        settings.setValue(ZOOMPANEL_POSITION, pos());
+        releaseMouse();
+    }
+    QWidget::mouseReleaseEvent(event);
+}
+
+void IndicatorButton::setDraggable(bool mode, QPoint eventPosition)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_isDraggable = mode;
+
+    if(mode) {
+        setAutoFillBackground(true);
+        grabMouse();
+        m_forceReleaseTimer->start();
+        m_dragPosition = eventPosition;
+    } else {
+        setAutoFillBackground(false);
+        releaseMouse();
+        m_forceReleaseTimer->stop();
+
+    }
+}
+
+const QPoint& IndicatorButton::eventPosition()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    return m_eventPosition;
+}
+
+void IndicatorButton::forceMouseRelease()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    releaseMouse();
+    setDraggable(false);
+}
+
+void IndicatorButton::timerExpired()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    if(this->isDown())
+        m_dragPosition = this->eventPosition();
+
+    setDraggable(true, m_dragPosition);
+}
diff --git a/src/ui/indicatorbutton.h b/src/ui/indicatorbutton.h
new file mode 100644 (file)
index 0000000..c5530c6
--- /dev/null
@@ -0,0 +1,138 @@
+/*
+   Situare - A location system for Facebook
+   Copyright (C) 2010  Ixonos Plc. Authors:
+
+       Kaj Wallin - kaj.wallin@ixonos.com
+       Katri Kaikkonen - katri.kaikkonen@ixonos.com
+
+   Situare is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as published by the Free Software Foundation.
+
+   Situare is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Situare; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+   USA.
+*/
+
+#ifndef INDICATORBUTTON_H
+#define INDICATORBUTTON_H
+
+#include <QWidget>
+#include <QToolButton>
+#include <QTimer>
+#include <QMouseEvent>
+#include <QPaintEvent>
+#include "../user/user.h"
+
+/**
+* @brief Indicator button class
+*
+* @class IndicatorButton indicatorbutton.h "ui/indicatorbutton.h"
+*/
+class IndicatorButton : public  QToolButton
+{
+   Q_OBJECT
+
+public:
+   /**
+    * @brief Constructor
+    *
+    * @param parent Parent widget
+    */
+   IndicatorButton(QWidget *parent = 0);
+
+/*******************************************************************************
+* BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
+******************************************************************************/
+protected:
+
+   /**
+    * @brief Move event for the zoom button panel
+    *
+    * @param event Event
+    */
+   void mouseMoveEvent(QMouseEvent *event);
+
+   /**
+    * @brief Press event for the zoom button panel
+    *
+    * @param event Event
+    */
+   void mousePressEvent(QMouseEvent *event);
+
+   /**
+    * @brief Event handler for mouse release events
+    *
+    * @param event Mouse event
+    */
+   void mouseReleaseEvent(QMouseEvent *event);
+
+
+/*******************************************************************************
+* MEMBER FUNCTIONS AND SLOTS
+******************************************************************************/
+
+public slots:
+
+    /**
+    * @brief Relative position of the event inside the widget
+    */
+    const QPoint& eventPosition();
+
+    /**
+     * @brief Toggle zoom panel draggability
+     */
+    void setDraggable(bool mode, QPoint eventPosition = QPoint(0,0));
+
+//    /**
+//    * @brief Slot to redraw the panel after window resize event
+//    *
+//    * @param size Size of the new screen
+//    */
+//    void screenResized(const QSize &size);
+
+private slots:
+    /**
+     * @brief Safeguard slot to release mouse grab if something goes horribly wrong
+     */
+    void forceMouseRelease();
+
+    /**
+     * @brief Slot that handles drag initialization once timer has timed out
+     */
+    void timerExpired();
+
+/*******************************************************************************
+ * SIGNALS
+ ******************************************************************************/
+signals:
+    /**
+    * @brief Automatic centering setting changed by user
+    *
+    * @param enabled True if automatic centering is enabled, otherwise false
+    */
+    void autoCenteringTriggered(bool enabled);
+
+/*******************************************************************************
+* DATA MEMBERS
+******************************************************************************/
+private:
+   bool m_isDraggable;             ///< Boolean for tracking the draggability state
+
+   QPoint m_dragPosition;          ///< Location from where the widget is grabbed
+   QPoint m_eventPosition;     ///< Position of mousePressEvent
+
+   QSize m_screenSize;             ///< Store for the screen size
+
+   QTimer *m_dragStartTimer;       ///< Timer to init draggability of the zoom panel
+   QTimer *m_forceReleaseTimer;    ///< Timer to run forceMouseRelease;
+
+};
+
+#endif // INDICATORBUTTON_H
index 1d0a247..c158b9b 100644 (file)
@@ -33,6 +33,7 @@
 #include "common.h"
 #include "friendlistpanel.h"
 #include "fullscreenbutton.h"
+#include "indicatorbutton.h"
 #include "logindialog.h"
 #include "mapscale.h"
 #include "settingsdialog.h"
@@ -60,6 +61,7 @@ MainWindow::MainWindow(QWidget *parent)
     m_email(),    
     m_password(),
     m_fullScreenButton(0),
+    m_indicatorButton(0),
     m_webView(0),
     m_mapScale(0),
     m_cookieJar(0)
@@ -92,9 +94,11 @@ MainWindow::MainWindow(QWidget *parent)
         m_osmLicense->stackUnder(m_zoomButtonPanel);
     }
     m_ownLocationCrosshair->stackUnder(m_osmLicense);
-    m_mapScale->stackUnder(m_ownLocationCrosshair);
+    m_indicatorButton->stackUnder(m_ownLocationCrosshair);
+    m_mapScale->stackUnder(m_indicatorButton);
     m_mapView->stackUnder(m_mapScale);
 
+
     grabZoomKeys(true);
 
     // Set default screen size
@@ -171,6 +175,17 @@ void MainWindow::buildFriendListPanel()
             this, SIGNAL(findFriend(QPointF)));
 }
 
+void MainWindow::buildIndicatorButton()
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_indicatorButton = new IndicatorButton(this);
+
+    connect(m_indicatorButton, SIGNAL(triggered(bool)),
+        this, SIGNAL(autoCenteringTriggered(bool)));
+
+}
+
 void MainWindow::buildInformationBox(const QString &message, bool modal)
 {
     qDebug() << __PRETTY_FUNCTION__;
@@ -228,6 +243,7 @@ void MainWindow::buildMap()
     buildOsmLicense();
     buildManualLocationCrosshair();
     buildFullScreenButton();
+    buildIndicatorButton();
     buildMapScale();
 
     connect(m_mapView, SIGNAL(viewScrolled(QPoint)),
@@ -411,17 +427,17 @@ void MainWindow::createMenus()
             this, SIGNAL(gpsTriggered(bool)));
 
     // automatic centering
-    m_autoCenteringAct = new QAction(tr("Auto centering"), this);
-    m_autoCenteringAct->setCheckable(true);
-    connect(m_autoCenteringAct, SIGNAL(triggered(bool)),
-        this, SIGNAL(autoCenteringTriggered(bool)));
+//    m_autoCenteringAct = new QAction(tr("Auto centering"), this);
+//    m_autoCenteringAct->setCheckable(true);
+//    connect(m_autoCenteringAct, SIGNAL(triggered(bool)),
+//        this, SIGNAL(autoCenteringTriggered(bool)));
 
     // build the actual menu
     m_viewMenu = menuBar()->addMenu(tr("Main"));
     m_viewMenu->addAction(m_loginAct);
     m_viewMenu->addAction(m_toSettingsAct);
     m_viewMenu->addAction(m_gpsToggleAct);
-    m_viewMenu->addAction(m_autoCenteringAct);
+//    m_viewMenu->addAction(m_autoCenteringAct);
     m_viewMenu->setObjectName(tr("Menu"));
 }
 
@@ -481,6 +497,25 @@ void MainWindow::drawFullScreenButton(const QSize &size)
     }
 }
 
+void MainWindow::drawIndicatorButton(const QSize &size)
+{
+    qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
+
+    const int LEFT_SCALE_MARGIN = 10;
+    const int BOTTOM_SCALE_MARGIN = 80;
+
+    if(m_indicatorButton) {
+        if(m_loggedIn) {
+            m_indicatorButton->move(PANEL_PEEK_AMOUNT + LEFT_SCALE_MARGIN,
+                             size.height() - m_mapScale->size().height() - BOTTOM_SCALE_MARGIN);
+
+        } else {
+            m_indicatorButton->move(PANEL_PEEK_AMOUNT + LEFT_SCALE_MARGIN,
+                             size.height() - m_mapScale->size().height() - BOTTOM_SCALE_MARGIN);
+        }
+    }
+}
+
 void MainWindow::drawMapScale(const QSize &size)
 {
     const int LEFT_SCALE_MARGIN = 10;
@@ -767,12 +802,12 @@ void MainWindow::saveCookies()
     settings.setValue(COOKIES, list);
 }
 
-void MainWindow::setAutoCenteringButtonEnabled(bool enabled)
-{
-    qDebug() << __PRETTY_FUNCTION__;
+//void MainWindow::setAutoCenteringButtonEnabled(bool enabled)
+//{
+//    qDebug() << __PRETTY_FUNCTION__;
 
-    m_autoCenteringAct->setChecked(enabled);
-}
+//    m_autoCenteringAct->setChecked(enabled);
+//}
 
 void MainWindow::setGPSButtonEnabled(bool enabled)
 {
@@ -782,7 +817,17 @@ void MainWindow::setGPSButtonEnabled(bool enabled)
 
     setOwnLocationCrosshairVisibility(!enabled);
 
-    m_autoCenteringAct->setVisible(enabled);
+//    m_autoCenteringAct->setVisible(enabled);
+}
+
+void MainWindow::setIndicatorButtonEnabled(bool enabled)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+
+    m_indicatorButton->setChecked(enabled);
+
+    connect(m_autoCenteringAct, SIGNAL(triggered(bool)),
+            this, SIGNAL(autoCenteringTriggered(bool)));
 }
 
 void MainWindow::setMapViewScene(QGraphicsScene *scene)
@@ -881,11 +926,13 @@ void MainWindow::showPanels()
     qDebug() << __PRETTY_FUNCTION__;
 
     drawFullScreenButton(m_viewPortSize);
+    drawIndicatorButton(m_viewPortSize);
 
     if(m_loggedIn) {
         if(!m_friendsListPanel->isVisible()) {
             m_friendsListPanel->show();
             m_friendsListPanelSidebar->show();
+            m_indicatorButton->show();
         }
 
         if(!m_userPanel->isVisible()) {
@@ -895,6 +942,12 @@ void MainWindow::showPanels()
     }
 }
 
+//void MainWindow::showIndicatorButton(bool gps, bool autoCentering)
+//{
+//    qDebug() << __PRETTY_FUNCTION__;
+
+//}
+
 void MainWindow::startLoginProcess()
 {
     qDebug() << __PRETTY_FUNCTION__;
index fe93387..16efacf 100644 (file)
@@ -38,6 +38,7 @@ class QNetworkReply;
 class FacebookAuthentication;
 class FullScreenButton;
 class FriendListPanel;
+class IndicatorButton;
 class MapScale;
 class MapScene;
 class MapView;
@@ -113,7 +114,7 @@ public:
     *
     * @param enabled true if shoud be enabled, false otherwise
     */
-    void setAutoCenteringButtonEnabled(bool enabled);
+//    void setAutoCenteringButtonEnabled(bool enabled);
 
     /**
     * @brief Enable / disable GPS button.
@@ -125,6 +126,13 @@ public:
     void setGPSButtonEnabled(bool enabled);
 
     /**
+    * @brief Enable / disable direction indicator button.
+    *
+    * @param enabled true if shoud be enabled, false otherwise
+    */
+    void setIndicatorButtonEnabled(bool enabled);
+
+    /**
       * @brief Set scene for MapView
       *
       * @param scene Scene to be set
@@ -146,6 +154,12 @@ public:
     const QString username();
 
 public slots:
+
+    /**
+      * @brief Build direction indicator button and connect slots
+      */
+    void buildIndicatorButton();
+
     /**
     * @brief Builds information box with message.
     *
@@ -313,6 +327,14 @@ private slots:
     void drawFullScreenButton(const QSize &size);
 
     /**
+    * @brief Slot for drawing the direction indicator button
+    *
+    * @param size Size of the screen
+    */
+    void drawIndicatorButton(const QSize &size);
+
+
+    /**
     * @brief Slot for drawing the map distance scale
     *
     * @param size Size of the screen
@@ -399,7 +421,7 @@ signals:
     *
     * @param enabled True if automatic centering is enabled, otherwise false
     */
-    void autoCenteringTriggered(bool enabled);
+//    void autoCenteringTriggered(bool enabled);
 
     /**
     * @brief Signal that indicates when user has cancelled login process
@@ -612,6 +634,7 @@ private:
     QString m_password;                     ///< Placeholder for password
 
     FullScreenButton *m_fullScreenButton;   ///< Instance of the fullscreen toggle button
+    IndicatorButton * m_indicatorButton;    ///< Instance of direction indicator button
 
     QWebView *m_webView;                    ///< Shows facebook login page
 
index 5e3cea8..a57f06d 100644 (file)
@@ -92,4 +92,10 @@ const int ZOOM_BUTTON_PANEL_BUTTON_SPACING = 4; ///< Size of a zoom button spaci
 
 const QString ZOOMPANEL_POSITION = "Zoom_Panel_Position";
 
+// Direction indicator button settings
+//const int DIRECTION_INDICATOR_POSITION_X = 30 + PANEL_PEEK_AMOUNT; ///< Horizontal position of zoom panel
+//const int DIRECTION_INDICATOR_POSITION_Y = 30; ///< Vertical position of zoom panel
+
+//const QString DIRECTION_INDICATOR_BUTTON_POSITION = "Direction_indicator_Position";
+
 #endif // PANELCOMMON_H
index 1309d09..a2d2a95 100644 (file)
@@ -3,6 +3,7 @@
     Copyright (C) 2010  Ixonos Plc. Authors:
 
         Kaj Wallin - kaj.wallin@ixonos.com
+        Katri Kaikkonen - katri.kaikkonen@ixonos.com
 
     Situare is free software; you can redistribute it and/or
     modify it under the terms of the GNU General Public License