#include "mainwidget.h"
+#include "settingsdlg.h"
#include <QInputDialog>
#include <QPainter>
#include <QToolButton>
#include <QSettings>
-#include "settingsdlg.h"
-
MainWidget::MainWidget (QWidget *parent)
: QWidget(parent)
{
"/usr/share/icons/hicolor/48x48/hildon/statusarea_volume_mute.png"
};
- for (int i = 0; i < BUTTON_COUNT; ++i)
- {
+ for (int i = 0; i < BUTTON_COUNT; ++i) {
QToolButton *button = new QToolButton(this);
button->setIcon(QIcon(QString(
settings->value(QString("buttonIcon") + QString::number(i),
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(sendCmdVolUp()));
+ connect(buttons[1], SIGNAL(clicked()), this, SLOT(sendCmdVolDown()));
+ connect(buttons[2], SIGNAL(clicked()), this, SLOT(sendCmdChUp()));
+ connect(buttons[3], SIGNAL(clicked()), this, SLOT(sendCmdChDown()));
+ connect(buttons[4], SIGNAL(clicked()), this, SLOT(sendCmdPower()));
+ connect(buttons[5], SIGNAL(clicked()), this, SLOT(sendCmdMute()));
- this->setContentsMargins(0, 0, 0, 0);
+ setContentsMargins(0, 0, 0, 0);
layout->setContentsMargins(0, 0, 0, 0);
- this->setLayout(layout);
- this->setAttribute(Qt::WA_TranslucentBackground);
- this->setAttribute(Qt::WA_OpaquePaintEvent);
+ setLayout(layout);
+ setAttribute(Qt::WA_TranslucentBackground);
+ setAttribute(Qt::WA_OpaquePaintEvent);
resize();
}
delete settings;
}
+void MainWidget::sendCmdVolUp()
+{
+ irCtrl.sendCmd(settings->value("volUpCmd", "VOLUP").toString());
+}
+
+void MainWidget::sendCmdVolDown()
+{
+ irCtrl.sendCmd(settings->value("volDownCmd", "VOLDOWN").toString());
+}
+
+void MainWidget::sendCmdChUp()
+{
+ irCtrl.sendCmd(settings->value("chUpCmd", "CHUP").toString());
+}
+
+void MainWidget::sendCmdChDown()
+{
+ irCtrl.sendCmd(settings->value("chDownCmd", "CHDOWN").toString());
+}
+
+void MainWidget::sendCmdPower()
+{
+ irCtrl.sendCmd(settings->value("powerCmd", "POWER").toString());
+}
+
+void MainWidget::sendCmdMute()
+{
+ irCtrl.sendCmd(settings->value("muteCmd", "MUTE").toString());
+}
+
void MainWidget::paintEvent(QPaintEvent*)
{
int bgAlpha = settings->value("bgAlpha", "192").toInt();
void MainWidget::showSettingsDialog()
{
- SettingsDlg dlg;
+ SettingsDlg dlg(this);
dlg.exec();
update(); // Repaint required if bgAlpha value was changed
resize();
void MainWidget::resize()
{
- QWidget::resize(settings->value("width", "250").toInt(),
- settings->value("height", "148").toInt());
+ 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);
}
+