Made a few cosmetic changes
[situare] / src / ui / friendlistpanel.cpp
index a923868..27e2814 100644 (file)
 #include "friendlistpanel.h"
 #include "friendlistview.h"
 #include "friendlistitem.h"
+#include "panelcommon.h"
+#include "panelsliderbar.h"
 
 FriendListPanel::FriendListPanel(QWidget *parent)
     : QWidget(parent)
 {
-    qWarning() << __PRETTY_FUNCTION__; 
-    QVBoxLayout *friendsListGrid = new QVBoxLayout(this);
-    this->setLayout(friendsListGrid);
-    QPushButton *friendsDummyBTN = new QPushButton("HOOO", this);
-//    QLabel *friendsDummyLBL = new QLabel("FRIENDS LIST", this);
-    friendsListGrid->addWidget(friendsDummyBTN);
-
+    qDebug() << __PRETTY_FUNCTION__;
+    m_friendsPanelVBox = new QVBoxLayout(this);
+    m_friendsPanelVBox->setMargin(0);
+    m_friendsPanelVBox->setContentsMargins(SLIDINGBAR_WIDTH+1, 0, SIDEBAR_WIDTH, 0);
+    m_friendsPanelVBox->setSpacing(0);
+    setLayout(m_friendsPanelVBox);
 
     m_friendListView = new FriendListView(this);
     QScrollArea *friendListScroll = new QScrollArea(this);
+    friendListScroll->setWidgetResizable(false);
     friendListScroll->setWidget(m_friendListView);
-    friendListScroll->setWidgetResizable(true);
-//    m_friendListView->setAutoFillBackground(false);
     friendListScroll->viewport()->setAutoFillBackground(false);
+    friendListScroll->widget()->setAutoFillBackground(false);
 
-    friendsListGrid->addWidget(friendListScroll);
+    m_friendsPanelVBox->addWidget(friendListScroll);
 
-//    friendsListGrid->addWidget(friendsDummyLBL, 2,2,2,3);
-    this->resize(420,600);
-//    this->setAutoFillBackground(true);
-    this->move(50,50);
+    setAutoFillBackground(true);
+    QPalette pal = palette();
+    pal.setColor(QPalette::Background, QColor(0, 0, 0, 128));
+    setPalette(pal);
 
-    QStateMachine *friendsListMachine = new QStateMachine(this);
-    QState *friendsListStateClosed = new QState(friendsListMachine);
-    friendsListStateClosed->assignProperty(this, "pos", QPoint(800,0));
-    friendsListMachine->setInitialState(friendsListStateClosed);
+    m_friendsPanelSlidingBar = new PanelSliderBar(this, RIGHT);
+    m_friendsPanelSlidingBar->move(TOP_CORNER_X, PANEL_TOP_Y);
 
-    QState *friendsListStateOpen = new QState(friendsListMachine);
-    friendsListStateOpen->assignProperty(this, "pos", QPoint(400,0));
+    m_friendsPanelStateMachine = new QStateMachine(this);
+    m_friendsPanelStateClosed = new QState(m_friendsPanelStateMachine);
+    m_friendsPanelStateClosed->assignProperty(this, "pos", QPoint(
+            FRIENDPANEL_CLOSED_X, PANEL_TOP_Y));
+    m_friendsPanelStateMachine->setInitialState(m_friendsPanelStateClosed);
 
-    QSignalTransition *friendsListTransitionOpen = friendsListStateClosed->addTransition(
-            friendsDummyBTN, SIGNAL(clicked()), friendsListStateOpen);
-    friendsListTransitionOpen->addAnimation(new QPropertyAnimation(this, "pos"));
+    m_friendsPanelStateOpened = new QState(m_friendsPanelStateMachine);
+    m_friendsPanelStateOpened->assignProperty(this, "pos", QPoint(
+            FRIENDPANEL_OPENED_X, PANEL_TOP_Y));
 
-    QSignalTransition *friendsListTransitionClose = friendsListStateOpen->addTransition(
-            friendsDummyBTN, SIGNAL(clicked()), friendsListStateClosed);
-    friendsListTransitionClose->addAnimation(new QPropertyAnimation(this, "pos"));
+    m_friendsPanelTransitionOpen = m_friendsPanelStateClosed->addTransition(
+            m_friendsPanelSlidingBar, SIGNAL(clicked()), m_friendsPanelStateOpened);
+    m_friendsPanelTransitionOpen->addAnimation(new QPropertyAnimation(this, "pos", this));
 
-    friendsListMachine->start();
+    m_friendsPanelTransitionClose = m_friendsPanelStateOpened->addTransition(
+            m_friendsPanelSlidingBar, SIGNAL(clicked()), m_friendsPanelStateClosed);
+    m_friendsPanelTransitionClose->addAnimation(new QPropertyAnimation(this, "pos", this));
+
+    m_friendsPanelStateMachine->start();
+    setObjectName("FriendsPanel");
 }
 
 void FriendListPanel::friendInfoReceived(QList<User *> &friendList)
@@ -76,6 +83,19 @@ void FriendListPanel::friendInfoReceived(QList<User *> &friendList)
     foreach (User *user, friendList) {
         FriendListItem *item = new FriendListItem(m_friendListView);
         item->setData(user);
+        connect(item, SIGNAL(findFriend(QPointF)),
+            this, SIGNAL(findFriend(QPointF)));
         m_friendListView->addWidget(item);
     }
 }
+
+void FriendListPanel::reDrawFriendsPanel(int width, int height)
+{
+    qDebug() << __PRETTY_FUNCTION__;
+    resize(FRIENDPANEL_WIDTH,height + MARGIN_CORRECTION);
+    m_friendsPanelStateClosed->assignProperty(this, "pos", QPoint(
+            width - PANEL_PEEK_AMOUNT, PANEL_TOP_Y));
+    m_friendsPanelStateOpened->assignProperty(this, "pos", QPoint(
+            width - FRIENDPANEL_WIDTH + MARGIN_CORRECTION, PANEL_TOP_Y));
+    move(width - PANEL_PEEK_AMOUNT, PANEL_TOP_Y);
+}