Added new background images to userinfo item
authorKatri Kaikkonen <katri.kaikkonen@ixonos.com>
Tue, 25 May 2010 08:09:19 +0000 (11:09 +0300)
committerKatri Kaikkonen <katri.kaikkonen@ixonos.com>
Tue, 25 May 2010 08:09:19 +0000 (11:09 +0300)
images.qrc
src/ui/userinfo.cpp
src/ui/userinfo.h
src/ui/userinfopanel.cpp

index 1c97969..f05aa75 100644 (file)
         <file>res/images/sliding_bar_right.png</file>
         <file>res/images/led_red.png</file>
         <file>res/images/led_red_s.png</file>
-        <file>res/images/list_item.png</file>
         <file>res/images/list_item_bottom.png</file>
         <file>res/images/list_item_middle.png</file>
         <file>res/images/list_item_top.png</file>
+       <file>res/images/user_info_item_bottom.png</file>
+        <file>res/images/user_info_item_middle.png</file>
+        <file>res/images/user_info_item_top.png</file>
         <file>res/images/sliding_bar_left_test.png</file>
         <file>res/images/userpanel_mask.png</file>
         <file>res/images/sliding_bar_right_test.png</file>
         <file>res/images/gps_pos_accurate.png</file>
         <file>res/images/gps_pos_coarse.png</file>
         <file>res/images/friend_group.png</file>
-               <file>res/images/sight.png</file>
+        <file>res/images/sight.png</file>
     </qresource>
 </RCC>
index 4afdaf3..b2d5d1c 100644 (file)
 #include "../user/user.h"
 #include "userinfo.h"
 
-const int BACKGROUND_TOP_HEIGHT = 20;
+const int BACKGROUND_WIDTH = 240; ///< Width for item
+const int BACKGROUND_TOP_HEIGHT = 16;
 const int BACKGROUND_BOTTOM_HEIGHT = 15;
-const QColor COLOR_GRAY = QColor(152, 152, 152);    ///< Gray color
-const QFont NOKIA_FONT_NORMAL = QFont("Nokia Sans", 18, QFont::Normal);    ///< Normal font
-const QFont NOKIA_FONT_SMALL = QFont("Nokia Sans", 13, QFont::Normal);     ///< Small font
-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 = 245;  ///< Minimum width for item
-const int MARGIN = 5;   ///< Icon margin
+const QColor COLOR_GRAY = QColor(152, 152, 152); ///< Gray color
+const QFont NOKIA_FONT_NORMAL = QFont("Nokia Sans", 18, QFont::Normal); ///< Normal font
+const QFont NOKIA_FONT_SMALL = QFont("Nokia Sans", 13, QFont::Normal);  ///< Small font
+const int ICON_HEIGHT = 24; ///< Icon height
+const int ICON_WIDTH = 24;  ///< Icon width
+const int IMAGE_HEIGHT = 60;    ///< Profile image height
+const int IMAGE_WIDTH = 60;     ///< Profile image width
+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
 
@@ -45,7 +45,7 @@ const int MOUSE_PRESS_AREA_HEIGHT = 20; ///< Area height for item height togglin
 *
 * @brief All label's maximum width
 */
-const int LABEL_MAX_WIDTH = ITEM_MIN_WIDTH - 3*MARGIN - ICON_WIDTH;
+const int LABEL_MAX_WIDTH = BACKGROUND_WIDTH - 3 * MARGIN - ICON_WIDTH + 130;
 
 /**
 * @brief Name label's maximum width
@@ -60,19 +60,14 @@ UserInfo::UserInfo(QWidget *parent)
 {    
     QVBoxLayout *verticalLayout = new QVBoxLayout(this);
     verticalLayout->setContentsMargins(MARGIN * 2, 0, MARGIN * 2, MARGIN * 2);
-//    verticalLayout->setSizeConstraint(QLayout::SetFixedSize);
     verticalLayout->setSpacing(0);
     this->setLayout(verticalLayout);
 
-    QVBoxLayout *topLayout = new QVBoxLayout(this);
-    topLayout->setMargin(0);
-    topLayout->setSpacing(0);
-
-    QFormLayout *infoLayout = new QFormLayout(this);
+    QFormLayout *infoLayout = new QFormLayout();
     infoLayout->setMargin(0);
     infoLayout->setSpacing(0);
 
-    QHBoxLayout *buttonLayout = new QHBoxLayout(this);
+    QHBoxLayout *buttonLayout = new QHBoxLayout();
     buttonLayout->setMargin(0);
     buttonLayout->setSpacing(0);
 
@@ -93,6 +88,8 @@ UserInfo::UserInfo(QWidget *parent)
     m_imageLabel->setFixedSize(IMAGE_WIDTH, IMAGE_HEIGHT);
 
     m_nameLabel = new QLabel(this);
+    m_nameLabel->setWordWrap(true);
+    m_nameLabel->setFixedHeight(IMAGE_HEIGHT);
 
     m_statusTextLabel = new QLabel(this);
     m_statusTextLabel->setWordWrap(true);
@@ -113,11 +110,8 @@ UserInfo::UserInfo(QWidget *parent)
     infoLayout->addRow(compassLabel, m_locationLabel);
     infoLayout->addRow(clockLabel, m_updatedLabel);
 
-//    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->addWidget(m_imageLabel, 0, Qt::AlignHCenter);
+    verticalLayout->addWidget(m_nameLabel, 0, Qt::AlignHCenter);
     verticalLayout->addLayout(infoLayout, 1);
     verticalLayout->addLayout(buttonLayout);
 
@@ -126,7 +120,7 @@ UserInfo::UserInfo(QWidget *parent)
     connect(updateFriendsButton,SIGNAL(clicked()),
             this, SIGNAL(refreshUserData()));
 
-    setFixedWidth(235);
+    this->setFixedWidth(BACKGROUND_WIDTH);
 
     this->setFont(NOKIA_FONT_SMALL);
     m_nameLabel->setFont(NOKIA_FONT_NORMAL);
@@ -137,12 +131,9 @@ UserInfo::UserInfo(QWidget *parent)
     namePalette.setColor(QPalette::Foreground, Qt::white);
     m_nameLabel->setPalette(namePalette);
 
-    m_backgroundTopImage.load(":/res/images/list_item_top.png");
-    m_backgroundMiddleImage.load(":/res/images/list_item_middle.png");
-    m_backgroundBottomImage.load(":/res/images/list_item_bottom.png");
-
-    qWarning() << "Widget width:" << size().width();
-    qWarning() << "VLay width:" << verticalLayout->sizeHint().width();
+    this->m_backgroundTopImage.load(":/res/images/user_info_item_top.png");
+    this->m_backgroundMiddleImage.load(":/res/images/user_info_item_middle.png");
+    this->m_backgroundBottomImage.load(":/res/images/user_info_item_bottom.png");
 }
 
 void UserInfo::setUserName(const QString &name)
@@ -153,7 +144,7 @@ void UserInfo::setUserName(const QString &name)
     setText(false);
 }
 
-void UserInfo::setAvatar(const QPixmap &image)
+void UserInfo::setProfileImage(const QPixmap &image)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
@@ -168,18 +159,18 @@ void UserInfo::setMessageText(const QString &text)
     setText(false);
 }
 
-void UserInfo::setAddress(const QString &addr)
+void UserInfo::setAddress(const QString &address)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_locationLabel->setText(addr);
+    m_locationLabel->setText(address);
 }
 
-void UserInfo::setTime(const QString &tim)
+void UserInfo::setTime(const QString &time)
 {
     qDebug() << __PRETTY_FUNCTION__;
 
-    m_updatedLabel->setText(tim);
+    m_updatedLabel->setText(time);
 }
 
 QString UserInfo::shortenText(const QLabel *label, const QString &text, int textMaxWidth)
@@ -208,7 +199,7 @@ void UserInfo::setText(bool expanded)
         m_statusTextLabel->setText(m_messageText);
     }
     else {
-        m_nameLabel->setText(shortenText(m_nameLabel, m_userName, NAME_LABEL_MAX_WIDTH));
+        m_nameLabel->setText(shortenText(m_nameLabel, m_userName, LABEL_MAX_WIDTH));
         m_statusTextLabel->setText(shortenText(m_statusTextLabel, m_messageText,
                                                LABEL_MAX_WIDTH));
     }
@@ -236,18 +227,15 @@ void UserInfo::paintEvent(QPaintEvent *aPaintEvent)
 
     QPainter painter(this);
 
-    QRect topRect = QRect(0, 0, ITEM_MIN_WIDTH, BACKGROUND_TOP_HEIGHT);
-    QRect middleRect = QRect(0, topRect.bottom(), ITEM_MIN_WIDTH,
+    QRect topRect = QRect(0, MARGIN, BACKGROUND_WIDTH, BACKGROUND_TOP_HEIGHT);
+    QRect middleRect = QRect(0, topRect.bottom(), BACKGROUND_WIDTH,
                              height() - BACKGROUND_TOP_HEIGHT - BACKGROUND_BOTTOM_HEIGHT);
-    QRect bottomRect = QRect(topRect.left(), middleRect.bottom(), ITEM_MIN_WIDTH,
+    QRect bottomRect = QRect(topRect.left(), middleRect.bottom(), BACKGROUND_WIDTH,
                              BACKGROUND_BOTTOM_HEIGHT);
 
     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 06c2494..a57d81f 100644 (file)
@@ -49,6 +49,7 @@ protected:
     * @param event QMouseEvent mouse press event
     */
     void mousePressEvent(QMouseEvent *event);
+
     /**
     * @brief Call toggleHeight if mouse position is unchanged.
     *
@@ -56,6 +57,7 @@ protected:
     * @param event QMouseEvent mouse release event
     */
     void mouseReleaseEvent(QMouseEvent *event);
+
     /**
     * @brief This function is called when the widget is drawn
     *
@@ -72,14 +74,14 @@ public:
     *
     * @param addr Reference to users current address
     */
-    void setAddress(const QString &addr);
+    void setAddress(const QString &address);
 
     /**
     * @brief Sets the user picture
     *
     * @param avat Reference to user picture
     */
-    void setAvatar(const QPixmap &image);
+    void setProfileImage(const QPixmap &image);
 
     /**
     * @brief Sets the message text
@@ -93,7 +95,7 @@ public:
     *
     * @param tim Reference to time when message was sent.
     */
-    void setTime(const QString &tim);
+    void setTime(const QString &time);
 
    /**
     * @brief Sets the user name
index 66a9a2a..60b952d 100644 (file)
@@ -26,10 +26,26 @@ UserInfoPanel::UserInfoPanel(QWidget *parent)
     : SidePanel(parent)
 {
     qDebug() << __PRETTY_FUNCTION__;
+
     setType(SidePanel::UserPanel);
 
     m_userInfo = new UserInfo(this);
-    m_panelVBox->addWidget(m_userInfo, 0, Qt::AlignCenter);
+
+    m_userInfoView = new QWidget(this);
+    m_userViewLayout = new QVBoxLayout(m_userInfoView);
+    m_userViewLayout->setMargin(0);
+    m_userViewLayout->setSpacing(0);
+    m_userViewLayout->setStretch(0, 0);
+    m_userViewLayout->setSizeConstraint(QLayout::SetFixedSize);
+    m_userViewLayout->addWidget(m_userInfo);
+
+    QScrollArea *userInfoScroll = new QScrollArea(this);
+    userInfoScroll->setWidgetResizable(true);
+    userInfoScroll->setWidget(m_userInfoView);
+    userInfoScroll->setAlignment(Qt::AlignVCenter);
+    userInfoScroll->viewport()->setAutoFillBackground(false);
+    userInfoScroll->widget()->setAutoFillBackground(false);
+    m_panelVBox->addWidget(userInfoScroll);
 
     connect(m_userInfo,SIGNAL(requestReverseGeo()),
             this, SIGNAL(requestReverseGeo()));
@@ -46,10 +62,11 @@ 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->setUserName("pirkko-liisapaula Marjamaa-Pulkkinen");
+    m_userInfo->setProfileImage(user->profileImage());
     m_userInfo->setMessageText(user->note());
     m_userInfo->setAddress(user->address());
     m_userInfo->setTime(user->timestamp());