First commit
[hidecallerid] / src / idwidget.cpp
1 #include "idwidget.h"
2
3 IdWidget::IdWidget(tpSession *tp)
4     : QPushButton()
5 {
6     this->tp = tp;
7     setAttribute(Qt::WA_TranslucentBackground);
8     QObject::connect(this, SIGNAL(clicked()), this, SLOT(changeState()));
9     QObject::connect(tp, SIGNAL(privacyUpdated(bool)), this, SLOT(setButtonState(bool)));
10     pHidden = new QPixmap(":/icons/hidden.png");
11     pShown = new QPixmap(":/icons/shown.png");
12 }
13
14 void IdWidget::setButtonState(bool showId)
15 {
16     QPixmap *pixmap;
17     this->showId = showId;
18
19     if(showId) {
20         pixmap = pShown;
21         setText("Id Shown");
22     }
23     else {
24         pixmap = pHidden;
25         setText("Id Hidden");
26     }
27
28     QIcon icon(*pixmap);
29     QSize iconSize(pixmap->width(), pixmap->height());
30     setIconSize(iconSize);
31     setIcon(icon);
32 }
33
34 void IdWidget::changeState()
35 {
36     if(showId) {
37         tp->setPrivacy(false);
38     }
39     else {
40         tp->setPrivacy(true);
41     }
42 }