1 #include "settingsdlg.h"
2 #include "advsettingsdlg.h"
3 #include "selectremotedlg.h"
10 #include <QPushButton>
14 SettingsDlg::SettingsDlg(QWidget *parent)
17 QSettings settings(this);
18 m_layout = new QVBoxLayout(this);
19 m_btnLayout = new QHBoxLayout(this);
20 m_remoteNameLayout = new QHBoxLayout(this);
22 m_advSettingsBtn = new QPushButton(tr("Advanced"), this);
23 m_selectRemoteBtn = new QPushButton(tr("Select remote"), this);
24 m_aboutBtn = new QPushButton(tr("About"), this);
25 m_rateUpBtn = new QPushButton(
26 QIcon(settings.value("rateUpIcon",
27 "/usr/share/icons/hicolor/48x48/hildon/chat_smiley_happy.png").
30 m_rateDownBtn = new QPushButton(
31 QIcon(settings.value("rateDownIcon",
32 "/usr/share/icons/hicolor/48x48/hildon/chat_smiley_sad.png").
35 m_rateUpBtn->setMaximumSize(72, 72);
36 m_rateDownBtn->setMaximumSize(72, 72);
38 m_btnLayout->addWidget(m_advSettingsBtn);
39 m_btnLayout->addWidget(m_selectRemoteBtn);
40 m_btnLayout->addWidget(m_aboutBtn);
42 m_remoteNameLabel = new QLabel(this);
43 m_ratingLabel = new QLabel(this);
44 m_ratingLabel->setText(tr("Rating"));
45 m_remoteNameLayout->addWidget(m_remoteNameLabel);
46 m_remoteNameLayout->addWidget(m_ratingLabel);
47 m_remoteNameLayout->addWidget(m_rateUpBtn);
48 m_remoteNameLayout->addWidget(m_rateDownBtn);
50 connect(m_advSettingsBtn, SIGNAL(clicked()),
51 this, SLOT(showAdvSettingsDlg()));
52 connect(m_selectRemoteBtn, SIGNAL(clicked()),
53 this, SLOT(showSelectRemoteDlg()));
54 connect(m_aboutBtn, SIGNAL(clicked()),
55 this, SLOT(showAboutDlg()));
56 connect(m_rateUpBtn, SIGNAL(clicked()),
57 this, SLOT(rateUpClicked()));
58 connect(m_rateDownBtn, SIGNAL(clicked()),
59 this, SLOT(rateDownClicked()));
61 m_layout->addLayout(m_remoteNameLayout);
62 m_layout->addLayout(m_btnLayout);
63 this->setLayout(m_layout);
68 SettingsDlg::~SettingsDlg()
70 delete m_advSettingsBtn;
71 delete m_selectRemoteBtn;
75 delete m_remoteNameLabel;
78 delete m_remoteNameLayout;
82 void SettingsDlg::showAdvSettingsDlg()
84 AdvSettingsDlg dlg(this);
88 void SettingsDlg::showSelectRemoteDlg()
90 SelectRemoteDlg dlg(this);
91 connect(&dlg, SIGNAL(m_remoteChanged(Remote)),
92 this, SLOT(setRemote(Remote)));
97 void SettingsDlg::showAboutDlg()
103 void SettingsDlg::initRemote()
105 QString selectedRemote = QSettings(this).value("remoteName", "").toString();
106 if (selectedRemote == "") {
107 m_remoteNameLabel->setText("No remote selected");
108 enableRateBtns(false);
110 m_remote = Remote(selectedRemote);
111 connect(&m_remote, SIGNAL(infoUpdated()),
112 this, SLOT(updateRemoteInfo()));
113 m_remote.updateInfo();
118 void SettingsDlg::setRemote(Remote r)
124 void SettingsDlg::updateRemoteInfo()
126 m_remoteNameLabel->setText(m_remote.mfg() + " " + m_remote.name());
127 m_ratingLabel->setText(tr("Rating") + ": "
128 + QString::number(m_remote.rating()));
131 void SettingsDlg::rateUpClicked()
133 m_remote.sendRating(Rating::Up);
134 enableRateBtns(false);
137 void SettingsDlg::rateDownClicked()
139 m_remote.sendRating(Rating::Down);
140 enableRateBtns(false);
143 void SettingsDlg::enableRateBtns(bool enable)
145 m_rateUpBtn->setEnabled(enable);
146 m_rateDownBtn->setEnabled(enable);