2 Situare - A location system for Facebook
3 Copyright (C) 2010 Ixonos Plc. Authors:
5 Jukka Saastamoinen - jukka.saastamoinen@ixonos.com
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.
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.
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,
23 #include "buttonitem.h"
25 InfoTab::InfoTab(QWidget *parent)
26 : QWidget(parent, Qt::FramelessWindowHint)
28 widget = new QWidget(this);
29 QVBoxLayout *verticalLayout = new QVBoxLayout(widget);
30 QVBoxLayout *verticalLayout2 = new QVBoxLayout(widget);
31 QHBoxLayout *horizontalLayout = new QHBoxLayout(widget);
32 QGridLayout *m_layout = new QGridLayout(widget);
33 situUser = new SituareUser(widget);
34 situUser->setAlignment(Qt::AlignHCenter|Qt::AlignVCenter);
35 situUser->setMargin(1);
39 QColor textColor(152,152,152);
40 textPalette.setColor(QPalette::WindowText,textColor);
41 m_userNameLabel = new QLabel(widget);
42 m_userNameLabel->setFont(QFont( "Nokia Sans", 18, QFont::Normal));
44 m_messageLabel = new QLabel(widget);
45 m_messageLabel->setFont(QFont( "Nokia Sans", 13, QFont::Normal));
46 m_messageLabel->setPalette(textPalette);
48 m_addressLabel = new QLabel(widget);
49 m_addressLabel->setFont(QFont( "Nokia Sans", 13, QFont::Normal));
50 m_addressLabel->setPalette(textPalette);
52 m_timeLabel = new QLabel(widget);
53 m_timeLabel->setFont(QFont( "Nokia Sans", 13, QFont::Normal));
54 m_timeLabel->setPalette(textPalette);
56 QLabel *m_clockLabel = new QLabel(widget);
57 m_clockLabel->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter);
58 QLabel *m_envelopeLabel = new QLabel(widget);
59 m_envelopeLabel->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter);
60 QLabel *m_compassLabel = new QLabel(widget);
61 m_compassLabel->setAlignment(Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter);
62 ButtonItem *updateFriendsButton = new ButtonItem(widget);
63 ButtonItem *updateStatusMessageButton = new ButtonItem(widget);
65 updateFriendsButton->setIcon(QIcon(QPixmap(":/res/images/refresh.png")));
66 updateStatusMessageButton->setIcon(QIcon(QPixmap(":/res/images/send_position.png")));
68 m_clockLabel->setPixmap(QPixmap(":/res/images/clock.png"));
69 m_envelopeLabel->setPixmap(QPixmap(":/res/images/envelope.png"));
70 m_compassLabel->setPixmap(QPixmap(":/res/images/compass.png"));
71 m_layout->addWidget(situUser,0,0,1,2,Qt::AlignHCenter);
72 m_layout->addWidget(m_userNameLabel,1,1,1,2);
73 m_layout->addWidget(m_clockLabel,3,0,1,1);
74 m_layout->addWidget(m_envelopeLabel,2,0,1,1);
75 m_layout->addWidget(m_compassLabel,4,0,1,1);
76 m_layout->addWidget(m_timeLabel,3,1,1,1);
77 m_layout->addWidget(m_messageLabel,2,1,1,1);
78 m_layout->addWidget(m_addressLabel,4,1,1,1);
80 verticalLayout->addLayout(m_layout);
81 horizontalLayout->setSpacing(0);
82 horizontalLayout->addWidget(updateFriendsButton);
83 horizontalLayout->addWidget(updateStatusMessageButton);
85 verticalLayout->addLayout(horizontalLayout);
87 verticalLayout2->addLayout(verticalLayout);
89 connect(updateStatusMessageButton,SIGNAL(clicked()),this,SLOT(messageUpdate()));
90 connect(updateFriendsButton,SIGNAL(clicked()),this,SLOT(updateFriendsStatus()));
93 void InfoTab::paintEvent(QPaintEvent *aPaintEvent)
95 Q_UNUSED(aPaintEvent);
97 QRect widgetRect = this->rect();
100 QLinearGradient linearGrad(QPointF(widgetRect.height(), widgetRect.width()/2),
101 QPointF(widgetRect.width()/2,0));
102 linearGrad.setColorAt(0, QColor::fromRgb(49,52,57));
103 linearGrad.setColorAt(1, QColor::fromRgb(82,73,74));
105 //Look and feel settings
107 QBrush brush(linearGrad);
108 qpalette.setBrush(QPalette::Window,brush);
109 setPalette(qpalette);
112 QPainter painter(this);
116 painter.setRenderHint(QPainter::Antialiasing);
117 QPainterPath roundedRect;
118 roundedRect.addRoundedRect(1,1,widgetRect.width()-2, widgetRect.height()-2,roundness,roundness);
120 painter.setClipPath(roundedRect);
121 QRegion maskRegion = painter.clipRegion();
125 painter.fillPath(roundedRect,QBrush(brush));
129 QSize InfoTab::sizeHint() const
135 void InfoTab::setAvatar(const QPixmap &avat)
138 situUser->setPixmap(m_avatar);
141 void InfoTab::setUserName(const QString &usernam)
143 if(m_userName == usernam)
145 m_userName = usernam;
146 m_userNameLabel->setText(m_userName);
149 void InfoTab::setMessageText(const QString &text)
151 if(m_messageText == text)
153 m_messageText = text;
154 m_messageLabel->setText(m_messageText);
157 void InfoTab::setAddress(const QString &addr)
159 if(m_address == addr)
162 m_addressLabel->setText(m_address);
165 void InfoTab::setTime(const QString &tim)
170 m_timeLabel->setText(m_time);
173 void InfoTab::messageUpdate()
175 emit launchMessageUpdate();
176 qDebug() << __PRETTY_FUNCTION__;
179 void InfoTab::updateFriendsStatus()
181 emit launchUpdateFriendsStatus();
182 qDebug() << __PRETTY_FUNCTION__;