Added scrollbar to userinfo
authorKatri Kaikkonen <katri.kaikkonen@ixonos.com>
Fri, 21 May 2010 13:23:40 +0000 (16:23 +0300)
committerKatri Kaikkonen <katri.kaikkonen@ixonos.com>
Fri, 21 May 2010 13:23:40 +0000 (16:23 +0300)
src/ui/userinfo.cpp
src/ui/userpanel.cpp
src/ui/userpanel.h

index d457e46..4afdaf3 100644 (file)
@@ -35,7 +35,7 @@ const int ICON_HEIGHT = 24;     ///< Icon height
 const int ICON_WIDTH = 24;       ///< Icon width
 const int IMAGE_HEIGHT = 60; ///< Friend image height
 const int IMAGE_WIDTH = 60;  ///< Friend image width
-const int ITEM_MIN_WIDTH = 250;  ///< Minimum width for item
+const int ITEM_MIN_WIDTH = 245;  ///< Minimum width for item
 const int MARGIN = 5;   ///< Icon margin
 const int MOUSE_PRESS_AREA_WIDTH = 20;  ///< Area width for item height toggling
 const int MOUSE_PRESS_AREA_HEIGHT = 20; ///< Area height for item height toggling
@@ -52,52 +52,54 @@ const int LABEL_MAX_WIDTH = ITEM_MIN_WIDTH - 3*MARGIN - ICON_WIDTH;
 *
 * @var NAME_LABEL_MAX_WIDTH
 */
-const int NAME_LABEL_MAX_WIDTH = LABEL_MAX_WIDTH + 30;
+const int NAME_LABEL_MAX_WIDTH = LABEL_MAX_WIDTH + 70;
 
 UserInfo::UserInfo(QWidget *parent)
-    : QWidget(parent)
-        , m_expanded(false)
-{
+    : QWidget(parent),
+      m_expanded(false)
+{    
     QVBoxLayout *verticalLayout = new QVBoxLayout(this);
-    verticalLayout->setContentsMargins(MARGIN, 0, MARGIN*2, MARGIN*2);
+    verticalLayout->setContentsMargins(MARGIN * 2, 0, MARGIN * 2, MARGIN * 2);
+//    verticalLayout->setSizeConstraint(QLayout::SetFixedSize);
     verticalLayout->setSpacing(0);
-    setLayout(verticalLayout);
+    this->setLayout(verticalLayout);
+
+    QVBoxLayout *topLayout = new QVBoxLayout(this);
+    topLayout->setMargin(0);
+    topLayout->setSpacing(0);
 
-    QFormLayout *infoLayout = new QFormLayout();
+    QFormLayout *infoLayout = new QFormLayout(this);
     infoLayout->setMargin(0);
     infoLayout->setSpacing(0);
 
-    QHBoxLayout *buttonLayout = new QHBoxLayout();
+    QHBoxLayout *buttonLayout = new QHBoxLayout(this);
     buttonLayout->setMargin(0);
     buttonLayout->setSpacing(0);
 
-    QLabel *clockLabel = new QLabel();
-    clockLabel->setPixmap(QPixmap(":/res/images/clock.png"));
-    clockLabel->setContentsMargins(0, 0, MARGIN, 0);
-    clockLabel->setFixedSize(ICON_WIDTH + MARGIN, ICON_HEIGHT);
-    QLabel *envelopeLabel = new QLabel();
+    QLabel *envelopeLabel = new QLabel(this);
     envelopeLabel->setPixmap(QPixmap(":/res/images/envelope.png"));
     envelopeLabel->setContentsMargins(0, 0, MARGIN, 0);
     envelopeLabel->setFixedSize(ICON_WIDTH + MARGIN, ICON_HEIGHT);
-    QLabel *compassLabel = new QLabel();
+    QLabel *compassLabel = new QLabel(this);
     compassLabel->setPixmap(QPixmap(":/res/images/compass.png"));
     compassLabel->setContentsMargins(0, 0, MARGIN, 0);
     compassLabel->setFixedSize(ICON_WIDTH + MARGIN, ICON_HEIGHT);
+    QLabel *clockLabel = new QLabel(this);
+    clockLabel->setPixmap(QPixmap(":/res/images/clock.png"));
+    clockLabel->setContentsMargins(0, 0, MARGIN, 0);
+    clockLabel->setFixedSize(ICON_WIDTH + MARGIN, ICON_HEIGHT);
 
-    m_imageLabel = new QLabel();
+    m_imageLabel = new QLabel(this);
     m_imageLabel->setFixedSize(IMAGE_WIDTH, IMAGE_HEIGHT);
-    m_imageLabel->setAlignment(Qt::AlignHCenter);
 
-    m_nameLabel = new QLabel();
-    m_nameLabel->setFixedHeight(IMAGE_HEIGHT);
-    m_nameLabel->setAlignment(Qt::AlignHCenter);
+    m_nameLabel = new QLabel(this);
 
-    m_updatedLabel = new QLabel();
-    m_updatedLabel->setWordWrap(true);
-    m_statusTextLabel = new QLabel();
+    m_statusTextLabel = new QLabel(this);
     m_statusTextLabel->setWordWrap(true);
-    m_locationLabel = new QLabel();
+    m_locationLabel = new QLabel(this);
     m_locationLabel->setWordWrap(true);
+    m_updatedLabel = new QLabel(this);
+    m_updatedLabel->setWordWrap(true);
 
     ImageButton *updateFriendsButton = new ImageButton(this, ":/res/images/refresh.png",
                                                              ":/res/images/refresh_s.png");
@@ -107,21 +109,25 @@ UserInfo::UserInfo(QWidget *parent)
     buttonLayout->addWidget(updateFriendsButton);
     buttonLayout->addWidget(updateStatusMessageButton);
 
-    infoLayout->addRow(compassLabel, m_locationLabel);
     infoLayout->addRow(envelopeLabel, m_statusTextLabel);
+    infoLayout->addRow(compassLabel, m_locationLabel);
     infoLayout->addRow(clockLabel, m_updatedLabel);
 
-    verticalLayout->addWidget(m_imageLabel, 0, Qt::AlignHCenter);
-
-    verticalLayout->addWidget(m_nameLabel, 1);
-    verticalLayout->addLayout(infoLayout);
-    verticalLayout->addLayout(buttonLayout, 2);
+//    verticalLayout->addWidget(m_imageLabel, 0, Qt::AlignHCenter);
+//    verticalLayout->addWidget(m_nameLabel, 0, Qt::AlignHCenter);
+    topLayout->addWidget(m_imageLabel, 0, Qt::AlignHCenter);
+    topLayout->addWidget(m_nameLabel, 0, Qt::AlignHCenter);
+    verticalLayout->addLayout(topLayout);
+    verticalLayout->addLayout(infoLayout, 1);
+    verticalLayout->addLayout(buttonLayout);
 
     connect(updateStatusMessageButton,SIGNAL(clicked()),
             this,SLOT(messageUpdate()));
     connect(updateFriendsButton,SIGNAL(clicked()),
             this, SIGNAL(refreshUserData()));
 
+    setFixedWidth(235);
+
     this->setFont(NOKIA_FONT_SMALL);
     m_nameLabel->setFont(NOKIA_FONT_NORMAL);
     QPalette itemPalette = palette();
@@ -135,7 +141,8 @@ UserInfo::UserInfo(QWidget *parent)
     m_backgroundMiddleImage.load(":/res/images/list_item_middle.png");
     m_backgroundBottomImage.load(":/res/images/list_item_bottom.png");
 
-    this->setMinimumWidth(ITEM_MIN_WIDTH);
+    qWarning() << "Widget width:" << size().width();
+    qWarning() << "VLay width:" << verticalLayout->sizeHint().width();
 }
 
 void UserInfo::setUserName(const QString &name)
@@ -238,6 +245,9 @@ void UserInfo::paintEvent(QPaintEvent *aPaintEvent)
     painter.drawPixmap(topRect, m_backgroundTopImage);
     painter.drawPixmap(middleRect, m_backgroundMiddleImage);
     painter.drawPixmap(bottomRect, m_backgroundBottomImage);
+
+//    painter.setPen(Qt::white);
+//    painter.drawRect(rect().x(), rect().y(), rect().width() - 1, rect().height() - 1);
 }
 
 void UserInfo::mousePressEvent(QMouseEvent *event)
index 1fd4584..0410a26 100644 (file)
@@ -31,15 +31,12 @@ UserInfoPanel::UserInfoPanel(QWidget *parent)
 
     m_userPanelVBox = new QVBoxLayout(this);
     m_userPanelVBox->setMargin(0);
-    m_userPanelVBox->setContentsMargins(SLIDINGBAR_WIDTH+1, 0, SIDEBAR_WIDTH, 0);
+    m_userPanelVBox->setContentsMargins(SLIDINGBAR_WIDTH + 3, 0, SIDEBAR_WIDTH + 3, 0);
     m_userPanelVBox->setSpacing(0);
 
-    m_userInfo = new UserInfo(this);
-    m_userPanelVBox->addWidget(m_userInfo, 0, Qt::AlignCenter);
-
     m_panelBase = new QWidget(this);
     m_panelBase->setLayout(m_userPanelVBox);
-    m_panelBase->move(TOP_CORNER_X,PANEL_TOP_Y);
+    m_panelBase->move(TOP_CORNER_X, PANEL_TOP_Y);
     m_panelBase->resize(USERPANEL_WIDTH, USERPANEL_HEIGHT);
 
     QPalette pal = palette();
@@ -47,6 +44,19 @@ UserInfoPanel::UserInfoPanel(QWidget *parent)
     m_panelBase->setPalette(pal);
     m_panelBase->setAutoFillBackground(true);
 
+    m_userView = new QWidget(this);
+    m_userView->setLayout(m_userPanelVBox);
+
+    m_userInfo = new UserInfo(this);
+    QScrollArea *userInfoScroll = new QScrollArea(this);
+    userInfoScroll->setWidget(m_userInfo);
+    userInfoScroll->setWidgetResizable(true);
+    userInfoScroll->viewport()->setAutoFillBackground(false);
+    userInfoScroll->widget()->setAutoFillBackground(false);
+    userInfoScroll->setFixedWidth(245);
+
+    m_userPanelVBox->addWidget(userInfoScroll);
+
     PanelSliderBar *m_userPanelSlidingBar = new PanelSliderBar(this, LEFT);
     m_userPanelSlidingBar->move(USERPANEL_WIDTH - SLIDINGBAR_WIDTH, PANEL_TOP_Y);
 
@@ -89,10 +99,10 @@ UserInfoPanel::UserInfoPanel(QWidget *parent)
 
 void UserInfoPanel::userDataReceived(User *user)
 {
-    qDebug() << __PRETTY_FUNCTION__ << " " << user->name();
+    qDebug() << __PRETTY_FUNCTION__;
 
-    m_userInfo->setUserName(user->name());
     m_userInfo->setAvatar(user->profileImage());
+    m_userInfo->setUserName(user->name());
     m_userInfo->setMessageText(user->note());
     m_userInfo->setAddress(user->address());
     m_userInfo->setTime(user->timestamp());
index e32fcaa..c5c6404 100644 (file)
@@ -101,6 +101,7 @@ signals:
  ******************************************************************************/
 private:
     QWidget *m_panelBase; ///< Widget for panel base
+    QWidget *m_userView;
     PanelSliderBar *m_userPanelSlidingBar; ///< Widget for sidebar tab item
     QState *m_userPanelStateClosed; ///< State of the closed panel
     QStateMachine *m_userPanelStateMachine; ///< State machine for sliding the panel
@@ -109,5 +110,6 @@ private:
     QSignalTransition *m_userPanelTransitionOpen; ///< Transition signal for opening the panel
     UserInfo *m_userInfo;
     QVBoxLayout *m_userPanelVBox; ///< Vertical layout inside the panel
+      QVBoxLayout *m_userViewLayout;
 };
 #endif // USERPANEL_H