+/*
+ 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)
{
- layout = new QGridLayout(this);
- userPicture = new QLabel;
- userNameLabel = new QLabel;
- messageLabel = new QLabel;
- addressLabel = new QLabel;
- timeLabel = new QLabel;
- QLabel *clockLabel = new QLabel;
- QLabel *envelopeLabel = new QLabel;
- QLabel *compassLabel = new QLabel;
- QToolButton *sendLocationButton = new QToolButton;
- QToolButton *updateStatusMessageButton = new QToolButton;
-
- sendLocationButton->setIcon(QIcon(QPixmap(":/resources/reload_icon.png")));
- updateStatusMessageButton->setIcon(QIcon(QPixmap(":/resources/sendPosition_icon.png")));
-
-
- clockLabel->setPixmap(QPixmap(":/resources/clock_small.png"));
- envelopeLabel->setPixmap(QPixmap(":/resources/list_small.png"));
- compassLabel->setPixmap(QPixmap(":/resources/compas_small.png"));
- layout->addWidget(userPicture,0,0,4,1);
- layout->addWidget(userNameLabel,0,2,1,2);
- layout->addWidget(clockLabel,1,1,1,1);
- layout->addWidget(envelopeLabel,2,1,1,1);
- layout->addWidget(compassLabel,3,1,1,1);
- layout->addWidget(timeLabel,1,2,1,1);
- layout->addWidget(messageLabel,2,2,1,1);
- layout->addWidget(addressLabel,3,2,1,1);
- layout->addWidget(sendLocationButton,0,3,2,1);
- layout->addWidget(updateStatusMessageButton,1,3,2,1);
-
-}
-
-InfoTab::~InfoTab()
-{
- if (userPicture)
- delete userPicture;
- if (userNameLabel)
- delete userNameLabel;
- if (messageLabel)
- delete messageLabel;
- if (addressLabel)
- delete addressLabel;
- if (timeLabel)
- delete timeLabel;
- if (layout)
- delete layout;
- userPicture=NULL;
- userNameLabel=NULL;
- messageLabel=NULL;
- addressLabel=NULL;
- timeLabel=NULL;
- layout=NULL;
+ 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()));
+
+ 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
- //setAutoFillBackground(true);
- QPalette qpalette;
- QColor myColor(Qt::lightGray);
- myColor.setAlpha(100);
- qpalette.setColor(QPalette::Background,myColor);
- setPalette(qpalette);
- int roundness(6);
+ Q_UNUSED(aPaintEvent);
+ QStyleOption option;
+ option.init(this);
- 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);
-
- painter.setClipPath(roundedRect);
- QRegion maskRegion = painter.clipRegion();
-
- setMask(maskRegion);
+ 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)
{
- avatar = avat;
- userPicture->setPixmap(avat);
+ m_avatar = avat;
+ situUser->setPixmap(m_avatar);
}
void InfoTab::setUserName(const QString &usernam)
{
- if(userName == usernam)
+ if(m_userName == usernam)
return;
- userName = usernam;
- userNameLabel->setText(userName);
+ m_userName = usernam;
+ m_userNameLabel->setText(m_userName);
}
void InfoTab::setMessageText(const QString &text)
{
- if(messageText == text)
+ if(m_messageText == text)
return;
- messageText = text;
- messageLabel->setText(messageText);
+ m_messageText = text;
+ m_messageLabel->setText(m_messageText);
}
void InfoTab::setAddress(const QString &addr)
{
- if(address == addr)
+ if(m_address == addr)
return;
- address = addr;
- addressLabel->setText(address);
+ m_address = addr;
+ m_addressLabel->setText(m_address);
}
void InfoTab::setTime(const QString &tim)
{
- if(time == tim)
+ if(m_time == tim)
return;
- time = tim;
- timeLabel->setText(time);
+ m_time = tim;
+ m_timeLabel->setText(m_time);
+}
+
+void InfoTab::messageUpdate()
+{
+ emit launchMessageUpdate();
+ qDebug() << __PRETTY_FUNCTION__;
+}
+
+void InfoTab::updateFriendsStatus()
+{
+ emit launchUpdateFriendsStatus();
+ qDebug() << __PRETTY_FUNCTION__;
}