#include "settingsdialog.h"
#include "facebookservice/facebookauthentication.h"
+#include <QtGui/QX11Info>
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+
MainWindow::MainWindow(QWidget *parent)
: QMainWindow(parent),
m_email(),
connect(this, SIGNAL(positionReceived(QPointF)),
m_mapViewScreen, SLOT(positionReceived(QPointF)));
+ connect(this, SIGNAL(zoomInKeyPressed()),
+ m_mapViewScreen, SIGNAL(zoomInKeyPressed()));
+ connect(this, SIGNAL(zoomOutKeyPressed()),
+ m_mapViewScreen, SIGNAL(zoomOutKeyPressed()));
+
this->toggleProgressIndicator(true);
+
+ grabZoomKeys(true);
}
MainWindow::~MainWindow()
{
qDebug() << __PRETTY_FUNCTION__;
+ grabZoomKeys(false);
+
if(m_webView)
delete m_webView;
}
}
}
}
+
+void MainWindow::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);
+#endif // Q_WS_MAEMO_5
+}
+
+void MainWindow::keyPressEvent(QKeyEvent* event)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ switch (event->key()) {
+ case Qt::Key_F7:
+ event->accept();
+ emit zoomInKeyPressed();
+ break;
+
+ case Qt::Key_F8:
+ event->accept();
+ emit zoomOutKeyPressed();
+ break;
+ }
+ QWidget::keyPressEvent(event);
+}
~MainWindow();
/*******************************************************************************
+ * BASE CLASS INHERITED AND REIMPLEMENTED MEMBER FUNCTIONS
+ ******************************************************************************/
+private:
+ /**
+ * @brief HW increase and decrease key presses are grabbed and used for zooming the map.
+ */
+ void keyPressEvent(QKeyEvent* event);
+
+/*******************************************************************************
* MEMBER FUNCTIONS AND SLOTS
******************************************************************************/
public slots:
*/
void createMenus();
- /**
+ /**
+ * @brief Grab or release HW increase and decrease buttons.
+ *
+ * @param grab Use true for grabbing and false for releasing the keys
+ */
+ void grabZoomKeys(bool grab);
+
+ /**
* @brief Show Maemo information box with message.
*
* @brief message information message
******************************************************************************/
signals:
/**
+ * @brief Signal that indicates when user has cancelled login process
+ *
+ */
+ void cancelLoginProcess();
+
+ /**
* @brief Signal for map auto centering
*
* @param enabled true if map should auto center to gps location
void userLocationReady(User *user);
/**
- * @brief Signal that indicates when user has cancelled login process
- *
- */
- void cancelLoginProcess();
+ * @brief Signal for HW increase button
+ */
+ void zoomInKeyPressed();
+
+ /**
+ * @brief Signal for HW decrease button
+ */
+ void zoomOutKeyPressed();
/*******************************************************************************
* DATA MEMBERS
connect(mapView, SIGNAL(viewZoomFinished()),
mapEngine, SLOT(viewZoomFinished()));
+ connect(this, SIGNAL(zoomInKeyPressed()),
+ mapEngine, SLOT(zoomIn()));
+ connect(this, SIGNAL(zoomOutKeyPressed()),
+ mapEngine, SLOT(zoomOut()));
+
connect(mapView, SIGNAL(viewResizedNewSize(int,int)),
this, SLOT(drawOsmLicense(int, int)));
******************************************************************************/
signals:
/**
- * @brief Signal when user location is fetched
- *
- * @param user User data
- */
- void userLocationReady(User *user);
-
- /**
* @brief Signal when friend list locations are fetched
*
* Forwarded to map engine and friends list panel
*/
void friendsLocationsReady(QList<User *> &friendsList);
+ /**
+ * @brief Signal when user location is fetched
+ *
+ * @param user User data
+ */
+ void userLocationReady(User *user);
+
+ /**
+ * @brief Signal for HW increase button
+ */
+ void zoomInKeyPressed();
+
+ /**
+ * @brief Signal for HW decrease button
+ */
+ void zoomOutKeyPressed();
+
/*******************************************************************************
* DATA MEMBERS
******************************************************************************/