#include "mainwindow.h"
#include "listviewscreen.h"
#include "mapviewscreen.h"
+#include "settingsdialog.h"
#include "facebookservice/facebookauthentication.h"
#include "situareservice/situareservice.h"
: QMainWindow(parent)
{
qDebug() << __PRETTY_FUNCTION__;
- m_loggedIn = false;
+
createViews();
setCentralWidget(m_situareViews);
createMenus();
setWindowTitle(tr("List view"));
this->hide();
- m_facebookAuthenticator = new FacebookAuthentication(this);
- connect(m_facebookAuthenticator, SIGNAL(credentialsReady()), this, SLOT(loginOK()));
- connect(m_facebookAuthenticator, SIGNAL(userExit()), this, SLOT(loginScreenClosed()));
- m_facebookAuthenticator->start();
-
- m_networkManager = new QNetworkAccessManager;
- m_situareService = new SituareService(this,m_networkManager);
+ m_locationDialog = new UpdateLocationDialog(this);
+ connect(m_listViewScreen->m_personalInfo,SIGNAL(launchMessageUpdate()),
+ this,SLOT(openLocationUpdateDialog()));
+
+ connect(this, SIGNAL(reverseGeoReady(QString)), m_locationDialog, SLOT(setAddress(QString)));
+ connect(m_locationDialog, SIGNAL(statusUpdate(QString,bool)), this,
+ SIGNAL(statusUpdate(QString,bool)));
+ connect(this, SIGNAL(userLocationReady(User*)),
+ m_mapViewScreen, SLOT(userLocationReady(User*)));
+ connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
+ m_mapViewScreen, SLOT(friendsLocationsReady(QList<User*>&)));
}
MainWindow::~MainWindow()
qDebug() << __PRETTY_FUNCTION__;
delete m_toListViewAct;
delete m_toMapViewAct;
+ delete m_toSettingsAct;
delete m_situareViews;
}
m_toMapViewAct = new QAction(tr("Map"), this);
m_toMapViewAct->setObjectName(tr("Map"));
connect(m_toMapViewAct, SIGNAL(triggered()), this, SLOT(toMapView()));
+ m_toSettingsAct = new QAction(tr("Settings"), this);
+ m_toSettingsAct->setObjectName(tr("Settings"));
+ connect(m_toSettingsAct, SIGNAL(triggered()), this, SLOT(openSettingsDialog()));
m_viewMenu = menuBar()->addMenu(tr("View"));
m_viewMenu->addAction(m_toListViewAct);
m_viewMenu->addAction(m_toMapViewAct);
+ m_viewMenu->addAction(m_toSettingsAct);
m_viewMenu->setObjectName(tr("View Menu"));
}
void MainWindow::createViews()
{
qDebug() << __PRETTY_FUNCTION__;
+ m_listViewScreen = new ListViewScreen(this);
+ m_mapViewScreen = new MapViewScreen(this);
+
m_situareViews = new QStackedWidget;
- m_situareViews->addWidget(new ListViewScreen);
- m_situareViews->addWidget(new MapViewScreen);
+ m_situareViews->addWidget(m_listViewScreen);
+ m_situareViews->addWidget(m_mapViewScreen);
}
void MainWindow::toListView()
}
}
-void MainWindow::loginScreenClosed()
+void MainWindow::openLocationUpdateDialog()
{
- qDebug() << __PRETTY_FUNCTION__ << m_loggedIn;
- if (m_loggedIn) {
- this->show();
- return;
- }
- else {
- this->close();
- }
+ qDebug() << __PRETTY_FUNCTION__;
+
+ emit requestReverseGeo();
+ m_locationDialog->exec();
}
-void MainWindow::loginOK()
+void MainWindow::openSettingsDialog()
{
- qDebug() << __PRETTY_FUNCTION__ << m_loggedIn;
- m_loggedIn = true;
- m_facebookAuthenticator->close();
+ qDebug() << __PRETTY_FUNCTION__;
+ SettingsDialog *dialog = new SettingsDialog(this);
+ dialog->show();
}
+