Merge branch 'master' of ssh://mercury.wipsl.com/var/git/irw
[irwi] / src / mainwidget.cpp
1 #include "mainwidget.h"
2
3 #include <QInputDialog>
4 #include <QPainter>
5 #include <QGridLayout>
6 #include <QPushButton>
7
8 #include "settingsdlg.h"
9
10 MainWidget::MainWidget (QWidget *parent)
11     : QWidget(parent)
12 {
13     layout = new QGridLayout(this);
14
15     for (int i = 0; i < BUTTON_COUNT; ++i)
16     {
17         QPushButton *button = new QPushButton(QString(i+0x30), this);
18         buttons[i] = button;
19         layout->addWidget(button, i%2, i/2);
20     }
21
22     connect(buttons[0], SIGNAL(clicked(bool)), &irCtrl, SLOT(sendCmd0(bool)));
23     connect(buttons[1], SIGNAL(clicked(bool)), &irCtrl, SLOT(sendCmd1(bool)));
24     connect(buttons[2], SIGNAL(clicked(bool)), &irCtrl, SLOT(sendCmd2(bool)));
25     connect(buttons[3], SIGNAL(clicked(bool)), &irCtrl, SLOT(sendCmd3(bool)));
26     connect(buttons[4], SIGNAL(clicked(bool)), &irCtrl, SLOT(sendCmd4(bool)));
27     connect(buttons[5], SIGNAL(clicked(bool)), &irCtrl, SLOT(sendCmd5(bool)));
28
29     this->setLayout(layout);
30     this->setAttribute(Qt::WA_TranslucentBackground);
31 }
32
33  void MainWidget::paintEvent(QPaintEvent *event)
34  {
35      QPainter p(this);
36      p.setBrush(QColor(0, 0, 0, 128));
37      p.setPen(Qt::NoPen);
38      p.drawRoundRect(rect(), 10, 20);
39      p.end();
40  }
41  
42 void MainWidget::showSettingsDialog()
43 {
44     SettingsDlg dlg(this);
45     if (dlg.exec() == QDialog::Accepted)
46     {
47         irCtrl.setRemoteName(dlg.getRemoteName());
48     }
49 }
50
51