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 QString selectedRemote = settings.value("remoteName", "").toString();
62 if (selectedRemote == "")
64 remoteNameLabel->setText(tr("No remote selected"));
65 enableRateBtns(false);
72 layout->addLayout(remoteNameLayout);
73 layout->addLayout(btnLayout);
74 this->setLayout(layout);
77 SettingsDlg::~SettingsDlg()
81 delete remoteNameLayout;
82 delete advSettingsBtn;
83 delete selectRemoteBtn;
87 delete remoteNameLabel;
95 void SettingsDlg::showAdvSettingsDlg()
97 AdvSettingsDlg dlg(this);
101 void SettingsDlg::showSelectRemoteDlg()
103 SelectRemoteDlg dlg(this);
108 void SettingsDlg::showAboutDlg()
114 void SettingsDlg::changeRemote()
120 remote = new Remote(settings.value("remoteName", "").toString());
121 connect(remote, SIGNAL(infoUpdated()),
122 this, SLOT(updateRemoteInfo()));
123 remote->updateInfo();
127 void SettingsDlg::updateRemoteInfo()
129 remoteNameLabel->setText(remote->mfg() + " " + remote->name());
130 ratingLabel->setText(tr("Rating") + ": " + remote->rating());
133 void SettingsDlg::rateUpClicked()
135 remote->sendRating(Rating::Up);
136 enableRateBtns(false);
139 void SettingsDlg::rateDownClicked()
141 remote->sendRating(Rating::Down);
142 enableRateBtns(false);
145 void SettingsDlg::enableRateBtns(bool enable)
147 rateUpBtn->setEnabled(enable);
148 rateDownBtn->setEnabled(enable);