2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Henri Lampela - henri.lampela@ixonos.com
6 Kaj Wallin - kaj.wallin@ixonos.com
7 Jussi Laitinen jussi.laitinen@ixonos.com
9 Situare is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 version 2 as published by the Free Software Foundation.
13 Situare is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with Situare; if not, write to the Free Software
20 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
27 #include <QtMaemo5/QMaemo5InformationBox>
28 #endif // Q_WS_MAEMO_5
30 #include "mainwindow.h"
31 #include "mapviewscreen.h"
32 #include "settingsdialog.h"
33 #include "facebookservice/facebookauthentication.h"
34 #include "situareservice/situareservice.h"
36 MainWindow::MainWindow(QWidget *parent)
39 qDebug() << __PRETTY_FUNCTION__;
41 m_mapViewScreen = new MapViewScreen(this);
42 setCentralWidget(m_mapViewScreen);
44 setWindowTitle(tr("Situare"));
47 m_locationDialog = new UpdateLocationDialog(this);
49 connect(this, SIGNAL(reverseGeoReady(QString)),
50 m_locationDialog, SLOT(setAddress(QString)));
51 connect(m_locationDialog, SIGNAL(statusUpdate(QString,bool)), this,
52 SIGNAL(statusUpdate(QString,bool)));
54 connect(this, SIGNAL(userLocationReady(User*)),
55 m_mapViewScreen, SIGNAL(userLocationReady(User*)));
56 connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
57 m_mapViewScreen, SIGNAL(friendsLocationsReady(QList<User*>&)));
59 connect(this, SIGNAL(enableAutoCentering(bool)),
60 m_mapViewScreen, SLOT(enableAutoCentering(bool)));
61 connect(this, SIGNAL(positionReceived(QPointF)),
62 m_mapViewScreen, SLOT(positionReceived(QPointF)));
64 this->toggleProgressIndicator(true);
67 void MainWindow::toggleProgressIndicator(bool value)
69 qDebug() << __PRETTY_FUNCTION__;
71 setAttribute(Qt::WA_Maemo5ShowProgressIndicator, value);
74 #endif // Q_WS_MAEMO_5
77 void MainWindow::createMenus()
79 qDebug() << __PRETTY_FUNCTION__;
80 m_toSettingsAct = new QAction(tr("Settings"), this);
81 m_toSettingsAct->setObjectName(tr("Settings"));
82 connect(m_toSettingsAct, SIGNAL(triggered()), this, SLOT(openSettingsDialog()));
83 m_gpsToggleAct = new QAction(tr("GPS enabled"), this);
84 m_gpsToggleAct->setCheckable(true);
85 m_gpsToggleAct->setChecked(true);
86 connect(m_gpsToggleAct, SIGNAL(toggled(bool)), this, SLOT(gpsActionToggled(bool)));
87 m_autoCenteringAct = new QAction(tr("Auto centering enabled"), this);
88 m_autoCenteringAct->setCheckable(true);
89 m_autoCenteringAct->setChecked(true);
90 connect(m_autoCenteringAct, SIGNAL(toggled(bool)), this, SLOT(autoCenteringToggled(bool)));
92 m_viewMenu = menuBar()->addMenu(tr("Main"));
94 m_viewMenu->addAction(m_toSettingsAct);
95 m_viewMenu->addAction(m_gpsToggleAct);
96 m_viewMenu->addAction(m_autoCenteringAct);
97 m_viewMenu->setObjectName(tr("Menu"));
100 void MainWindow::openLocationUpdateDialog()
102 qDebug() << __PRETTY_FUNCTION__;
104 emit requestReverseGeo();
105 m_locationDialog->exec();
108 void MainWindow::openSettingsDialog()
110 qDebug() << __PRETTY_FUNCTION__;
111 SettingsDialog *dialog = new SettingsDialog(this);
115 void MainWindow::gpsActionToggled(bool checked)
117 qDebug() << __PRETTY_FUNCTION__;
120 emit enableGPS(true);
121 m_gpsToggleAct->setText(tr("GPS enabled"));
122 showMaemoInformationBox(tr("GPS enabled"));
123 m_autoCenteringAct->setVisible(true);
126 emit enableGPS(false);
127 m_gpsToggleAct->setText(tr("GPS disabled"));
128 showMaemoInformationBox(tr("GPS disabled"));
129 m_autoCenteringAct->setVisible(false);
134 void MainWindow::gpsTimeout()
136 qDebug() << __PRETTY_FUNCTION__;
138 showMaemoInformationBox(tr("GPS timeout"));
141 void MainWindow::gpsError(const QString &message)
143 qDebug() << __PRETTY_FUNCTION__;
145 showMaemoInformationBox(message);
148 void MainWindow::autoCenteringToggled(bool checked)
150 qDebug() << __PRETTY_FUNCTION__ << " " << checked;
153 emit enableAutoCentering(true);
154 m_autoCenteringAct->setText(tr("Auto centering enabled"));
155 showMaemoInformationBox(tr("Auto centering enabled"));
158 emit enableAutoCentering(false);
159 m_autoCenteringAct->setText(tr("Auto centering disabled"));
160 showMaemoInformationBox(tr("Auto centering disabled"));
164 void MainWindow::showMaemoInformationBox(const QString &message)
166 qDebug() << __PRETTY_FUNCTION__;
169 QMaemo5InformationBox::information(this, message, QMaemo5InformationBox::DefaultTimeout);