1 #include "settingsdlg.h"
2 #include "advsettingsdlg.h"
3 #include "selectremotedlg.h"
11 #include <QPushButton>
15 SettingsDlg::SettingsDlg(QWidget *parent)
19 layout = new QVBoxLayout(this);
20 btnLayout = new QHBoxLayout(this);
21 remoteNameLayout = new QHBoxLayout(this);
23 advSettingsBtn = new QPushButton(tr("Advanced"), this);
24 selectRemoteBtn = new QPushButton(tr("Select remote"), this);
25 aboutBtn = new QPushButton(tr("About"), this);
26 rateUpBtn = new QPushButton(
27 QIcon(settings.value("rateUpIcon",
28 "/usr/share/icons/hicolor/48x48/hildon/chat_smiley_happy.png").
31 rateDownBtn = new QPushButton(
32 QIcon(settings.value("rateDownIcon",
33 "/usr/share/icons/hicolor/48x48/hildon/chat_smiley_sad.png").
36 rateUpBtn->setMaximumSize(72, 72);
37 rateDownBtn->setMaximumSize(72, 72);
39 btnLayout->addWidget(advSettingsBtn);
40 btnLayout->addWidget(selectRemoteBtn);
41 btnLayout->addWidget(aboutBtn);
43 remoteNameLabel = new QLabel(this);
44 ratingLabel = new QLabel(this);
45 remoteNameLayout->addWidget(remoteNameLabel);
46 remoteNameLayout->addWidget(ratingLabel);
47 remoteNameLayout->addWidget(rateUpBtn);
48 remoteNameLayout->addWidget(rateDownBtn);
50 connect(advSettingsBtn, SIGNAL(clicked()),
51 this, SLOT(showAdvSettingsDlg()));
52 connect(selectRemoteBtn, SIGNAL(clicked()),
53 this, SLOT(showSelectRemoteDlg()));
54 connect(aboutBtn, SIGNAL(clicked()),
55 this, SLOT(showAboutDlg()));
56 connect(rateUpBtn, SIGNAL(clicked()),
57 this, SLOT(rateUpClicked()));
58 connect(rateDownBtn, SIGNAL(clicked()),
59 this, SLOT(rateDownClicked()));
61 layout->addLayout(remoteNameLayout);
62 layout->addLayout(btnLayout);
63 this->setLayout(layout);
68 SettingsDlg::~SettingsDlg()
70 delete advSettingsBtn;
71 delete selectRemoteBtn;
75 delete remoteNameLabel;
78 delete remoteNameLayout;
85 void SettingsDlg::showAdvSettingsDlg()
87 AdvSettingsDlg dlg(this);
91 void SettingsDlg::showSelectRemoteDlg()
93 SelectRemoteDlg dlg(this);
98 void SettingsDlg::showAboutDlg()
104 void SettingsDlg::changeRemote()
106 QString selectedRemote = settings.value("remoteName", "").toString();
107 if (selectedRemote == "") {
108 remoteNameLabel->setText("No remote selected");
109 enableRateBtns(false);
114 remote = new Remote(selectedRemote);
115 connect(remote, SIGNAL(infoUpdated()),
116 this, SLOT(updateRemoteInfo()));
117 remote->updateInfo();
122 void SettingsDlg::updateRemoteInfo()
124 remoteNameLabel->setText(remote->mfg() + " " + remote->name());
125 ratingLabel->setText(tr("Rating") + ": " + remote->rating());
128 void SettingsDlg::rateUpClicked()
130 remote->sendRating(Rating::Up);
131 enableRateBtns(false);
134 void SettingsDlg::rateDownClicked()
136 remote->sendRating(Rating::Down);
137 enableRateBtns(false);
140 void SettingsDlg::enableRateBtns(bool enable)
142 rateUpBtn->setEnabled(enable);
143 rateDownBtn->setEnabled(enable);