Finalised the classes for panels
[situare] / src / ui / userpanel.cpp
1  /*
2     Situare - A location system for Facebook
3     Copyright (C) 2010  Ixonos Plc. Authors:
4
5         Kaj Wallin - kaj.wallin@ixonos.com
6
7     Situare is free software; you can redistribute it and/or
8     modify it under the terms of the GNU General Public License
9     version 2 as published by the Free Software Foundation.
10
11     Situare is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with Situare; if not, write to the Free Software
18     Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
19     USA.
20  */
21
22 #include "userpanel.h"
23 #include "panelcommon.h"
24 #include "panelsliderbar.h"
25
26 UserInfoPanel::UserInfoPanel(QWidget *parent)
27     : QWidget(parent)
28 {
29     qDebug() << __PRETTY_FUNCTION__;
30     m_userPanelVBox = new QVBoxLayout(this);
31     setLayout(m_userPanelVBox);
32
33     setAutoFillBackground(true);
34     QPalette pal = palette();
35     pal.setColor(QPalette::Background, QColor(0, 0, 0, 128));
36     setPalette(pal);
37
38     PanelSliderBar *m_userPanelSlidingBar = new PanelSliderBar(this, LEFT);
39     m_userPanelSlidingBar->move(USERPANEL_WIDTH - SLIDINGBAR_WIDTH, PANEL_TOP_Y);
40
41     m_userPanelStateMachine = new QStateMachine(this);
42     m_userPanelStateClosed = new QState(m_userPanelStateMachine);
43     m_userPanelStateClosed->assignProperty(this, "pos", QPoint(
44             USERPANEL_CLOSED_X, PANEL_TOP_Y));
45     m_userPanelStateMachine->setInitialState(m_userPanelStateClosed);
46
47     m_userPanelStateOpened = new QState(m_userPanelStateMachine);
48     m_userPanelStateOpened->assignProperty(this, "pos", QPoint(
49             USERPANEL_OPENED_X, PANEL_TOP_Y));
50
51     m_userPanelTransitionOpen = m_userPanelStateClosed->addTransition(
52             m_userPanelSlidingBar, SIGNAL(clicked()), m_userPanelStateOpened);
53     m_userPanelTransitionOpen->addAnimation(new QPropertyAnimation(this, "pos", this));
54
55     m_userPanelTransitionClose = m_userPanelStateOpened->addTransition(
56             m_userPanelSlidingBar, SIGNAL(clicked()), m_userPanelStateClosed);
57     m_userPanelTransitionClose->addAnimation(new QPropertyAnimation(this, "pos", this));
58
59     m_userPanelStateMachine->start();
60     setObjectName("UserPanel");
61 }
62
63 void UserInfoPanel::reDrawUserPanel(int width, int height)
64 {
65     qDebug() << __PRETTY_FUNCTION__;
66     Q_UNUSED(width);
67     resize(USERPANEL_WIDTH,height + MARGIN_CORRECTION);
68 }