Merge branch 'remove_list_view'
[situare] / src / ui / mainwindow.cpp
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5       Henri Lampela - henri.lampela@ixonos.com
6       Kaj Wallin - kaj.wallin@ixonos.com
7       Jussi Laitinen jussi.laitinen@ixonos.com
8
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.
12
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.
17
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,
21    USA.
22 */
23
24 #include <QtGui>
25 #include "mainwindow.h"
26 #include "mapviewscreen.h"
27 #include "settingsdialog.h"
28 #include "facebookservice/facebookauthentication.h"
29 #include "situareservice/situareservice.h"
30
31 MainWindow::MainWindow(QWidget *parent)
32     : QMainWindow(parent)
33 {
34     qDebug() << __PRETTY_FUNCTION__;
35
36     m_mapViewScreen = new MapViewScreen(this);
37     setCentralWidget(m_mapViewScreen);
38     createMenus();
39     setWindowTitle(tr("Situare"));
40     hide();
41
42     m_locationDialog = new UpdateLocationDialog(this);
43
44     connect(this, SIGNAL(reverseGeoReady(QString)),
45             m_locationDialog, SLOT(setAddress(QString)));
46     connect(m_locationDialog, SIGNAL(statusUpdate(QString,bool)), this,
47             SIGNAL(statusUpdate(QString,bool)));
48
49     connect(this, SIGNAL(userLocationReady(User*)),
50             m_mapViewScreen, SIGNAL(userLocationReady(User*)));
51     connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
52             m_mapViewScreen, SIGNAL(friendsLocationsReady(QList<User*>&)));
53
54
55     this->toggleProgressIndicator(true);
56 }
57
58 void MainWindow::toggleProgressIndicator(bool value)
59 {
60     qDebug() << __PRETTY_FUNCTION__;
61 #ifdef Q_WS_MAEMO_5
62     setAttribute(Qt::WA_Maemo5ShowProgressIndicator, value);
63 #else
64     Q_UNUSED(value);
65 #endif // Q_WS_MAEMO_5
66 }
67
68 void MainWindow::createMenus()
69 {
70     qDebug() << __PRETTY_FUNCTION__;
71     m_toSettingsAct = new QAction(tr("Settings"), this);
72     m_toSettingsAct->setObjectName(tr("Settings"));
73     connect(m_toSettingsAct, SIGNAL(triggered()), this, SLOT(openSettingsDialog()));
74     m_viewMenu = menuBar()->addMenu(tr("Main"));
75
76     m_viewMenu->addAction(m_toSettingsAct);
77     m_viewMenu->setObjectName(tr("Menu"));
78 }
79
80 void MainWindow::openLocationUpdateDialog()
81 {
82     qDebug() << __PRETTY_FUNCTION__;
83
84     emit requestReverseGeo();
85     m_locationDialog->exec();
86 }
87
88 void MainWindow::openSettingsDialog()
89 {
90     qDebug() << __PRETTY_FUNCTION__;
91     SettingsDialog *dialog = new SettingsDialog(this);
92     dialog->show();
93 }