1 #include "settingsdlg.h"
2 #include "advsettingsdlg.h"
3 #include "selectremotedlg.h"
11 #include <QPushButton>
16 SettingsDlg::SettingsDlg(QWidget *parent)
20 QSettings settings(this);
22 layout = new QVBoxLayout(this);
23 btnLayout = new QHBoxLayout(this);
24 remoteNameLayout = new QHBoxLayout(this);
26 advSettingsBtn = new QPushButton(tr("Advanced"), this);
27 selectRemoteBtn = new QPushButton(tr("Select remote"), this);
28 aboutBtn = new QPushButton(tr("About"), this);
29 rateUpBtn = new QPushButton(
30 QIcon(settings.value("rateUpIcon",
31 "/usr/share/icons/hicolor/48x48/hildon/chat_smiley_happy.png").
34 rateDownBtn = new QPushButton(
35 QIcon(settings.value("rateDownIcon",
36 "/usr/share/icons/hicolor/48x48/hildon/chat_smiley_sad.png").
39 rateUpBtn->setMaximumSize(72, 72);
40 rateDownBtn->setMaximumSize(72, 72);
42 btnLayout->addWidget(advSettingsBtn);
43 btnLayout->addWidget(selectRemoteBtn);
44 btnLayout->addWidget(aboutBtn);
46 remoteNameLabel = new QLabel(this);
47 ratingLabel = new QLabel(this);
48 remoteNameLayout->addWidget(remoteNameLabel);
49 remoteNameLayout->addWidget(ratingLabel);
50 remoteNameLayout->addWidget(rateUpBtn);
51 remoteNameLayout->addWidget(rateDownBtn);
53 connect(advSettingsBtn, SIGNAL(clicked()),
54 this, SLOT(showAdvSettingsDlg()));
55 connect(selectRemoteBtn, SIGNAL(clicked()),
56 this, SLOT(showSelectRemoteDlg()));
57 connect(aboutBtn, SIGNAL(clicked()),
58 this, SLOT(showAboutDlg()));
59 connect(rateUpBtn, SIGNAL(clicked()),
60 this, SLOT(rateUpClicked()));
61 connect(rateDownBtn, SIGNAL(clicked()),
62 this, SLOT(rateDownClicked()));
64 QString selectedRemote = settings.value("remoteName", "").toString();
65 if (selectedRemote == "")
67 remoteNameLabel->setText(tr("No remote selected"));
68 enableRateBtns(false);
72 changeRemote(selectedRemote);
75 layout->addLayout(remoteNameLayout);
76 layout->addLayout(btnLayout);
77 this->setLayout(layout);
80 SettingsDlg::~SettingsDlg()
84 delete remoteNameLayout;
85 delete advSettingsBtn;
86 delete selectRemoteBtn;
90 delete remoteNameLabel;
98 void SettingsDlg::showAdvSettingsDlg()
100 AdvSettingsDlg dlg(this);
104 void SettingsDlg::showSelectRemoteDlg()
106 SelectRemoteDlg dlg(this);
107 connect(&dlg, SIGNAL(remoteChanged(QString)),
108 this, SLOT(updateRemoteInfo(QString)));
112 void SettingsDlg::showAboutDlg()
118 void SettingsDlg::changeRemote(const QString &name)
124 remote = new Remote(name);
125 connect(remote, SIGNAL(infoUpdated()),
126 this, SLOT(updateRemoteInfo()));
127 remote->updateInfo();
131 void SettingsDlg::updateRemoteInfo()
133 remoteNameLabel->setText(remote->mfg() + " " + remote->name());
134 ratingLabel->setText(tr("Rating") + ": " + remote->rating());
137 void SettingsDlg::rateUpClicked()
139 remote->sendRating(Rating::Up);
140 enableRateBtns(false);
143 void SettingsDlg::rateDownClicked()
145 remote->sendRating(Rating::Down);
146 enableRateBtns(false);
149 void SettingsDlg::enableRateBtns(bool enable)
151 rateUpBtn->setEnabled(enable);
152 rateDownBtn->setEnabled(enable);