Prepared for merge
authorKaj Wallin <kaj.wallin@ixonos.com>
Mon, 19 Apr 2010 05:58:57 +0000 (08:58 +0300)
committerKaj Wallin <kaj.wallin@ixonos.com>
Mon, 19 Apr 2010 05:58:57 +0000 (08:58 +0300)
src/ui/mainwindow.cpp
src/ui/mainwindow.h
tests/ui/mainwindow/mainwindow_test.pro

index 073639e..39076b7 100644 (file)
@@ -24,6 +24,7 @@
 #include "mainwindow.h"
 #include "listviewscreen.h"
 #include "mapviewscreen.h"
+//#include "facebookservice/facebookauthentication.h"
 
 MainWindow::MainWindow(QWidget *parent)
     : QMainWindow(parent)
@@ -61,16 +62,13 @@ void MainWindow::createMenus()
     viewMenu->addAction(toListViewAct);
     viewMenu->addAction(toMapViewAct);
     viewMenu->setObjectName(tr("View Menu"));
-//    QList<QAction*> actionit = viewMenu->actions();
-//    qDebug() << "AKTIONIT" << actionit;
-
 /*
-    testClose1Act = new QAction(tr("login fail"),this);
-    connect(testClose1Act, SIGNAL(triggered()), this, SLOT(testClose1()));
-    testClose2Act = new QAction(tr("login ok"), this);
-    connect(testClose2Act, SIGNAL(triggered()), this, SLOT(testClose2()));
-    viewMenu->addAction(testClose1Act);
-    viewMenu->addAction(testClose2Act);
+    FBAuth = new FacebookAuthentication(this);
+    FBAuth->show();
+    FBAuth->start();
+
+    connect(FBAuth, SIGNAL(credentialsReady()), this, SLOT(loginOK()));
+    connect(FBAuth, SIGNAL(userExit()), this, SLOT(loginScreenClosed()));
 */
 }
 
@@ -115,18 +113,20 @@ void MainWindow::switchView(int nextIndex)
     }
 }
 
-/*
-void MainWindow::testClose1()
+void MainWindow::loginScreenClosed()
 {
-    qDebug() << tr("Login window closed with FAIL");
-    this->loggedIn = false;
-    emit testLoginClosed();
+    qDebug() << __PRETTY_FUNCTION__ << loggedIn;
+    if (loggedIn) {
+        //this->show();
+        return;
+    }
+    else {
+        this->close();
+    }
 }
 
-void MainWindow::testClose2()
+void MainWindow::loginOK()
 {
-    qDebug() << tr("Login window closed with OK");
-    this->loggedIn = true;
-    emit testLoginClosed();
+    qDebug() << __PRETTY_FUNCTION__ << loggedIn;
+    loggedIn = true;
 }
-*/
index 5f55c0c..bdb50f5 100644 (file)
@@ -27,6 +27,7 @@
 #include <QtGui/QMainWindow>
 #include <QWidget>
 #include <QDebug>
+//#include "facebookservice/facebookauthentication.h"
 
 class QLabel;
 class QStackedWidget;
@@ -86,11 +87,6 @@ private:
     */
     QAction *toMapViewAct;
 
-/*
-    QAction *testClose1Act;
-    QAction *testClose2Act;
-*/
-
     /**
     * @brief Method used to switch active view.
     *
@@ -112,14 +108,16 @@ public slots:
     * @fn toMapView
     */
     void toMapView();
-/*
-    void testClose1();
-    void testClose2();
-*/
-/*
-signals:
-    void testLoginClosed();
-*/
+
+private slots:
+    /**
+    * @brief Intercepts signal fom closing login window. Checks login status and exits if necessary
+    *
+    * @fn loginScreenClosed
+    */
+    void loginScreenClosed();
+
+    void loginOK();
 };
 
 #endif // MAINWINDOW_H
index f2a2cc4..2801d54 100644 (file)
@@ -1,6 +1,6 @@
 CONFIG += qtestlib
 TEMPLATE = app
-TARGET = 
+TARGET = mainwindow_test
 DEPENDPATH += .
 INCLUDEPATH += . \
     ../../../src/