*/
#include <QtGui>
+
+#ifdef Q_WS_MAEMO_5
+#include <QtMaemo5/QMaemo5InformationBox>
+#endif // Q_WS_MAEMO_5
+
#include "mainwindow.h"
#include "listviewscreen.h"
#include "mapviewscreen.h"
connect(m_listViewScreen, SIGNAL(updateFriendsData()),
this, SIGNAL(refreshUserData()));
+ connect(this, SIGNAL(enableAutoCentering(bool)),
+ m_mapViewScreen, SLOT(enableAutoCentering(bool)));
+ connect(this, SIGNAL(positionReceived(QPointF)),
+ m_mapViewScreen, SLOT(positionReceived(QPointF)));
+
this->toggleProgressIndicator(true);
+
+ //Debug, use settings instead
+ autoCenteringToggled(true);
}
MainWindow::~MainWindow()
m_toSettingsAct = new QAction(tr("Settings"), this);
m_toSettingsAct->setObjectName(tr("Settings"));
connect(m_toSettingsAct, SIGNAL(triggered()), this, SLOT(openSettingsDialog()));
+ m_gpsToggleAct = new QAction(tr("GPS enabled"), this);
+ m_gpsToggleAct->setCheckable(true);
+ m_gpsToggleAct->setChecked(true);
+ connect(m_gpsToggleAct, SIGNAL(toggled(bool)), this, SLOT(gpsActionToggled(bool)));
+ m_autoCenteringAct = new QAction(tr("Auto centering enabled"), this);
+ m_autoCenteringAct->setCheckable(true);
+ m_autoCenteringAct->setChecked(true);
+ connect(m_autoCenteringAct, SIGNAL(toggled(bool)), this, SLOT(autoCenteringToggled(bool)));
m_viewMenu = menuBar()->addMenu(tr("View"));
m_viewMenu->addAction(m_toListViewAct);
m_viewMenu->addAction(m_toMapViewAct);
m_viewMenu->addAction(m_toSettingsAct);
+ m_viewMenu->addAction(m_gpsToggleAct);
+ m_viewMenu->addAction(m_autoCenteringAct);
m_viewMenu->setObjectName(tr("View Menu"));
}
SettingsDialog *dialog = new SettingsDialog(this);
dialog->show();
}
+
+void MainWindow::gpsActionToggled(bool checked)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ if (checked) {
+ emit enableGPS(true);
+ m_gpsToggleAct->setText(tr("GPS enabled"));
+ showMaemoInformationBox(tr("GPS enabled"));
+ m_autoCenteringAct->setEnabled(true);
+ }
+ else {
+ emit enableGPS(false);
+ m_gpsToggleAct->setText(tr("GPS disabled"));
+ showMaemoInformationBox(tr("GPS disabled"));
+ m_autoCenteringAct->setEnabled(false);
+ }
+}
+
+void MainWindow::gpsTimeout()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ showMaemoInformationBox(tr("GPS timeout"));
+}
+
+void MainWindow::gpsError(const QString &message)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+ showMaemoInformationBox(message);
+}
+
+void MainWindow::autoCenteringToggled(bool checked)
+{
+ qDebug() << __PRETTY_FUNCTION__ << " " << checked;
+
+ if (checked) {
+ emit enableAutoCentering(true);
+ m_autoCenteringAct->setText(tr("Auto centering enabled"));
+ showMaemoInformationBox(tr("Auto centering enabled"));
+ }
+ else {
+ emit enableAutoCentering(false);
+ m_autoCenteringAct->setText(tr("Auto centering disabled"));
+ showMaemoInformationBox(tr("Auto centering disabled"));
+ }
+}
+
+void MainWindow::showMaemoInformationBox(const QString &message)
+{
+ qDebug() << __PRETTY_FUNCTION__;
+
+#ifdef Q_WS_MAEMO_5
+ QMaemo5InformationBox::information(this, message,
+ QMaemo5InformationBox::DefaultTimeout);
+#endif // Q_WS_MAEMO_5
+}