Added icons for buttons
[irwi] / src / mainwidget.cpp
1 #include "mainwidget.h"
2
3 #include <QtGui/qinputdialog.h>
4 #include <QGridLayout>
5 #include <QPushButton>
6
7 #include "settingsdlg.h"
8
9 MainWidget::MainWidget (QWidget *parent)
10     : QWidget(parent)
11 {
12     layout = new QGridLayout(this);
13
14     char *iconNames[] = {
15         "/usr/share/icons/hicolor/48x48/hildon/statusarea_volumelevel1.png",
16         "/usr/share/icons/hicolor/48x48/hildon/statusarea_volumelevel3.png",
17         "/usr/share/icons/hicolor/48x48/hildon/rss_move_up.png",
18         "/usr/share/icons/hicolor/48x48/hildon/rss_move_down.png",
19         "/usr/share/icons/hicolor/48x48/hildon/location_applet_on.png",
20         "/usr/share/icons/hicolor/48x48/hildon/statusarea_volume_mute.png"
21     };
22
23     char *buttonTitles = {
24         "Vol Up",
25         "Vol Down",
26         "Ch Up",
27         "Ch Down",
28         "Power Off",
29         "Mute"
30     };
31
32     for (int i = 0; i < BUTTON_COUNT; ++i)
33     {
34         QPushButton *button = new QPushButton(
35                 QIcon(QString(iconNames[i])), 
36                 QString(buttonTitles[i]), this);
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 }
50
51 void MainWidget::showSettingsDialog()
52 {
53     SettingsDlg dlg(this);
54     if (dlg.exec() == QDialog::Accepted)
55     {
56         irCtrl.setRemoteName(dlg.getRemoteName());
57     }
58 }
59
60