Added text label for empty panels
[situare] / src / ui / friendlistpanel.cpp
index 99a2585..316638e 100644 (file)
@@ -114,6 +114,15 @@ FriendListPanel::FriendListPanel(QWidget *parent)
     friendListPanelLayout->setSpacing(0);
     setLayout(friendListPanelLayout);
 
+    m_noFriendsLabel = new QLabel();
+    m_noFriendsLabel->setText("No Friends");
+    m_noFriendsLabel->setAlignment(Qt::AlignCenter);
+
+    QPalette noFriendsPalette = palette();
+    noFriendsPalette.setColor(QPalette::Foreground, Qt::white);
+    m_noFriendsLabel->setPalette(noFriendsPalette);
+
+    friendListPanelLayout->addWidget(m_noFriendsLabel, Qt::AlignCenter);
     friendListPanelLayout->addWidget(m_headerWidget);
     friendListPanelLayout->addLayout(listViewLayout);
     friendListPanelLayout->addLayout(footerLayout);
@@ -142,6 +151,8 @@ FriendListPanel::FriendListPanel(QWidget *parent)
     m_itemButtonsLayout->addWidget(m_routeButton);
     m_itemButtonsLayout->addWidget(m_showContactButton);
     m_genericButtonsLayout->addWidget(m_clearGroupFilteringButton);
+
+    showEmptyPanel(true);
 }
 
 void FriendListPanel::anyPanelClosed()
@@ -209,6 +220,9 @@ void FriendListPanel::friendInfoReceived(QList<User *> &friendList)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
+    if (!friendList.isEmpty())
+           showEmptyPanel(false);
+
     QStringList newUserIDs;
 
     foreach (User *user, friendList) {
@@ -231,6 +245,7 @@ void FriendListPanel::friendInfoReceived(QList<User *> &friendList)
     }
 
     m_friendListView->clearUnused(newUserIDs);
+    m_friendListView->show();
 }
 
 void FriendListPanel::hideEvent(QHideEvent *event)
@@ -297,6 +312,17 @@ void FriendListPanel::showEvent(QShowEvent *event)
     setFilteringLayoutVisibility(false);
 }
 
+void FriendListPanel::showEmptyPanel(bool show)
+{
+    if (show){
+        m_noFriendsLabel->show();
+        m_friendListView->hide();
+    }
+    else {
+        m_noFriendsLabel->hide();
+    }
+}
+
 void FriendListPanel::showFriendsInList(const QList<QString> &userIDs)
 {
     qDebug() << __PRETTY_FUNCTION__;