#include "friendlistview.h"
#include "friendlistitem.h"
#include "panelcommon.h"
+#include "panelsliderbar.h"
FriendListPanel::FriendListPanel(QWidget *parent)
: QWidget(parent)
{
qDebug() << __PRETTY_FUNCTION__;
m_friendsPanelVBox = new QVBoxLayout(this);
- this->setLayout(m_friendsPanelVBox);
- m_friendsPanelExpandButton = new QPushButton("Friends", this);
- m_friendsPanelVBox->addWidget(m_friendsPanelExpandButton);
+ 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);
friendListScroll->viewport()->setAutoFillBackground(false);
+ friendListScroll->widget()->setAutoFillBackground(false);
- this->setAutoFillBackground(true);
+ m_friendsPanelVBox->addWidget(friendListScroll);
+
+ setAutoFillBackground(true);
QPalette pal = palette();
pal.setColor(QPalette::Background, QColor(0, 0, 0, 128));
setPalette(pal);
- m_friendsPanelVBox->addWidget(friendListScroll);
+ m_friendsPanelSlidingBar = new PanelSliderBar(this, RIGHT);
+ m_friendsPanelSlidingBar->move(TOP_CORNER_X, PANEL_TOP_Y);
m_friendsPanelStateMachine = new QStateMachine(this);
m_friendsPanelStateClosed = new QState(m_friendsPanelStateMachine);
FRIENDPANEL_OPENED_X, PANEL_TOP_Y));
m_friendsPanelTransitionOpen = m_friendsPanelStateClosed->addTransition(
- this, SIGNAL(clicked()), m_friendsPanelStateOpened);
+ m_friendsPanelSlidingBar, SIGNAL(clicked()), m_friendsPanelStateOpened);
m_friendsPanelTransitionOpen->addAnimation(new QPropertyAnimation(this, "pos", this));
m_friendsPanelTransitionClose = m_friendsPanelStateOpened->addTransition(
- this, SIGNAL(clicked()), m_friendsPanelStateClosed);
+ m_friendsPanelSlidingBar, SIGNAL(clicked()), m_friendsPanelStateClosed);
m_friendsPanelTransitionClose->addAnimation(new QPropertyAnimation(this, "pos", this));
m_friendsPanelStateMachine->start();
- this->setObjectName("FriendsPanel");
-
- m_friendsPanelSlidingBar = new QWidget(this);
- m_friendsPanelSlidingBar->setObjectName("FriendsPanelSlidingBar");
- m_friendsPanelSlidingBar->setStyleSheet(QString(
- "#FriendsPanelSlidingBar{background-image: url(:/res/images/sliding_bar_right.png)}"));
- m_friendsPanelSlidingBar->resize(SLIDINGBAR_WIDTH, SLIDINGBAR_HEIGHT);
- m_friendsPanelSlidingBar->move(0, PANEL_TOP_Y);
+ setObjectName("FriendsPanel");
}
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__;
- this->resize(FRIENDPANEL_WIDTH,height + MARGIN_CORRECTION);
- m_friendsPanelSlidingBar->resize(SLIDINGBAR_WIDTH, SLIDINGBAR_HEIGHT);
+ resize(FRIENDPANEL_WIDTH,height + MARGIN_CORRECTION);
m_friendsPanelStateClosed->assignProperty(this, "pos", QPoint(
- width-PANEL_PEEK_AMOUNT, PANEL_TOP_Y));
+ width - PANEL_PEEK_AMOUNT, PANEL_TOP_Y));
m_friendsPanelStateOpened->assignProperty(this, "pos", QPoint(
width - FRIENDPANEL_WIDTH + MARGIN_CORRECTION, PANEL_TOP_Y));
- this->move(width-PANEL_PEEK_AMOUNT, PANEL_TOP_Y);
-}
-
-void FriendListPanel::mouseReleaseEvent(QMouseEvent *)
-{
- qDebug() << __PRETTY_FUNCTION__;
- emit clicked();
-}
-
-void FriendListPanel::paintEvent(QPaintEvent *)
-{
- qDebug() << __PRETTY_FUNCTION__;
-
- QStyleOption option;
- option.init(this);
-
- QStylePainter painter(this);
- style()->drawPrimitive(QStyle::PE_Widget, &option, &painter, this);
+ move(width - PANEL_PEEK_AMOUNT, PANEL_TOP_Y);
}