SettingsDlg implementation
[irwi] / src / mainwidget.cpp
index 76c6231..3c9207b 100644 (file)
@@ -1,4 +1,5 @@
 #include "mainwidget.h"
+#include "settingsdlg.h"
 
 #include <QInputDialog>
 #include <QPainter>
@@ -6,8 +7,6 @@
 #include <QToolButton>
 #include <QSettings>
 
-#include "settingsdlg.h"
-
 MainWidget::MainWidget (QWidget *parent)
     : QWidget(parent)
 {
@@ -31,21 +30,23 @@ MainWidget::MainWidget (QWidget *parent)
             settings->value(QString("buttonIcon") + QString::number(i),
                 iconNames[i]).toString()))); 
         buttons[i] = button;
+        button->setSizePolicy(QSizePolicy::MinimumExpanding,
+                QSizePolicy::MinimumExpanding);
         layout->addWidget(button, i%2, i/2);
     }
 
-    connect(buttons[0], SIGNAL(clicked()), &irCtrl, SLOT(sendCmd0()));
-    connect(buttons[1], SIGNAL(clicked()), &irCtrl, SLOT(sendCmd1()));
-    connect(buttons[2], SIGNAL(clicked()), &irCtrl, SLOT(sendCmd2()));
-    connect(buttons[3], SIGNAL(clicked()), &irCtrl, SLOT(sendCmd3()));
-    connect(buttons[4], SIGNAL(clicked()), &irCtrl, SLOT(sendCmd4()));
-    connect(buttons[5], SIGNAL(clicked()), &irCtrl, SLOT(sendCmd5()));
-
+    connect(buttons[0], SIGNAL(clicked()),
+            this, SLOT(sendCmdClicked(IRemote::VOLUMEUP)));
+   
     this->setContentsMargins(0, 0, 0, 0);
     layout->setContentsMargins(0, 0, 0, 0);
     this->setLayout(layout);
     this->setAttribute(Qt::WA_TranslucentBackground);
     this->setAttribute(Qt::WA_OpaquePaintEvent);
+    resize();
+
+
+    showSettingsDialog();
 }
 
 MainWidget::~MainWidget()
@@ -57,18 +58,27 @@ void MainWidget::paintEvent(QPaintEvent*)
 {
     int bgAlpha = settings->value("bgAlpha", "192").toInt();
     QPainter p(this);
-    p.setBrush(QColor(0, 0, 0, bgAlpha));
-    p.setPen(Qt::NoPen);
-    p.drawRect(rect());
+    p.fillRect(rect(), QColor(0, 0, 0, bgAlpha));
     p.end();
 }
  
 void MainWidget::showSettingsDialog()
 {
-    SettingsDlg dlg;
+    SettingsDlg dlg(this);
     dlg.exec();
     update(); // Repaint required if bgAlpha value was changed
+    resize();
 }
 
+void MainWidget::resize()
+{
+    int w = settings->value("width", "250").toInt();
+    int h = settings->value("height", "148").toInt();
+    if (w < 1)
+        w = 250;
+    if (h < 1)
+        h = 148;
+    QWidget::resize(w, h);
+}