#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_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)));
+
+ m_networkManager = new QNetworkAccessManager;
+ m_situareService = new SituareService(this,m_networkManager);
}
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"));
}
break;
}
}
+
void MainWindow::openLocationUpdateDialog()
{
qDebug() << __PRETTY_FUNCTION__;
emit requestReverseGeo();
m_locationDialog->exec();
}
+
+void MainWindow::openSettingsDialog()
+{
+ qDebug() << __PRETTY_FUNCTION__;
+ SettingsDialog *dialog = new SettingsDialog(this);
+ dialog->show();
+}
+
+void MainWindow::loginScreenClosed()
+{
+ qDebug() << __PRETTY_FUNCTION__ << m_loggedIn;
+ if (m_loggedIn) {
+ this->show();
+ return;
+ }
+ else {
+ this->close();
+ }
+}
+
+void MainWindow::loginOK()
+{
+ qDebug() << __PRETTY_FUNCTION__ << m_loggedIn;
+ m_loggedIn = true;
+ m_facebookAuthenticator->close();
+}
******************************************************************************/
public slots:
/**
+ * @brief Public slot, which open settings dialog
+ */
+ void openSettingsDialog();
+
+ /**
* @brief Public slot, which initiates toListViewAct action to switch view
*/
void toListView();
+
/**
* @brief Public slot, which initiates toMapViewAct action to switch view
*/
/**
* @brief Method used to switch active view.
*
- * @paraDaily scrum 2010-03-26m nextIndex 0 for listview, 1 for mapview
+ * @param nextIndex 0 for listview, 1 for mapview
*/
void switchView(int);
private slots:
+ /**
+ * @brief Slot to change value of m_loggedIn to true
+ */
+ void loginOK();
+
+ /**
+ * @brief Slot to check login status and exits if necessary
+ */
+ void loginScreenClosed();
/**
* @brief Private slot, which starts UpdateLocationDialog
ListViewScreen *m_listViewScreen;
UpdateLocationDialog *m_locationDialog; ///< Message dialog
MapViewScreen *m_mapViewScreen;
+ FacebookAuthentication *m_facebookAuthenticator; ///< Instance for facebook authenticator
+ QNetworkAccessManager *m_networkManager; ///< NetworkManager that is passed on to SituareService
+ SituareService *m_situareService; ///< Instance of the situare server communication service
+ bool m_loggedIn; ///< Boolean value to indicate whether login has been successfull or not
QStackedWidget *m_situareViews; ///< Stacked widget that hold both view widgets
QAction *m_toListViewAct; ///< Action to trigger switch to list view
QAction *m_toMapViewAct; ///< Action to trigger switch to map view
+ QAction *m_toSettingsAct; ///< Action to trigger switch to settings dialog
QMenu *m_viewMenu; ///< Object that hold the view menu items
};