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)));
63 connect(m_mapViewScreen, SIGNAL(mapLocationChanged()), this, SLOT(mapLocationChanged()));
65 this->toggleProgressIndicator(true);
68 void MainWindow::toggleProgressIndicator(bool value)
70 qDebug() << __PRETTY_FUNCTION__;
72 setAttribute(Qt::WA_Maemo5ShowProgressIndicator, value);
75 #endif // Q_WS_MAEMO_5
78 void MainWindow::createMenus()
80 qDebug() << __PRETTY_FUNCTION__;
82 m_toSettingsAct = new QAction(tr("Settings"), this);
83 m_toSettingsAct->setObjectName(tr("Settings"));
84 connect(m_toSettingsAct, SIGNAL(triggered()), this, SLOT(openSettingsDialog()));
85 m_gpsToggleAct = new QAction(tr("GPS"), this);
86 m_gpsToggleAct->setCheckable(true);
87 m_gpsToggleAct->setChecked(true);
88 connect(m_gpsToggleAct, SIGNAL(toggled(bool)), this, SLOT(gpsActionToggled(bool)));
89 m_autoCenteringAct = new QAction(tr("Auto centering"), this);
90 m_autoCenteringAct->setCheckable(true);
91 m_autoCenteringAct->setChecked(true);
92 connect(m_autoCenteringAct, SIGNAL(toggled(bool)), this, SLOT(autoCenteringToggled(bool)));
94 m_viewMenu = menuBar()->addMenu(tr("Main"));
96 m_viewMenu->addAction(m_toSettingsAct);
97 m_viewMenu->addAction(m_gpsToggleAct);
98 m_viewMenu->addAction(m_autoCenteringAct);
99 m_viewMenu->setObjectName(tr("Menu"));
102 void MainWindow::openLocationUpdateDialog()
104 qDebug() << __PRETTY_FUNCTION__;
106 emit requestReverseGeo();
107 m_locationDialog->exec();
110 void MainWindow::openSettingsDialog()
112 qDebug() << __PRETTY_FUNCTION__;
113 SettingsDialog *dialog = new SettingsDialog(this);
117 void MainWindow::gpsActionToggled(bool checked)
119 qDebug() << __PRETTY_FUNCTION__;
122 emit enableGPS(true);
123 showMaemoInformationBox(tr("GPS enabled"));
124 m_autoCenteringAct->setVisible(true);
127 emit enableGPS(false);
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::mapLocationChanged()
150 qDebug() << __PRETTY_FUNCTION__;
152 m_autoCenteringAct->setChecked(false);
155 void MainWindow::autoCenteringToggled(bool checked)
157 qDebug() << __PRETTY_FUNCTION__ << " " << checked;
160 emit enableAutoCentering(true);
161 showMaemoInformationBox(tr("Auto centering enabled"));
164 emit enableAutoCentering(false);
165 showMaemoInformationBox(tr("Auto centering disabled"));
169 void MainWindow::showMaemoInformationBox(const QString &message)
171 qDebug() << __PRETTY_FUNCTION__;
174 QMaemo5InformationBox::information(this, message, QMaemo5InformationBox::DefaultTimeout);