Removed borders.
[irwi] / src / mainwidget.cpp
index dde4a7b..7f909ea 100644 (file)
@@ -1,30 +1,74 @@
 #include "mainwidget.h"
 
-#include <QtGui/qinputdialog.h>
+#include <QInputDialog>
+#include <QPainter>
 #include <QGridLayout>
 #include <QPushButton>
 
+#include "settingsdlg.h"
+
 MainWidget::MainWidget (QWidget *parent)
     : QWidget(parent)
 {
     layout = new QGridLayout(this);
 
+    char *iconNames[] = {
+        "/usr/share/icons/hicolor/48x48/hildon/statusarea_volumelevel4.png",
+        "/usr/share/icons/hicolor/48x48/hildon/statusarea_volumelevel1.png",
+        "/usr/share/icons/hicolor/48x48/hildon/rss_reader_move_up.png",
+        "/usr/share/icons/hicolor/48x48/hildon/rss_reader_move_down.png",
+        "/usr/share/icons/hicolor/48x48/hildon/location_applet_on.png",
+        "/usr/share/icons/hicolor/48x48/hildon/statusarea_volume_mute.png"
+    };
+
+    char *buttonTitles[] = {
+        "Vol Up",
+        "Vol Down",
+        "Ch Up",
+        "Ch Down",
+        "Power Off",
+        "Mute"
+    };
+
     for (int i = 0; i < BUTTON_COUNT; ++i)
     {
-        buttons[i] = new QPushButton(this);
-        layout->addWidget(buttons[i], i/3, i%3);
+        QPushButton *button = new QPushButton(
+                QIcon(QString(iconNames[i])), 
+                QString(buttonTitles[i]), this);
+        buttons[i] = button;
+        button->setPalette(QPalette(QColor(0, 0, 0, 192)));
+        layout->addWidget(button, i%2, i/2);
     }
+
+    connect(buttons[0], SIGNAL(clicked(bool)), &irCtrl, SLOT(sendCmd0(bool)));
+    connect(buttons[1], SIGNAL(clicked(bool)), &irCtrl, SLOT(sendCmd1(bool)));
+    connect(buttons[2], SIGNAL(clicked(bool)), &irCtrl, SLOT(sendCmd2(bool)));
+    connect(buttons[3], SIGNAL(clicked(bool)), &irCtrl, SLOT(sendCmd3(bool)));
+    connect(buttons[4], SIGNAL(clicked(bool)), &irCtrl, SLOT(sendCmd4(bool)));
+    connect(buttons[5], SIGNAL(clicked(bool)), &irCtrl, SLOT(sendCmd5(bool)));
+
+    this->setContentsMargins(0, 0, 0, 0);
+    layout->setContentsMargins(0, 0, 0, 0);
     this->setLayout(layout);
+    this->setAttribute(Qt::WA_TranslucentBackground);
 }
 
+ void MainWidget::paintEvent(QPaintEvent *event)
+ {
+     QPainter p(this);
+     p.setBrush(QColor(0, 0, 0, 128));
+     p.setPen(Qt::NoPen);
+     p.drawRoundRect(rect(), 0, 0);
+     p.end();
+ }
 void MainWidget::showSettingsDialog()
 {
-    bool isOk;
-    QString newText = QInputDialog::getText(this, tr("New Text"),
-            tr("Please enter a new text:"), QLineEdit::Normal,
-            "foo", &isOk);
-//    if (isOk)
-//        setText(newText);
+    SettingsDlg dlg(this);
+    if (dlg.exec() == QDialog::Accepted)
+    {
+        irCtrl.setRemoteName(dlg.getRemoteName());
+    }
 }