Changed PushButtons to ToolButtons
[irwi] / src / mainwidget.cpp
1 #include "mainwidget.h"
2
3 #include <QInputDialog>
4 #include <QPainter>
5 #include <QGridLayout>
6 #include <QToolButton>
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         QToolButton *button = new QToolButton(this);
36         button->setIcon(QIcon(QString(iconNames[i]))); 
37         buttons[i] = button;
38         layout->addWidget(button, i%2, i/2);
39     }
40
41     connect(buttons[0], SIGNAL(clicked(bool)), &irCtrl, SLOT(sendCmd0(bool)));
42     connect(buttons[1], SIGNAL(clicked(bool)), &irCtrl, SLOT(sendCmd1(bool)));
43     connect(buttons[2], SIGNAL(clicked(bool)), &irCtrl, SLOT(sendCmd2(bool)));
44     connect(buttons[3], SIGNAL(clicked(bool)), &irCtrl, SLOT(sendCmd3(bool)));
45     connect(buttons[4], SIGNAL(clicked(bool)), &irCtrl, SLOT(sendCmd4(bool)));
46     connect(buttons[5], SIGNAL(clicked(bool)), &irCtrl, SLOT(sendCmd5(bool)));
47
48     this->setLayout(layout);
49     this->setAttribute(Qt::WA_TranslucentBackground);
50 }
51
52  void MainWidget::paintEvent(QPaintEvent *event)
53  {
54      QPainter p(this);
55      p.setBrush(QColor(0, 0, 0, 128));
56      p.setPen(Qt::NoPen);
57      p.drawRoundRect(rect(), 10, 20);
58      p.end();
59  }
60  
61 void MainWidget::showSettingsDialog()
62 {
63     SettingsDlg dlg(this);
64     if (dlg.exec() == QDialog::Accepted)
65     {
66         irCtrl.setRemoteName(dlg.getRemoteName());
67     }
68 }
69
70