Fixed application icon sizes and re-organized resource files to another location
[situare] / src / ui / infotab.cpp
1 #include "infotab.h"
2
3 InfoTab::InfoTab(QWidget *parent)
4     : QWidget(parent, Qt::FramelessWindowHint)
5 {
6     m_layout = new QGridLayout(this);
7     m_userPicture = new QLabel;
8     m_userNameLabel = new QLabel;
9     m_messageLabel = new QLabel;
10     m_addressLabel = new QLabel;
11     m_timeLabel = new QLabel;
12     QLabel *m_clockLabel = new QLabel;
13     QLabel *m_envelopeLabel = new QLabel;
14     QLabel *m_compassLabel = new QLabel;
15     QToolButton *updateFriendsButton = new QToolButton;
16     QToolButton *updateStatusMessageButton = new QToolButton;
17
18     updateFriendsButton->setIcon(QIcon(QPixmap(":/res/images/reload_icon.png")));
19     updateStatusMessageButton->setIcon(QIcon(QPixmap(":/res/images/sendPosition_icon.png")));
20
21     m_clockLabel->setPixmap(QPixmap(":/res/images/clock_small.png"));
22     m_envelopeLabel->setPixmap(QPixmap(":/res/images/list_small.png"));
23     m_compassLabel->setPixmap(QPixmap(":/res/images/compas_small.png"));
24     m_layout->addWidget(m_userPicture,0,0,4,1);
25     m_layout->addWidget(m_userNameLabel,0,2,1,2);
26     m_layout->addWidget(m_clockLabel,1,1,1,1);
27     m_layout->addWidget(m_envelopeLabel,2,1,1,1);
28     m_layout->addWidget(m_compassLabel,3,1,1,1);
29     m_layout->addWidget(m_timeLabel,1,2,1,1);
30     m_layout->addWidget(m_messageLabel,2,2,1,1);
31     m_layout->addWidget(m_addressLabel,3,2,1,1);
32     m_layout->addWidget(updateFriendsButton,0,3,2,1);
33     m_layout->addWidget(updateStatusMessageButton,1,3,2,1);
34
35     connect(updateStatusMessageButton,SIGNAL(clicked()),this,SLOT(messageUpdate()));
36     connect(updateFriendsButton,SIGNAL(clicked()),this,SLOT(updateFriendsStatus()));
37 }
38
39 InfoTab::~InfoTab()
40 {
41     if (m_userPicture)
42         delete m_userPicture;
43     if (m_userNameLabel)
44         delete m_userNameLabel;
45     if (m_messageLabel)
46         delete m_messageLabel;
47     if (m_addressLabel)
48         delete m_addressLabel;
49     if (m_timeLabel)
50         delete m_timeLabel;
51     if (m_layout)
52         delete m_layout;
53     m_userPicture=NULL;
54     m_userNameLabel=NULL;
55     m_messageLabel=NULL;
56     m_addressLabel=NULL;
57     m_timeLabel=NULL;
58     m_layout=NULL;
59 }
60
61 void InfoTab::paintEvent(QPaintEvent *aPaintEvent)
62 {
63     //Look and feel settings
64     QPalette qpalette;
65     QColor myColor(Qt::black);
66     myColor.setAlpha(50);
67     qpalette.setColor(QPalette::Background,myColor);
68     setPalette(qpalette);
69     int roundness(6);
70
71     QRect widgetRect = this->rect();
72     QPainter painter(this);
73     painter.save();
74
75     painter.setRenderHint(QPainter::Antialiasing);
76     QPainterPath roundedRect;
77     roundedRect.addRoundedRect(1,1,widgetRect.width() - 2, widgetRect.height()-2,roundness,roundness);
78
79     painter.setClipPath(roundedRect);
80     QRegion maskRegion = painter.clipRegion();
81
82     setMask(maskRegion);
83
84     painter.fillPath(roundedRect,QBrush(myColor));
85     painter.restore();
86 }
87
88 void InfoTab::setAvatar(const QPixmap &avat)
89 {
90     m_avatar = avat;
91     m_userPicture->setPixmap(m_avatar);
92 }
93
94 void InfoTab::setUserName(const QString &usernam)
95 {
96     if(m_userName == usernam)
97       return;
98     m_userName = usernam;
99     m_userNameLabel->setText(m_userName);
100 }
101
102 void InfoTab::setMessageText(const QString &text)
103 {
104     if(m_messageText == text)
105       return;
106     m_messageText = text;
107     m_messageLabel->setText(m_messageText);
108 }
109
110 void InfoTab::setAddress(const QString &addr)
111 {
112     if(m_address == addr)
113       return;
114     m_address = addr;
115     m_addressLabel->setText(m_address);
116 }
117
118 void InfoTab::setTime(const QString &tim)
119 {
120     if(m_time == tim)
121       return;
122     m_time = tim;
123     m_timeLabel->setText(m_time);
124 }
125
126 void InfoTab::messageUpdate()
127 {
128     emit launchMessageUpdate();
129     qDebug() << __PRETTY_FUNCTION__;
130 }
131
132 void InfoTab::updateFriendsStatus()
133 {
134     emit launchUpdateFriendsStatus();
135     qDebug() << __PRETTY_FUNCTION__;
136 }