Added toggleProgressInidicator to engine.cpp.
[situare] / src / ui / infotab.cpp
index 48e2f8f..9f39004 100644 (file)
+/*
+   Situare - A location system for Facebook
+   Copyright (C) 2010  Ixonos Plc. Authors:
+
+       Jukka Saastamoinen - jukka.saastamoinen@ixonos.com
+
+   Situare is free software; you can redistribute it and/or
+   modify it under the terms of the GNU General Public License
+   version 2 as published by the Free Software Foundation.
+
+   Situare is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with Situare; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301,
+   USA.
+*/
+
 #include "infotab.h"
+#include "buttonitem.h"
+#include "mainwindow.h"
+#include <QDebug>
+
+const int RGB_R = 152;
+const int RGB_G = 152;
+const int RGB_B = 152;
+const int SIZE_X = 320;
+const int SIZE_Y = 280;
+const int BIG_FONT = 18;
+const int SMALL_FONT = 13;
 
 InfoTab::InfoTab(QWidget *parent)
     : QWidget(parent, Qt::FramelessWindowHint)
 {
-    m_layout = new QGridLayout(this);
-    m_userPicture = new QLabel;
-    m_userNameLabel = new QLabel;
-    m_messageLabel = new QLabel;
-    m_addressLabel = new QLabel;
-    m_timeLabel = new QLabel;
-    QLabel *m_clockLabel = new QLabel;
-    QLabel *m_envelopeLabel = new QLabel;
-    QLabel *m_compassLabel = new QLabel;
-    QToolButton *updateFriendsButton = new QToolButton;
-    QToolButton *updateStatusMessageButton = new QToolButton;
-
-    updateFriendsButton->setIcon(QIcon(QPixmap(":/resources/reload_icon.png")));
-    updateStatusMessageButton->setIcon(QIcon(QPixmap(":/resources/sendPosition_icon.png")));
-
-    m_clockLabel->setPixmap(QPixmap(":/resources/clock_small.png"));
-    m_envelopeLabel->setPixmap(QPixmap(":/resources/list_small.png"));
-    m_compassLabel->setPixmap(QPixmap(":/resources/compas_small.png"));
-    m_layout->addWidget(m_userPicture,0,0,4,1);
-    m_layout->addWidget(m_userNameLabel,0,2,1,2);
-    m_layout->addWidget(m_clockLabel,1,1,1,1);
-    m_layout->addWidget(m_envelopeLabel,2,1,1,1);
-    m_layout->addWidget(m_compassLabel,3,1,1,1);
-    m_layout->addWidget(m_timeLabel,1,2,1,1);
-    m_layout->addWidget(m_messageLabel,2,2,1,1);
-    m_layout->addWidget(m_addressLabel,3,2,1,1);
-    m_layout->addWidget(updateFriendsButton,0,3,2,1);
-    m_layout->addWidget(updateStatusMessageButton,1,3,2,1);
+    widget = new QWidget(this);
+    verticalLayout = new QVBoxLayout(widget);
+    horizontalLayout = new QHBoxLayout(widget);
+    m_layout = new QGridLayout(widget);
+    situUser = new SituareUser(widget);
+
+    //Tex color settings
+    QPalette textPalette;
+    QColor textColor(RGB_R,RGB_G,RGB_B);
+    textPalette.setColor(QPalette::WindowText,textColor);
+    m_userNameLabel = new QLabel(widget);
+    m_userNameLabel->setFont(QFont( "Nokia Sans", BIG_FONT, QFont::Normal));
+
+    m_messageLabel = new QLabel(widget);
+    m_messageLabel->setFont(QFont( "Nokia Sans", SMALL_FONT, QFont::Normal));
+    m_messageLabel->setPalette(textPalette);
+
+    m_addressLabel = new QLabel(widget);
+    m_addressLabel->setFont(QFont( "Nokia Sans", SMALL_FONT, QFont::Normal));
+    m_addressLabel->setPalette(textPalette);
+
+    m_timeLabel = new QLabel(widget);
+    m_timeLabel->setFont(QFont( "Nokia Sans", 13, QFont::Normal));
+    m_timeLabel->setPalette(textPalette);
+
+    m_clockLabel = new QLabel(widget);
+    m_clockLabel->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter);
+    m_envelopeLabel = new QLabel(widget);
+    m_envelopeLabel->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter);
+    m_compassLabel = new QLabel(widget);
+    m_compassLabel->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter);
+    ButtonItem *updateFriendsButton = new ButtonItem(widget);
+    ButtonItem *updateStatusMessageButton = new ButtonItem(widget);
+
+    updateFriendsButton->setIcon(QIcon(QPixmap(":/res/images/refresh.png")));
+    updateStatusMessageButton->setIcon(QIcon(QPixmap(":/res/images/send_position.png")));
+
+    m_clockLabel->setPixmap(QPixmap(":/res/images/clock.png"));
+    m_envelopeLabel->setPixmap(QPixmap(":/res/images/envelope.png"));
+    m_compassLabel->setPixmap(QPixmap(":/res/images/compass.png"));
+    m_layout->addWidget(situUser,0,0,1,2,Qt::AlignHCenter);
+    m_layout->addWidget(m_userNameLabel,1,1,1,2);
+    m_layout->addWidget(m_clockLabel,3,0,1,1);
+    m_layout->addWidget(m_envelopeLabel,2,0,1,1);
+    m_layout->addWidget(m_compassLabel,4,0,1,1);
+    m_layout->addWidget(m_timeLabel,3,1,1,1);
+    m_layout->addWidget(m_messageLabel,2,1,1,1);
+    m_layout->addWidget(m_addressLabel,4,1,1,1);
+
+    verticalLayout->addLayout(m_layout);
+    horizontalLayout->setSpacing(0);
+    horizontalLayout->addWidget(updateFriendsButton);
+    horizontalLayout->addWidget(updateStatusMessageButton);
+
+    verticalLayout->addLayout(horizontalLayout);
 
     connect(updateStatusMessageButton,SIGNAL(clicked()),this,SLOT(messageUpdate()));
     connect(updateFriendsButton,SIGNAL(clicked()),this,SLOT(updateFriendsStatus()));
-}
 
-InfoTab::~InfoTab()
-{
-    if (m_userPicture)
-        delete m_userPicture;
-    if (m_userNameLabel)
-        delete m_userNameLabel;
-    if (m_messageLabel)
-        delete m_messageLabel;
-    if (m_addressLabel)
-        delete m_addressLabel;
-    if (m_timeLabel)
-        delete m_timeLabel;
-    if (m_layout)
-        delete m_layout;
-    m_userPicture=NULL;
-    m_userNameLabel=NULL;
-    m_messageLabel=NULL;
-    m_addressLabel=NULL;
-    m_timeLabel=NULL;
-    m_layout=NULL;
+    widget->setObjectName("infoTab");
+    widget->setStyleSheet(QString("#infoTab { border-image: url(:/res/images/list_item.png) 20%; " \
+                                  "border-width: 20px 14px 16px 14px; }"));
 }
 
 void InfoTab::paintEvent(QPaintEvent *aPaintEvent)
 {
-    //Look and feel settings
-    QPalette qpalette;
-    QColor myColor(Qt::black);
-    myColor.setAlpha(50);
-    qpalette.setColor(QPalette::Background,myColor);
-    setPalette(qpalette);
-    int roundness(6);
-
-    QRect widgetRect = this->rect();
-    QPainter painter(this);
-    painter.save();
-
-    painter.setRenderHint(QPainter::Antialiasing);
-    QPainterPath roundedRect;
-    roundedRect.addRoundedRect(1,1,widgetRect.width() - 2, widgetRect.height()-2,roundness,roundness);
+    Q_UNUSED(aPaintEvent);
 
-    painter.setClipPath(roundedRect);
-    QRegion maskRegion = painter.clipRegion();
+    QStyleOption option;
+    option.init(this);
 
-    setMask(maskRegion);
+    QPainter painter(this);
+    style()->drawPrimitive(QStyle::PE_Widget, &option, &painter, this);
+}
 
-    painter.fillPath(roundedRect,QBrush(myColor));
-    painter.restore();
+QSize InfoTab::sizeHint() const
+{
+   QSize size(SIZE_X,SIZE_Y);
+   return size;
 }
 
 void InfoTab::setAvatar(const QPixmap &avat)
 {
     m_avatar = avat;
-    m_userPicture->setPixmap(m_avatar);
+    situUser->setPixmap(m_avatar);
 }
 
 void InfoTab::setUserName(const QString &usernam)