Removed borders.
[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     char *iconNames[] = {
16         "/usr/share/icons/hicolor/48x48/hildon/statusarea_volumelevel4.png",
17         "/usr/share/icons/hicolor/48x48/hildon/statusarea_volumelevel1.png",
18         "/usr/share/icons/hicolor/48x48/hildon/rss_reader_move_up.png",
19         "/usr/share/icons/hicolor/48x48/hildon/rss_reader_move_down.png",
20         "/usr/share/icons/hicolor/48x48/hildon/location_applet_on.png",
21         "/usr/share/icons/hicolor/48x48/hildon/statusarea_volume_mute.png"
22     };
23
24     char *buttonTitles[] = {
25         "Vol Up",
26         "Vol Down",
27         "Ch Up",
28         "Ch Down",
29         "Power Off",
30         "Mute"
31     };
32
33     for (int i = 0; i < BUTTON_COUNT; ++i)
34     {
35         QPushButton *button = new QPushButton(
36                 QIcon(QString(iconNames[i])), 
37                 QString(buttonTitles[i]), this);
38         buttons[i] = button;
39         button->setPalette(QPalette(QColor(0, 0, 0, 192)));
40         layout->addWidget(button, i%2, i/2);
41     }
42
43     connect(buttons[0], SIGNAL(clicked(bool)), &irCtrl, SLOT(sendCmd0(bool)));
44     connect(buttons[1], SIGNAL(clicked(bool)), &irCtrl, SLOT(sendCmd1(bool)));
45     connect(buttons[2], SIGNAL(clicked(bool)), &irCtrl, SLOT(sendCmd2(bool)));
46     connect(buttons[3], SIGNAL(clicked(bool)), &irCtrl, SLOT(sendCmd3(bool)));
47     connect(buttons[4], SIGNAL(clicked(bool)), &irCtrl, SLOT(sendCmd4(bool)));
48     connect(buttons[5], SIGNAL(clicked(bool)), &irCtrl, SLOT(sendCmd5(bool)));
49
50     this->setContentsMargins(0, 0, 0, 0);
51     layout->setContentsMargins(0, 0, 0, 0);
52     this->setLayout(layout);
53     this->setAttribute(Qt::WA_TranslucentBackground);
54 }
55
56  void MainWidget::paintEvent(QPaintEvent *event)
57  {
58      QPainter p(this);
59      p.setBrush(QColor(0, 0, 0, 128));
60      p.setPen(Qt::NoPen);
61      p.drawRoundRect(rect(), 0, 0);
62      p.end();
63  }
64  
65 void MainWidget::showSettingsDialog()
66 {
67     SettingsDlg dlg(this);
68     if (dlg.exec() == QDialog::Accepted)
69     {
70         irCtrl.setRemoteName(dlg.getRemoteName());
71     }
72 }
73
74