2 * SomePlayer - An alternate music player for Maemo 5
3 * Copyright (C) 2010 Nikolay (somebody) Tischenko <niktischenko@gmail.com>
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License
7 * as published by the Free Software Foundation; either version 2
8 * of the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 #include "settingsform.h"
22 #include "ui_settingsform.h"
25 #include "someplayer.h"
27 using namespace SomePlayer::Storage;
29 SettingsForm::SettingsForm(QWidget *parent) :
31 ui(new Ui::SettingsForm)
35 QString albumSorting = config.getValue("ui/albumsorting").toString();
36 QString showTrackLenght = config.getValue("ui/showtracklenght").toString();
37 QString orientation = config.getValue("ui/orientation").toString();
38 QString icons_theme = config.getValue("ui/iconstheme").toString();
39 QString gradient = config.getValue("ui/gradient").toString();
40 QString language = config.getValue("ui/language").toString();
41 QString track_color = config.getValue("ui/trackcolor").toString();
42 ui->albumsSortDButton->setChecked(true); // defaule sorting
43 ui->showTrackLenghtYButton->setChecked(true); // show by default
44 ui->orientationLButton->setChecked(true);
45 ui->iconsWButton->setChecked(true);
46 ui->gradientYButton->setChecked(true);
47 ui->engLangButton->setChecked(true);
48 ui->cBlueButton->setChecked(true);
49 if (albumSorting == "alphabet") {
50 ui->albumsSortAButton->setChecked(true);
52 if (showTrackLenght == "no") {
53 ui->showTrackLenghtNButton->setChecked(true);
55 if (orientation == "portrait") {
56 ui->orientationPButton->setChecked(true);
57 } else if (orientation == "auto") {
58 ui->orientationAButton->setChecked(true);
60 if (icons_theme == "black") {
61 ui->iconstBButton->setChecked(true);
63 if (gradient == "no") {
64 ui->gradientNButton->setChecked(true);
66 if (language == "ru") {
67 ui->ruLangButton->setChecked(true);
69 if (track_color == "black") {
70 ui->cBlackButton->setChecked(true);
71 } else if (track_color == "magenta") {
72 ui->cMagentaButton->setChecked(true);
73 } else if (track_color == "Red") {
74 ui->cRedButton->setChecked(true);
75 } else if (track_color == "yellow") {
76 ui->cYellowButton->setChecked(true);
77 } else if (track_color == "white") {
78 ui->cWhiteButton->setChecked(true);
79 } else if (track_color == "dark") {
80 ui->cDarkButton->setChecked(true);
81 } else if (track_color == "light") {
82 ui->cLightButton->setChecked(true);
84 if (!QFile::exists(QString(_APPLICATION_PATH_)+"/someplayer_ru.qm")) {
86 } // refactor this when more translations will be added
87 connect (ui->albumsSortAButton, SIGNAL(toggled(bool)), this, SLOT(_set_album_sorting_alphabet(bool)));
88 connect (ui->albumsSortDButton, SIGNAL(toggled(bool)), this, SLOT(_set_album_sorting_date(bool)));
89 connect (ui->showTrackLenghtNButton, SIGNAL(toggled(bool)), this, SLOT(_set_track_lenght_show_no(bool)));
90 connect (ui->showTrackLenghtYButton, SIGNAL(toggled(bool)), this, SLOT(_set_track_lenght_show_yes(bool)));
91 connect (ui->orientationAButton, SIGNAL(toggled(bool)), this, SLOT(_set_orientation_auto(bool)));
92 connect (ui->orientationLButton, SIGNAL(toggled(bool)), this, SLOT(_set_orientation_landscape(bool)));
93 connect (ui->orientationPButton, SIGNAL(toggled(bool)), this, SLOT(_set_orientation_portrait(bool)));
94 connect (ui->iconstBButton, SIGNAL(toggled(bool)), this, SLOT(_set_icons_black(bool)));
95 connect (ui->iconsWButton, SIGNAL(toggled(bool)), this, SLOT(_set_icons_white(bool)));
96 connect (ui->gradientNButton, SIGNAL(toggled(bool)), this, SLOT(_set_gradient_no(bool)));
97 connect (ui->gradientYButton, SIGNAL(toggled(bool)), this, SLOT(_set_gradient_yes(bool)));
98 connect (ui->engLangButton, SIGNAL(toggled(bool)), this, SLOT(_set_lang_en(bool)));
99 connect (ui->ruLangButton, SIGNAL(toggled(bool)), this, SLOT(_set_lang_ru(bool)));
100 connect (ui->cBlackButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_black(bool)));
101 connect (ui->cBlueButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_blue(bool)));
102 connect (ui->cDarkButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_dark(bool)));
103 connect (ui->cLightButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_light(bool)));
104 connect (ui->cMagentaButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_magenta(bool)));
105 connect (ui->cRedButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_red(bool)));
106 connect (ui->cWhiteButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_white(bool)));
107 connect (ui->cYellowButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_yellow(bool)));
108 setAttribute(Qt::WA_Maemo5StackedWindow);
109 setWindowFlags(Qt::Window | windowFlags());
112 SettingsForm::~SettingsForm()
117 void SettingsForm::_set_album_sorting_date(bool checked) {
118 if (!checked) return;
120 config.setValue("ui/albumsorting", "date");
121 emit libraryOptionsChanged();
124 void SettingsForm::_set_album_sorting_alphabet(bool checked) {
125 if (!checked) return;
127 config.setValue("ui/albumsorting", "alphabet");
128 emit libraryOptionsChanged();
131 void SettingsForm::_set_track_lenght_show_no(bool checked) {
132 if (!checked) return;
134 config.setValue("ui/showtracklenght", "no");
135 emit libraryOptionsChanged();
138 void SettingsForm::_set_track_lenght_show_yes(bool checked) {
139 if (!checked) return;
141 config.setValue("ui/showtracklenght", "yes");
142 emit libraryOptionsChanged();
145 void SettingsForm::_set_orientation_auto(bool checked) {
146 if (!checked) return;
148 config.setValue("ui/orientation", "auto");
149 emit orientationChanged();
152 void SettingsForm::_set_orientation_landscape(bool checked) {
153 if (!checked) return;
155 config.setValue("ui/orientation", "landscape");
156 emit orientationChanged();
159 void SettingsForm::_set_orientation_portrait(bool checked) {
160 if (!checked) return;
162 config.setValue("ui/orientation", "portrait");
163 emit orientationChanged();
166 void SettingsForm::_set_icons_black(bool checked) {
167 if (!checked) return;
169 config.setValue("ui/iconstheme", "black");
173 void SettingsForm::_set_icons_white(bool checked) {
174 if (!checked) return;
176 config.setValue("ui/iconstheme", "white");
180 void SettingsForm::_set_gradient_no(bool checked) {
181 if (!checked) return;
183 config.setValue("ui/gradient", "no");
184 emit gradientChanged();
187 void SettingsForm::_set_gradient_yes(bool checked) {
188 if (!checked) return;
190 config.setValue("ui/gradient", "yes");
191 emit gradientChanged();
194 void SettingsForm::_set_color_black(bool checked) {
195 if (!checked) return;
197 config.setValue("ui/trackcolor", "black");
198 emit trackColorChanged();
201 void SettingsForm::_set_color_blue(bool checked) {
202 if (!checked) return;
204 config.setValue("ui/trackcolor", "blue");
205 emit trackColorChanged();
208 void SettingsForm::_set_color_dark(bool checked) {
209 if (!checked) return;
211 config.setValue("ui/trackcolor", "dark");
212 emit trackColorChanged();
215 void SettingsForm::_set_color_light(bool checked) {
216 if (!checked) return;
218 config.setValue("ui/trackcolor", "light");
219 emit trackColorChanged();
222 void SettingsForm::_set_color_magenta(bool checked) {
223 if (!checked) return;
225 config.setValue("ui/trackcolor", "magenta");
226 emit trackColorChanged();
229 void SettingsForm::_set_color_red(bool checked) {
230 if (!checked) return;
232 config.setValue("ui/trackcolor", "red");
233 emit trackColorChanged();
236 void SettingsForm::_set_color_white(bool checked) {
237 if (!checked) return;
239 config.setValue("ui/trackcolor", "white");
240 emit trackColorChanged();
243 void SettingsForm::_set_color_yellow(bool checked) {
244 if (!checked) return;
246 config.setValue("ui/trackcolor", "yellow");
247 emit trackColorChanged();
250 void SettingsForm::_set_lang_en(bool checked) {
251 if (!checked) return;
253 config.setValue("ui/language", "en");
254 emit translationChanged();
257 void SettingsForm::_set_lang_ru(bool checked) {
258 if (!checked) return;
260 config.setValue("ui/language", "ru");
261 emit translationChanged();
264 void SettingsForm::updateTranslations() {
265 ui->retranslateUi(this);
268 void SettingsForm::landscapeMode() {
269 ui->cButtonsLayout->removeWidget(ui->cBlueButton);
270 ui->cButtonsLayout->removeWidget(ui->cMagentaButton);
271 ui->cButtonsLayout->removeWidget(ui->cRedButton);
272 ui->cButtonsLayout->removeWidget(ui->cYellowButton);
273 ui->cButtonsLayout->removeWidget(ui->cWhiteButton);
274 ui->cButtonsLayout->removeWidget(ui->cBlackButton);
275 ui->cButtonsLayout->removeWidget(ui->cLightButton);
276 ui->cButtonsLayout->removeWidget(ui->cDarkButton);
277 ui->cButtonsLayout->addWidget(ui->cBlueButton, 0, 0);
278 ui->cButtonsLayout->addWidget(ui->cMagentaButton, 0, 1);
279 ui->cButtonsLayout->addWidget(ui->cRedButton, 0, 2);
280 ui->cButtonsLayout->addWidget(ui->cYellowButton, 0, 3);
281 ui->cButtonsLayout->addWidget(ui->cWhiteButton, 1, 0);
282 ui->cButtonsLayout->addWidget(ui->cBlackButton, 1, 1);
283 ui->cButtonsLayout->addWidget(ui->cLightButton, 1, 2);
284 ui->cButtonsLayout->addWidget(ui->cDarkButton, 1, 3);
286 ui->orientationGridLayout->removeWidget(ui->orientationAButton);
287 ui->orientationGridLayout->removeWidget(ui->orientationLButton);
288 ui->orientationGridLayout->removeWidget(ui->orientationPButton);
289 ui->orientationGridLayout->addWidget(ui->orientationLButton);
290 ui->orientationGridLayout->addWidget(ui->orientationAButton);
291 ui->orientationGridLayout->addWidget(ui->orientationPButton);
294 void SettingsForm::portraitMode() {
295 ui->cButtonsLayout->removeWidget(ui->cBlueButton);
296 ui->cButtonsLayout->removeWidget(ui->cMagentaButton);
297 ui->cButtonsLayout->removeWidget(ui->cRedButton);
298 ui->cButtonsLayout->removeWidget(ui->cYellowButton);
299 ui->cButtonsLayout->removeWidget(ui->cWhiteButton);
300 ui->cButtonsLayout->removeWidget(ui->cBlackButton);
301 ui->cButtonsLayout->removeWidget(ui->cLightButton);
302 ui->cButtonsLayout->removeWidget(ui->cDarkButton);
303 ui->cButtonsLayout->addWidget(ui->cBlueButton, 0, 0);
304 ui->cButtonsLayout->addWidget(ui->cMagentaButton, 0, 1);
305 ui->cButtonsLayout->addWidget(ui->cRedButton, 1, 0);
306 ui->cButtonsLayout->addWidget(ui->cYellowButton, 1, 1);
307 ui->cButtonsLayout->addWidget(ui->cWhiteButton, 2, 0);
308 ui->cButtonsLayout->addWidget(ui->cBlackButton, 2, 1);
309 ui->cButtonsLayout->addWidget(ui->cLightButton, 3, 0);
310 ui->cButtonsLayout->addWidget(ui->cDarkButton, 3, 1);
312 ui->orientationGridLayout->removeWidget(ui->orientationAButton);
313 ui->orientationGridLayout->removeWidget(ui->orientationLButton);
314 ui->orientationGridLayout->removeWidget(ui->orientationPButton);
315 ui->orientationGridLayout->addWidget(ui->orientationLButton, 0, 0);
316 ui->orientationGridLayout->addWidget(ui->orientationAButton, 0, 1);
317 ui->orientationGridLayout->addWidget(ui->orientationPButton, 1, 0, 1, 2);