The first "kind of" working version of the new panels
[situare] / src / ui / mainwindow.cpp
index d93ae1a..6bd5c0d 100644 (file)
@@ -37,6 +37,8 @@
 #include "indicatorbutton.h"
 #include "logindialog.h"
 #include "mapscale.h"
+#include "panelcommon.h"
+#include "tabbedpanel.h"
 #include "searchdialog.h"
 #include "settingsdialog.h"
 #include "userinfopanel.h"
 
 MainWindow::MainWindow(QWidget *parent)
     : QMainWindow(parent),
-    m_errorShown(false),
-    m_loggedIn(false),
-    m_refresh(false),
-    m_progressIndicatorCount(0),
-    m_ownLocationCrosshair(0),
-    m_email(),
-    m_password(),
-    m_webView(0),
-    m_fullScreenButton(0),
-    m_indicatorButton(0),
-    m_mapScale(0),
-    m_cookieJar(0)
+      m_errorShown(false),
+      m_loggedIn(false),
+      m_refresh(false),
+      m_progressIndicatorCount(0),
+      m_ownLocationCrosshair(0),
+      m_email(),
+      m_password(),
+      m_webView(0),
+      m_fullScreenButton(0),
+      m_indicatorButton(0),
+      m_mapScale(0),
+      m_cookieJar(0)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
@@ -80,14 +82,15 @@ MainWindow::MainWindow(QWidget *parent)
     setCentralWidget(new QWidget());
     centralWidget()->setLayout(layout);
 
-    buildFriendListPanel();
+//    buildFriendListPanel();
     buildUserInfoPanel();
 
     createMenus();
     setWindowTitle(tr("Situare"));
 
     // set stacking order of widgets
-    m_zoomButtonPanel->stackUnder(m_userPanel);
+//    m_zoomButtonPanel->stackUnder(m_userInfoPanel);
+    m_zoomButtonPanel->stackUnder(m_tabbedPanel);
     if(m_fullScreenButton) {
         m_fullScreenButton->stackUnder(m_zoomButtonPanel);
         m_osmLicense->stackUnder(m_fullScreenButton);
@@ -155,10 +158,6 @@ void MainWindow::buildFriendListPanel()
 
     m_friendsListPanel = new FriendListPanel(this);
 
-    m_friendsListPanelSidebar = new PanelSideBar(this, RIGHT);
-
-    m_friendsListPanel->stackUnder(m_friendsListPanelSidebar);
-
     connect(this, SIGNAL(friendsLocationsReady(QList<User*>&)),
             m_friendsListPanel, SLOT(friendInfoReceived(QList<User*>&)));
 
@@ -168,9 +167,6 @@ void MainWindow::buildFriendListPanel()
     connect(m_mapView, SIGNAL(viewResized(QSize)),
             m_friendsListPanel, SLOT(resizePanel(QSize)));
 
-    connect(m_mapView, SIGNAL(viewResized(QSize)),
-            m_friendsListPanelSidebar, SLOT(resizeSideBar(QSize)));
-
     connect(m_friendsListPanel, SIGNAL(findFriend(GeoCoordinate)),
             this, SIGNAL(findFriend(GeoCoordinate)));
 
@@ -309,42 +305,43 @@ void MainWindow::buildUserInfoPanel()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_userPanel = new UserInfoPanel(this);
-
-    m_userPanelSidebar = new PanelSideBar(this, LEFT);
-
-    m_userPanelSidebar->stackUnder(m_friendsListPanel);
-    m_userPanel->stackUnder(m_userPanelSidebar);
+    m_userInfoPanel = new UserInfoPanel(this);
 
     connect(this, SIGNAL(userLocationReady(User*)),
-            m_userPanel, SLOT(userDataReceived(User*)));
+            m_userInfoPanel, SLOT(userDataReceived(User*)));
 
     connect(this, SIGNAL(reverseGeoReady(QString)),
-            m_userPanel, SIGNAL(reverseGeoReady(QString)));
+            m_userInfoPanel, SIGNAL(reverseGeoReady(QString)));
 
     connect(this, SIGNAL(clearUpdateLocationDialogData()),
-            m_userPanel, SIGNAL(clearUpdateLocationDialogData()));
+            m_userInfoPanel, SIGNAL(clearUpdateLocationDialogData()));
 
-    connect(m_mapView, SIGNAL(viewResized(QSize)),
-            m_userPanel, SLOT(resizePanel(QSize)));
-
-    connect(m_mapView, SIGNAL(viewResized(QSize)),
-            m_userPanelSidebar, SLOT(resizeSideBar(QSize)));
-
-    connect(m_userPanel, SIGNAL(findUser(GeoCoordinate)),
+    connect(m_userInfoPanel, SIGNAL(findUser(GeoCoordinate)),
             this, SIGNAL(findUser(GeoCoordinate)));
 
-    connect(m_userPanel, SIGNAL(requestReverseGeo()),
+    connect(m_userInfoPanel, SIGNAL(requestReverseGeo()),
             this, SIGNAL(requestReverseGeo()));
 
-    connect(m_userPanel, SIGNAL(statusUpdate(QString,bool)),
+    connect(m_userInfoPanel, SIGNAL(statusUpdate(QString,bool)),
             this, SIGNAL(statusUpdate(QString,bool)));
 
-    connect(m_userPanel, SIGNAL(refreshUserData()),
+    connect(m_userInfoPanel, SIGNAL(refreshUserData()),
             this, SIGNAL(refreshUserData()));
 
-    connect(m_userPanel, SIGNAL(notificateUpdateFailing(QString, bool)),
+    connect(m_userInfoPanel, SIGNAL(notificateUpdateFailing(QString, bool)),
             this, SLOT(buildInformationBox(QString, bool)));
+
+    m_tabbedPanel = new TabbedPanel(this);
+    m_tabbedPanel->addTab(m_userInfoPanel, QIcon(":/res/images/user_info.png"));
+
+    // This is just testing
+    m_tabbedPanel->addTab(new QPushButton("Friend List"), QIcon(":/res/images/friend_list.png"));
+
+    // Another test
+    m_tabbedPanel->addTab(new QPushButton("Routing"), QIcon(":/res/images/routing.png"));
+
+    connect(m_mapView, SIGNAL(viewResized(QSize)),
+            m_tabbedPanel, SLOT(resizePanel(QSize)));
 }
 
 void MainWindow::buildWebView()
@@ -500,16 +497,9 @@ void MainWindow::drawFullScreenButton(const QSize &size)
 {
     qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
 
-    if(m_fullScreenButton) {
-        if(m_loggedIn) {
-            m_fullScreenButton->move(size.width() - m_fullScreenButton->size().width()
-                                     - PANEL_PEEK_AMOUNT,
-                                     size.height() - m_fullScreenButton->size().height());
-        } else {
-            m_fullScreenButton->move(size.width() - m_fullScreenButton->size().width(),
-                                     size.height() - m_fullScreenButton->size().height());
-        }
-    }
+    if(m_fullScreenButton)
+        m_fullScreenButton->move(size.width() - m_fullScreenButton->size().width(),
+                                 size.height() - m_fullScreenButton->size().height());
 }
 
 void MainWindow::drawMapScale(const QSize &size)
@@ -518,9 +508,9 @@ void MainWindow::drawMapScale(const QSize &size)
 
     const int LEFT_SCALE_MARGIN = 10;
     const int BOTTOM_SCALE_MARGIN = 2;
-    qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
+//    qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
 
-    m_mapScale->move(PANEL_PEEK_AMOUNT + LEFT_SCALE_MARGIN,
+    m_mapScale->move(LEFT_SCALE_MARGIN,
                      size.height() - m_mapScale->size().height() - BOTTOM_SCALE_MARGIN);
 }
 
@@ -529,7 +519,7 @@ void MainWindow::drawOsmLicense(const QSize &size)
     qDebug() << __PRETTY_FUNCTION__ << size.width() << "x" << size.height();
 
     m_osmLicense->move(size.width() - m_osmLicense->fontMetrics().width(OSM_LICENSE)
-                       - PANEL_PEEK_AMOUNT,
+                       - PANEL_BAR_WIDTH,
                        size.height() - m_osmLicense->fontMetrics().height());
 }
 
@@ -909,17 +899,17 @@ void MainWindow::showPanels()
 
     drawFullScreenButton(m_viewPortSize);
 
-    if(m_loggedIn) {
-        if(!m_friendsListPanel->isVisible()) {
-            m_friendsListPanel->show();
-            m_friendsListPanelSidebar->show();
-        }
+//    if(m_loggedIn) {
+//        if(!m_friendsListPanel->isVisible()) {
+//            m_friendsListPanel->show();
+//            m_friendsListPanelSidebar->show();
+//        }
 
-        if(!m_userPanel->isVisible()) {
-            m_userPanel->show();
-            m_userPanelSidebar->show();
-        }
-    }
+//        if(!m_userPanel->isVisible()) {
+//            m_userPanel->show();
+//            m_userPanelSidebar->show();
+//        }
+//    }
 }
 
 void MainWindow::startLocationSearch()
@@ -970,14 +960,14 @@ void MainWindow::updateItemVisibility()
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    if(!m_loggedIn) {
-        m_friendsListPanel->closePanel();
-        m_friendsListPanel->hide();
-        m_friendsListPanelSidebar->hide();
-        m_userPanel->closePanel();
-        m_userPanel->hide();
-        m_userPanelSidebar->hide();
-    }
+//    if(!m_loggedIn) {
+//        m_friendsListPanel->closePanel();
+//        m_friendsListPanel->hide();
+//        m_friendsListPanelSidebar->hide();
+//        m_userPanel->closePanel();
+//        m_userPanel->hide();
+//        m_userPanelSidebar->hide();
+//    }
 }
 
 const QString MainWindow::username()