#include <cstdlib>
#include <QSettings>
+#include <QTcpSocket>
+#include <QHostAddress>
#include <QTimer>
#include "irctrl.h"
{
}
-void IrCtrl::sendCmd(const QString &remoteName, const QString &cmd)
+void IrCtrl::sendCmd(const QString &cmd)
{
if (!killLircTimer->isActive()) {
startLirc();
killLircTimer->stop();
}
-// QTcpSocket sock;
-// QSettings settings(this);
-// sock.setSocketOption(QAbstractSocket::LowDelayOption, 1);
-// sock.connectToHost(QHostAddress::LocalHost,
-// settings.value("lircPort", LIRC_PORT).toInt(),
-// QIODevice::WriteOnly|QIODevice::Unbuffered);
-// sock.waitForConnected();
-// QString cmdStr = "SEND_ONCE " + cmd.remoteName + " " + cmd.cmd + "\n";
-// sock.write(cmdStr.toAscii());
-// sock.waitForBytesWritten();
-// sock.close();
+ QTcpSocket sock;
+ QSettings settings(this);
+ sock.setSocketOption(QAbstractSocket::LowDelayOption, 1);
+ sock.connectToHost(QHostAddress::LocalHost,
+ settings.value("lircPort", LIRC_PORT).toInt(),
+ QIODevice::WriteOnly | QIODevice::Unbuffered);
+ sock.waitForConnected();
+ QString remoteName = settings.value("remoteName", "").toString();
+ QString cmdStr = "SEND_ONCE " + remoteName + " " + cmd + "\n";
+ sock.write(cmdStr.toAscii());
+ sock.waitForBytesWritten();
+ sock.close();
killLircTimer->start();
}
"/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);
}
- this->setContentsMargins(0, 0, 0, 0);
+ 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()));
+
+ 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();
-
- showSettingsDialog();
}
MainWidget::~MainWidget()
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();
m_remoteNameLayout = new QHBoxLayout(this);
m_advSettingsBtn = new QPushButton(tr("Advanced"), this);
- m_selectRemoteBtn = new QPushButton(tr("Select m_remote"), this);
+ m_selectRemoteBtn = new QPushButton(tr("Select remote"), this);
m_aboutBtn = new QPushButton(tr("About"), this);
m_rateUpBtn = new QPushButton(
QIcon(settings.value("rateUpIcon",
m_remoteNameLabel = new QLabel(this);
m_ratingLabel = new QLabel(this);
+ m_ratingLabel->setText(tr("Rating"));
m_remoteNameLayout->addWidget(m_remoteNameLabel);
m_remoteNameLayout->addWidget(m_ratingLabel);
m_remoteNameLayout->addWidget(m_rateUpBtn);
SelectRemoteDlg dlg(this);
connect(&dlg, SIGNAL(m_remoteChanged(Remote)),
this, SLOT(setRemote(Remote)));
+ updateRemoteInfo();
dlg.exec();
}
void SettingsDlg::setRemote(Remote r)
{
m_remote = r;
- updateRemoteInfo();
enableRateBtns();
}