Removed old pictures.
[situare] / src / ui / infotab.cpp
1 /*
2    Situare - A location system for Facebook
3    Copyright (C) 2010  Ixonos Plc. Authors:
4
5        Jukka Saastamoinen - jukka.saastamoinen@ixonos.com
6
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.
10
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.
15
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,
19    USA.
20 */
21
22 #include "infotab.h"
23 #include "buttonitem.h"
24
25 InfoTab::InfoTab(QWidget *parent)
26     : QWidget(parent, Qt::FramelessWindowHint)
27 {
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);
36
37     //Tex color settings
38     QPalette textPalette;
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));
43
44     m_messageLabel = new QLabel(widget);
45     m_messageLabel->setFont(QFont( "Nokia Sans", 13, QFont::Normal));
46     m_messageLabel->setPalette(textPalette);
47
48     m_addressLabel = new QLabel(widget);
49     m_addressLabel->setFont(QFont( "Nokia Sans", 13, QFont::Normal));
50     m_addressLabel->setPalette(textPalette);
51
52     m_timeLabel = new QLabel(widget);
53     m_timeLabel->setFont(QFont( "Nokia Sans", 13, QFont::Normal));
54     m_timeLabel->setPalette(textPalette);
55
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);
64
65     updateFriendsButton->setIcon(QIcon(QPixmap(":/res/images/refresh.png")));
66     updateStatusMessageButton->setIcon(QIcon(QPixmap(":/res/images/send_position.png")));
67
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);
79
80     verticalLayout->addLayout(m_layout);
81     horizontalLayout->setSpacing(0);
82     horizontalLayout->addWidget(updateFriendsButton);
83     horizontalLayout->addWidget(updateStatusMessageButton);
84
85     verticalLayout->addLayout(horizontalLayout);
86
87     verticalLayout2->addLayout(verticalLayout);
88
89     connect(updateStatusMessageButton,SIGNAL(clicked()),this,SLOT(messageUpdate()));
90     connect(updateFriendsButton,SIGNAL(clicked()),this,SLOT(updateFriendsStatus()));
91 }
92
93 void InfoTab::paintEvent(QPaintEvent *aPaintEvent)
94 {
95
96     QRect widgetRect = this->rect();
97
98     //Gradient
99     QLinearGradient linearGrad(QPointF(widgetRect.height(), widgetRect.width()/2),
100                                QPointF(widgetRect.width()/2,0));
101     linearGrad.setColorAt(0, QColor::fromRgb(49,52,57));
102     linearGrad.setColorAt(1, QColor::fromRgb(82,73,74));
103
104     //Look and feel settings
105     QPalette qpalette;
106     QBrush brush(linearGrad);
107     qpalette.setBrush(QPalette::Window,brush);
108     setPalette(qpalette);
109     int roundness(9);
110
111     QPainter painter(this);
112
113     painter.save();
114
115     painter.setRenderHint(QPainter::Antialiasing);
116     QPainterPath roundedRect;
117     roundedRect.addRoundedRect(1,1,widgetRect.width()-2, widgetRect.height()-2,roundness,roundness);
118
119     painter.setClipPath(roundedRect);
120     QRegion maskRegion = painter.clipRegion();
121
122     setMask(maskRegion);
123
124     painter.fillPath(roundedRect,QBrush(brush));
125     painter.restore();
126 }
127
128 QSize InfoTab::sizeHint() const
129 {
130    QSize size(280,280);
131    return size;
132 }
133
134 void InfoTab::setAvatar(const QPixmap &avat)
135 {
136     m_avatar = avat;
137     situUser->setPixmap(m_avatar);
138 }
139
140 void InfoTab::setUserName(const QString &usernam)
141 {
142     if(m_userName == usernam)
143       return;
144     m_userName = usernam;
145     m_userNameLabel->setText(m_userName);
146 }
147
148 void InfoTab::setMessageText(const QString &text)
149 {
150     if(m_messageText == text)
151       return;
152     m_messageText = text;
153     m_messageLabel->setText(m_messageText);
154 }
155
156 void InfoTab::setAddress(const QString &addr)
157 {
158     if(m_address == addr)
159       return;
160     m_address = addr;
161     m_addressLabel->setText(m_address);
162 }
163
164 void InfoTab::setTime(const QString &tim)
165 {
166     if(m_time == tim)
167       return;
168     m_time = tim;
169     m_timeLabel->setText(m_time);
170 }
171
172 void InfoTab::messageUpdate()
173 {
174     emit launchMessageUpdate();
175     qDebug() << __PRETTY_FUNCTION__;
176 }
177
178 void InfoTab::updateFriendsStatus()
179 {
180     emit launchUpdateFriendsStatus();
181     qDebug() << __PRETTY_FUNCTION__;
182 }