const QFont NOKIA_FONT_NORMAL = QFont("Nokia Sans", 18, QFont::Normal); ///< Normal font
const QFont NOKIA_FONT_SMALL = QFont("Nokia Sans", 13, QFont::Normal); ///< Small font
+const QString ZOOMPANEL_POSITION = "ZoomPanelPosition";
#endif // COMMON_H
map/gpslocationitem.cpp \
ui/zoombuttonpanel.cpp \
ui/userinfo.cpp \
- ui/sidepanel.cpp
+ ui/sidepanel.cpp \
+ ui/zoombutton.cpp
HEADERS += ui/mainwindow.h \
map/mapengine.h \
map/mapview.h \
ui/zoombuttonpanel.h \
common.h \
ui/userinfo.h \
- ui/sidepanel.h
+ ui/sidepanel.h \
+ ui/zoombutton.h
QT += network \
webkit
/*******************************************************************************
* DATA MEMBERS
******************************************************************************/
-private:
- QIcon::Mode m_buttonMode; ///< Button mode (Normal, Selected etc...)
- QSize m_buttonSize; ///< Button size
+protected:
+ QIcon::Mode m_buttonMode; ///< Button mode (Normal, Selected etc...)
+ QSize m_buttonSize; ///< Button size
};
#endif // IMAGEBUTTON_H
connect(m_mapView, SIGNAL(viewResized(QSize)),
m_friendsListPanel, SLOT(screenResized(QSize)));
+ connect(m_mapView, SIGNAL(viewResized(QSize)),
+ m_zoomButtonPanel, SLOT(screenResized(QSize)));
+
connect(m_mapView, SIGNAL(viewResizedNewSize(int, int)),
friendsListPanelSidebar, SLOT(reDrawSidebar(int, int)));
}
connect(this, SIGNAL(minZoomLevelReached()),
m_zoomButtonPanel, SLOT(disableZoomOutButton()));
+
+ QSettings settings(DIRECTORY_NAME, FILE_NAME);
+ m_zoomButtonPanel->move(settings.value(ZOOMPANEL_POSITION,
+ QPoint(ZOOM_BUTTON_PANEL_POSITION_X,
+ ZOOM_BUTTON_PANEL_POSITION_Y)).toPoint());
}
void MainWindow::createMenus()
enum Side {LEFT, RIGHT}; ///< Enumerator for panel sideness
-const int SIDEBAR_WIDTH = 23;
-const int SIDEBAR_HEIGHT = 424;
+const int DRAG_INIT_TIME = 1000; ///< How long buttons must be pressed to start drag mode
-const int SLIDINGBAR_WIDTH = 24;
-const int SLIDINGBAR_HEIGHT = 424;
+const int SIDEBAR_WIDTH = 23; ///< Width of the sidebar
+const int SIDEBAR_HEIGHT = 424; ///< Height of the sidebar
+
+const int SLIDINGBAR_WIDTH = 24; ///< Width of the slidingbar
+const int SLIDINGBAR_HEIGHT = 424; ///< Height of the slidingbar
const int PANEL_PEEK_AMOUNT = 25; ///< Amount of pixels shown when panel is closed
const int TOP_CORNER_X = 0; ///< X coordinate for top left corner
const int FRIENDPANEL_CLOSED_X =
- DEFAULT_SCREEN_WIDTH - PANEL_PEEK_AMOUNT - SLIDINGBAR_WIDTH; ///< X location of the friend list panel when closed
+ DEFAULT_SCREEN_WIDTH - PANEL_PEEK_AMOUNT
+ - SLIDINGBAR_WIDTH; ///< X location of the friend list panel when closed
const int FRIENDPANEL_OPENED_X =
- DEFAULT_SCREEN_WIDTH - FRIENDPANEL_WIDTH - SLIDINGBAR_WIDTH; ///< X location of the friend list panel when opened
+ DEFAULT_SCREEN_WIDTH - FRIENDPANEL_WIDTH
+ - SLIDINGBAR_WIDTH; ///< X location of the friend list panel when opened
const int USERPANEL_CLOSED_X =
2 - USERPANEL_WIDTH + PANEL_PEEK_AMOUNT; ///< X location of the user panel when closed
const int USERPANEL_OPENED_X = 0; ///< X location of the user panel when opened
-const int ZOOM_BUTTON_PANEL_POSITION_X = 10 + PANEL_PEEK_AMOUNT; ///< Horizontal position of zoom panel
+const int ZOOM_BUTTON_PANEL_POSITION_X = 10
+ + PANEL_PEEK_AMOUNT; ///< Horizontal position of zoom panel
const int ZOOM_BUTTON_PANEL_POSITION_Y = 10; ///< Vertical position of zoom panel
const int ZOOM_BUTTON_PANEL_BUTTON_SPACING = 4; ///< Size of a zoom button spacing
--- /dev/null
+ /*
+ Situare - A location system for Facebook
+ Copyright (C) 2010 Ixonos Plc. Authors:
+
+ Kaj Wallin - kaj.wallin@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 "zoombutton.h"
+#include <QDebug>
+#include <QTimer>
+#include "panelcommon.h"
+
+ZoomButton::ZoomButton(QWidget *parent, QString normalIconPictureFileName,
+ QString selectedIconPictureFileName)
+ : ImageButton(parent, normalIconPictureFileName, selectedIconPictureFileName)
+{
+ m_dragStartTimer = new QTimer(this);
+ m_dragStartTimer->setSingleShot(true);
+ connect(m_dragStartTimer, SIGNAL(timeout()),
+ this, SLOT(timerExpired()));
+}
+
+void ZoomButton::mousePressEvent(QMouseEvent *event)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if(m_buttonMode != QIcon::Disabled) {
+ QAbstractButton::mousePressEvent(event);
+ setMode(QIcon::Selected);
+ }
+
+ eventPosition = mapToParent(event->pos());
+
+ m_dragStartTimer->start(DRAG_INIT_TIME);
+}
+
+void ZoomButton::mouseReleaseEvent(QMouseEvent *event)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if(m_buttonMode != QIcon::Disabled) {
+ QAbstractButton::mouseReleaseEvent(event);
+ setMode(QIcon::Normal);
+ }
+
+ m_dragStartTimer->stop();
+}
+void ZoomButton::timerExpired()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ setMode(QIcon::Normal);
+ emit startDragMode(true, eventPosition);
+}
--- /dev/null
+ /*
+ Situare - A location system for Facebook
+ Copyright (C) 2010 Ixonos Plc. Authors:
+
+ Kaj Wallin - kaj.wallin@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 "imagebutton.h"
+
+#ifndef ZOOMBUTTON_H
+#define ZOOMBUTTON_H
+
+class QTimer;
+
+/**
+ * @brief A class for Zoom Buttons
+ *
+ * @author Kaj Wallin - kaj.wallin (at) ixonos.com
+ */
+class ZoomButton : public ImageButton
+{
+ Q_OBJECT
+
+public:
+ /**
+ * @brief Constructor
+ *
+ * @param parent Parent
+ * @param normalIconPictureFileName Normal state Icon image file name
+ * @param selectedIconPictureFileName Selected state Icon image file name (optional)
+ */
+ ZoomButton(QWidget *parent = 0, QString normalIconPictureFileName = "",
+ QString selectedIconPictureFileName = "");
+
+/*******************************************************************************
+ * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
+ ******************************************************************************/
+protected:
+ /**
+ * @brief Event handler for mouse press events
+ *
+ * @param event Mouse event
+ */
+ void mousePressEvent(QMouseEvent *event);
+
+ /**
+ * @brief Event handler for mouse release events
+ *
+ * @param event Mouse event
+ */
+ void mouseReleaseEvent(QMouseEvent *event);
+
+/*******************************************************************************
+ * MEMBER FUNCTIONS AND SLOTS
+ ******************************************************************************/
+private slots:
+ /**
+ * @brief Slot to emit signal to zoom button panel to start drag mode after timer timeout
+ */
+ void timerExpired();
+
+/*******************************************************************************
+ * SIGNALS
+ ******************************************************************************/
+signals:
+ /**
+ * @brief Signal for starting drag mode
+ *
+ * @param mode True to start drag mode
+ * @param eventPosition Position of mousePressEvent mapped to parent
+ */
+ void startDragMode(bool mode, QPoint eventPosition);
+
+/*******************************************************************************
+ * DATA MEMBERS
+ ******************************************************************************/
+private:
+ QTimer *m_dragStartTimer; ///< Mouse press timer, initiates drag mode
+ QPoint eventPosition; ///< Position of mousePressEvent
+};
+
+#endif // ZOOMBUTTON_H
Copyright (C) 2010 Ixonos Plc. Authors:
Pekka Nissinen - pekka.nissinen@ixonos.com
+ Kaj Wallin - kaj.wallin@ixonos.com
Situare is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
#include <QDebug>
#include <QPainter>
+#include <QSettings>
#include "zoombuttonpanel.h"
#include "panelcommon.h"
+#include "zoombutton.h"
+#include "common.h"
ZoomButtonPanel::ZoomButtonPanel(QWidget *parent, int x, int y)
: QWidget(parent),
m_zoomInButton(0),
m_zoomOutButton(0),
- m_panelLayout(this),
+ m_isDraggable(false),
m_x(x),
- m_y(y)
+ m_y(y),
+ m_panelLayout(this)
{
qDebug() << __PRETTY_FUNCTION__;
- m_zoomInButton = new ImageButton(this, ":/res/images/zoom_in.png");
- m_zoomOutButton = new ImageButton(this, ":/res/images/zoom_out.png");
+ m_zoomInButton = new ZoomButton(this, ":/res/images/zoom_in.png");
+ m_zoomOutButton = new ZoomButton(this, ":/res/images/zoom_out.png");
m_panelLayout.setMargin(0);
m_panelLayout.setSpacing(0);
QPalette pal = palette();
pal.setColor(QPalette::Background, QColor(0, 0, 0, 128));
setPalette(pal);
+
+ m_eventBlocker = new QWidget(this);
+ m_eventBlocker->setAttribute(Qt::WA_TransparentForMouseEvents, true);
+ m_eventBlocker->resize(size().width(),
+ m_zoomInButton->size().height() * 2 + ZOOM_BUTTON_PANEL_BUTTON_SPACING);
+
+ connect(m_zoomInButton, SIGNAL(startDragMode(bool, QPoint)),
+ this, SLOT(setDraggable(bool, QPoint)));
+ connect(m_zoomOutButton, SIGNAL(startDragMode(bool, QPoint)),
+ this, SLOT(setDraggable(bool, QPoint)));
+
+ m_dragStartTimer = new QTimer(this);
+ m_dragStartTimer->setSingleShot(true);
+ connect(m_dragStartTimer, SIGNAL(timeout()),
+ this, SLOT(timerExpired()));
}
-// BUG: Zoom buttons catch the mouse press event and it doesn't propagate to zoombuttonpanel
-void ZoomButtonPanel::mousePressEvent(QMouseEvent *event)
+void ZoomButtonPanel::mouseMoveEvent(QMouseEvent *event)
{
qDebug() << __PRETTY_FUNCTION__;
- if (event->button() == Qt::LeftButton) {
- m_dragPosition = event->pos();
- qWarning() << "Press:" << event->pos().x() << event->pos().y()
- << "DP:" << m_dragPosition.x() << m_dragPosition.y();
- event->accept();
- m_inButtonMode = m_zoomInButton->mode();
- m_outButtonMode = m_zoomOutButton->mode();
- m_zoomInButton->setMode(QIcon::Disabled);
- m_zoomOutButton->setMode(QIcon::Disabled);
+ 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()
+ - m_eventBlocker->width()){
+ newLocation.rx() = m_screenSize.width() - m_eventBlocker->width();
+ }
+ if (newLocation.y() < 0){
+ newLocation.ry() = 0;
+ }
+ else if (newLocation.y() > m_screenSize.height() - m_eventBlocker->height()) {
+ newLocation.ry() = m_screenSize.height() - m_eventBlocker->height();
+ }
+ move(newLocation);
+ event->accept();
+ }
}
}
-void ZoomButtonPanel::mouseMoveEvent(QMouseEvent *event)
+void ZoomButtonPanel::mousePressEvent(QMouseEvent *event)
{
qDebug() << __PRETTY_FUNCTION__;
- if (event->buttons() & Qt::LeftButton) {
- move(mapToParent(event->pos()) - m_dragPosition);
- qWarning() << "Move:" << event->pos().x() << event->pos().y();
- setAutoFillBackground(true);
+ if (event->button() == Qt::LeftButton) {
+ m_dragPosition = event->pos();
event->accept();
}
+ m_dragStartTimer->start(DRAG_INIT_TIME);
}
void ZoomButtonPanel::mouseReleaseEvent(QMouseEvent *event)
{
- qDebug() << __PRETTY_FUNCTION__;
-
- setAutoFillBackground(false);
- event->accept();
- m_zoomInButton->setMode(m_inButtonMode);
- m_zoomOutButton->setMode(m_outButtonMode);
+ Q_UNUSED(event);
+ setDraggable(false);
+ QSettings settings(DIRECTORY_NAME, FILE_NAME);
+ settings.setValue(ZOOMPANEL_POSITION, pos());
+ releaseMouse();
}
void ZoomButtonPanel::disableZoomInButton()
m_zoomInButton->setMode(QIcon::Normal);
m_zoomOutButton->setMode(QIcon::Normal);
}
+
+void ZoomButtonPanel::setDraggable(bool mode, QPoint eventPosition)
+{
+ if(mode == true) {
+ m_eventBlocker->setAttribute(Qt::WA_TransparentForMouseEvents, false);
+ m_isDraggable = mode;
+ setAutoFillBackground(true);
+ m_zoomInMode = m_zoomInButton->mode();
+ m_zoomOutMode = m_zoomOutButton->mode();
+ m_zoomInButton->setMode(QIcon::Disabled);
+ m_zoomOutButton->setMode(QIcon::Disabled);
+ grabMouse();
+ m_dragPosition = eventPosition;
+ }
+ else {
+ m_eventBlocker->setAttribute(Qt::WA_TransparentForMouseEvents, true);
+ m_isDraggable = mode;
+ setAutoFillBackground(false);
+ m_zoomInButton->setMode(m_zoomInMode);
+ m_zoomOutButton->setMode(m_zoomOutMode);
+ releaseMouse();
+ }
+}
+
+void ZoomButtonPanel::screenResized(const QSize &size)
+{
+ m_screenSize = size;
+}
+
+void ZoomButtonPanel::timerExpired()
+{
+ setDraggable(true, m_dragPosition);
+}
Copyright (C) 2010 Ixonos Plc. Authors:
Pekka Nissinen - pekka.nissinen@ixonos.com
+ Kaj Wallin - kaj.wallin@ixonos.com
Situare is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
* @brief Panel for zoom buttons
*
* @author Pekka Nissinen - pekka.nissinen (at) ixonos.com
+ * @author Kaj Wallin - kaj.wallin (at) ixonos.com
*/
class ZoomButtonPanel : public QWidget
{
ZoomButtonPanel(QWidget *parent = 0, int x = 0, int y = 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:
*/
void resetButtons();
-protected:
- void mouseMoveEvent(QMouseEvent *event);
- void mousePressEvent(QMouseEvent *event);
- void mouseReleaseEvent(QMouseEvent *event);
+ /**
+ * @brief Toggle zoom panel draggability
+ */
+ void setDraggable(bool mode, QPoint eventPosition = QPoint(0,0));
+ void screenResized(const QSize &size);
+
+private slots:
+ /**
+ * @brief Slot to emit signal to zoom button panel to start drag mode after timer timeout
+ */
+ void timerExpired();
/*******************************************************************************
* DATA MEMBERS
******************************************************************************/
public:
- ImageButton *m_zoomInButton; ///< Button for zoom in
- ImageButton *m_zoomOutButton; ///< Button for zoom out
+ ImageButton *m_zoomInButton; ///< Button for zoom in
+ ImageButton *m_zoomOutButton; ///< Button for zoom out
private:
- QGridLayout m_panelLayout; ///< Panel layout
- QPoint m_dragPosition;
- QIcon::Mode m_inButtonMode;
- QIcon::Mode m_outButtonMode;
- int m_x; ///< Panel x coordinate
- int m_y; ///< Panel y coordinate
+ bool m_isDraggable; ///< Boolean for tracking the draggability state
+
+ int m_x; ///< Panel x coordinate
+ int m_y; ///< Panel y coordinate
+
+ QGridLayout m_panelLayout; ///< Panel layout
+
+ QPoint m_dragPosition; ///< Location from where the widget is grabbed
+
+ QIcon::Mode m_zoomInMode; ///< Store for zoom in button mode before dragging
+ QIcon::Mode m_zoomOutMode; ///< Store for zoom out button mode before dragging
+
+ QSize m_screenSize; ///< Store for the screen size
+
+ QTimer *m_dragStartTimer; ///< Timer to init draggability of the zoom panel
+
+ QWidget *m_eventBlocker; ///< Overlaying widget that catches the mouse events
};
#endif // ZOOMBUTTONPANEL_H