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(":/resources/refresh.png")));
66 updateStatusMessageButton->setIcon(QIcon(QPixmap(":/resources/send_position.png")));
68 m_clockLabel->setPixmap(QPixmap(":/resources/clock.png"));
69 m_envelopeLabel->setPixmap(QPixmap(":/resources/envelope.png"));
70 m_compassLabel->setPixmap(QPixmap(":/resources/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);
88 connect(updateStatusMessageButton,SIGNAL(clicked()),this,SLOT(messageUpdate()));
89 connect(updateFriendsButton,SIGNAL(clicked()),this,SLOT(updateFriendsStatus()));
92 void InfoTab::paintEvent(QPaintEvent *aPaintEvent)
95 QRect widgetRect = this->rect();
98 QLinearGradient linearGrad(QPointF(widgetRect.height(), widgetRect.width()/2),
99 QPointF(widgetRect.width()/2,0));
100 linearGrad.setColorAt(0, QColor::fromRgb(49,52,57));
101 linearGrad.setColorAt(1, QColor::fromRgb(82,73,74));
103 //Look and feel settings
105 QBrush brush(linearGrad);
106 qpalette.setBrush(QPalette::Window,brush);
107 setPalette(qpalette);
110 QPainter painter(this);
114 painter.setRenderHint(QPainter::Antialiasing);
115 QPainterPath roundedRect;
116 roundedRect.addRoundedRect(1,1,widgetRect.width()-2, widgetRect.height()-2,roundness,roundness);
118 painter.setClipPath(roundedRect);
119 QRegion maskRegion = painter.clipRegion();
123 painter.fillPath(roundedRect,QBrush(brush));
127 QSize InfoTab::sizeHint() const
133 void InfoTab::setAvatar(const QPixmap &avat)
136 situUser->setPixmap(m_avatar);
139 void InfoTab::setUserName(const QString &usernam)
141 if(m_userName == usernam)
143 m_userName = usernam;
144 m_userNameLabel->setText(m_userName);
147 void InfoTab::setMessageText(const QString &text)
149 if(m_messageText == text)
151 m_messageText = text;
152 m_messageLabel->setText(m_messageText);
155 void InfoTab::setAddress(const QString &addr)
157 if(m_address == addr)
160 m_addressLabel->setText(m_address);
163 void InfoTab::setTime(const QString &tim)
168 m_timeLabel->setText(m_time);
171 void InfoTab::messageUpdate()
173 emit launchMessageUpdate();
174 qDebug() << __PRETTY_FUNCTION__;
177 void InfoTab::updateFriendsStatus()
179 emit launchUpdateFriendsStatus();
180 qDebug() << __PRETTY_FUNCTION__;