#include <QInputDialog>
#include <QPainter>
#include <QGridLayout>
-#include <QPushButton>
+#include <QToolButton>
+#include <QSettings>
#include "settingsdlg.h"
{
layout = new QGridLayout(this);
+ settings = new QSettings(this);
+
+ char iconNames[][128] = {
+ "/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"
+ };
+
for (int i = 0; i < BUTTON_COUNT; ++i)
{
- QPushButton *button = new QPushButton(QString(i+0x30), this);
+ QToolButton *button = new QToolButton(this);
+ button->setIcon(QIcon(QString(
+ settings->value(QString("buttonIcon") + QString::number(i),
+ iconNames[i]).toString())));
buttons[i] = button;
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)));
+ 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()));
+ 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);
+}
+
+MainWidget::~MainWidget()
+{
+ delete settings;
}
- void MainWidget::paintEvent(QPaintEvent *event)
- {
- QPainter p(this);
- p.setBrush(QColor(0, 0, 0, 128));
- p.setPen(Qt::NoPen);
- p.drawRoundRect(rect(), 10, 20);
- p.end();
- }
+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.end();
+}
void MainWidget::showSettingsDialog()
{
- SettingsDlg dlg(this);
- if (dlg.exec() == QDialog::Accepted)
- {
- irCtrl.setRemoteName(dlg.getRemoteName());
- }
+ SettingsDlg dlg;
+ dlg.exec();
+ update(); // Repaint required if bgAlpha value was changed
}
+