Transparent background.
[irwi] / src / mainwidget.cpp
1 #include "mainwidget.h"
2
3 #include <QInputDialog>
4 #include <QPainter>
5 #include <QGridLayout>
6 #include <QPushButton>
7
8 MainWidget::MainWidget (QWidget *parent)
9     : QWidget(parent)
10 {
11     layout = new QGridLayout(this);
12
13     for (int i = 0; i < BUTTON_COUNT; ++i)
14     {
15         QPushButton *button = new QPushButton(QString(i+0x30), this);
16         buttons[i] = button;
17         layout->addWidget(button, i%2, i/2);
18     }
19
20     connect(buttons[0], SIGNAL(clicked(bool)), &irCtrl, SLOT(sendCmd0(bool)));
21     connect(buttons[1], SIGNAL(clicked(bool)), &irCtrl, SLOT(sendCmd1(bool)));
22     connect(buttons[2], SIGNAL(clicked(bool)), &irCtrl, SLOT(sendCmd2(bool)));
23     connect(buttons[3], SIGNAL(clicked(bool)), &irCtrl, SLOT(sendCmd3(bool)));
24     connect(buttons[4], SIGNAL(clicked(bool)), &irCtrl, SLOT(sendCmd4(bool)));
25     connect(buttons[5], SIGNAL(clicked(bool)), &irCtrl, SLOT(sendCmd5(bool)));
26
27     this->setLayout(layout);
28     this->setAttribute(Qt::WA_TranslucentBackground);
29 }
30
31  void MainWidget::paintEvent(QPaintEvent *event)
32  {
33      QPainter p(this);
34      p.setBrush(QColor(0, 0, 0, 128));
35      p.setPen(Qt::NoPen);
36      p.drawRoundRect(rect(), 10, 20);
37      p.end();
38  }
39  
40 void MainWidget::showSettingsDialog()
41 {
42     bool isOk;
43     QString newText = QInputDialog::getText(this, tr("New Text"),
44             tr("Please enter a new text:"), QLineEdit::Normal,
45             "foo", &isOk);
46 //    if (isOk)
47 //        setText(newText);
48 }
49
50