ui/zoombuttonpanel.h \
common.h \
ui/userinfo.h \
- ui/sidepanel.h
+ ui/sidepanel.h \
+ ui/zoombutton.h
QT += network \
webkit
-
DEFINES += QT_NO_DEBUG_OUTPUT
maemo5 | simulator {
this, SIGNAL(findFriend(QPointF)));
connect(m_mapView, SIGNAL(viewResized(QSize)),
- m_friendsListPanel, SLOT(screenResized(QSize)));
++ m_zoomButtonPanel, SLOT(screenResized(QSize)));
+
+ connect(m_mapView, SIGNAL(viewResized(QSize)),
- m_zoomButtonPanel, SLOT(screenResized(QSize)));
+ m_friendsListPanel, SLOT(screenResized(QSize)));
+
+ connect(this, SIGNAL(locationItemClicked(QList<QString>)),
+ m_friendsListPanel, SLOT(showFriendsInList(QList<QString>)));
connect(m_mapView, SIGNAL(viewResizedNewSize(int, int)),
- friendsListPanelSidebar, SLOT(reDrawSidebar(int, int)));
+ m_friendsListPanelSidebar, SLOT(reDrawSidebar(int, int)));
}
void MainWindow::buildManualLocationCrosshair()
void MainWindow::buildOsmLicense()
{
-- qWarning() << __PRETTY_FUNCTION__;
++ qDebug() << __PRETTY_FUNCTION__;
m_osmLicense = new QLabel(this);
m_osmLicense->setAttribute(Qt::WA_TranslucentBackground, true);
ZoomButtonPanel::ZoomButtonPanel(QWidget *parent, int x, int y)
: QWidget(parent),
- m_panelLayout(this),
m_zoomInButton(0),
- m_zoomOutButton(0)
+ m_zoomOutButton(0),
+ m_isDraggable(false),
- m_x(x),
- m_y(y),
+ m_panelLayout(this)
{
qDebug() << __PRETTY_FUNCTION__;
m_panelLayout.addWidget(m_zoomInButton, 0, 0);
m_panelLayout.addWidget(m_zoomOutButton, 1, 0);
- move(m_x, m_y);
+ move(x, y);
+
+ 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()));
+}
+
+void ZoomButtonPanel::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()
+ - 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::mousePressEvent(QMouseEvent *event)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if (event->button() == Qt::LeftButton) {
+ m_dragPosition = event->pos();
+ event->accept();
+ }
+ m_dragStartTimer->start(DRAG_INIT_TIME);
+}
+
+void ZoomButtonPanel::mouseReleaseEvent(QMouseEvent *event)
+{
+ Q_UNUSED(event);
+ setDraggable(false);
+ QSettings settings(DIRECTORY_NAME, FILE_NAME);
+ settings.setValue(ZOOMPANEL_POSITION, pos());
+ releaseMouse();
}
+ const ImageButton* ZoomButtonPanel::zoomInButton()
+ {
+ qDebug() << __PRETTY_FUNCTION__;
+
+ return m_zoomInButton;
+ }
+
+ const ImageButton* ZoomButtonPanel::zoomOutButton()
+ {
+ qDebug() << __PRETTY_FUNCTION__;
+
+ return m_zoomOutButton;
+ }
+
void ZoomButtonPanel::disableZoomInButton()
{
qDebug() << __PRETTY_FUNCTION__;
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:
+ /**
+ * @brief Getter for the zoom in button
+ *
+ * @return Pointer to the zoomInButton
+ */
+ const ImageButton* zoomInButton();
+
+ /**
+ * @brief Getter for the zoom out button
+ *
+ * @return Pointer to the zoomOutButton
+ */
+ const ImageButton* zoomOutButton();
+
public slots:
/**
- * @brief Disables the Zoom In button
+ * @brief Disables the zoom in button
*/
void disableZoomInButton();
/*******************************************************************************
* DATA MEMBERS
******************************************************************************/
-private:
- QGridLayout m_panelLayout; ///< Panel layout
+public:
ImageButton *m_zoomInButton; ///< Button for zoom in
ImageButton *m_zoomOutButton; ///< Button for zoom out
+
+private:
+ 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