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 ui->pauseHPNoButton->setChecked(true);
50 ui->hwKeysBox->setChecked(false);
51 ui->hwkeysLabel->setEnabled(false);
52 ui->hwTControlButton->setEnabled(false);
53 ui->hwVolumeButton->setEnabled(false);
54 if (albumSorting == "alphabet") {
55 ui->albumsSortAButton->setChecked(true);
57 if (showTrackLenght == "no") {
58 ui->showTrackLenghtNButton->setChecked(true);
60 if (orientation == "portrait") {
61 ui->orientationPButton->setChecked(true);
62 } else if (orientation == "auto") {
63 ui->orientationAButton->setChecked(true);
65 if (icons_theme == "black") {
66 ui->iconstBButton->setChecked(true);
68 if (gradient == "no") {
69 ui->gradientNButton->setChecked(true);
71 if (language == "ru") {
72 ui->ruLangButton->setChecked(true);
74 if (track_color == "black") {
75 ui->cBlackButton->setChecked(true);
76 } else if (track_color == "magenta") {
77 ui->cMagentaButton->setChecked(true);
78 } else if (track_color == "Red") {
79 ui->cRedButton->setChecked(true);
80 } else if (track_color == "yellow") {
81 ui->cYellowButton->setChecked(true);
82 } else if (track_color == "white") {
83 ui->cWhiteButton->setChecked(true);
84 } else if (track_color == "dark") {
85 ui->cDarkButton->setChecked(true);
86 } else if (track_color == "light") {
87 ui->cLightButton->setChecked(true);
89 if (config.getValue("hw/hpautopause").toString() == "yes") {
90 ui->pauseHPYesButton->setChecked(true);
92 if (config.getValue("hw/zoomkeys").toString() == "enabled") {
93 ui->hwKeysBox->setChecked(true);
94 ui->hwkeysLabel->setEnabled(true);
95 ui->hwTControlButton->setEnabled(true);
96 ui->hwVolumeButton->setEnabled(true);
98 QString behavior = config.getValue("hw/zoom_action").toString();
99 if (behavior == "volume") {
100 ui->hwVolumeButton->setChecked(true);
101 } else if (behavior == "track") {
102 ui->hwTControlButton->setChecked(true);
104 ui->hwVolumeButton->setChecked(true);
105 config.setValue("hw/zoom_action", "volume");
107 if (!QFile::exists(QString(_APPLICATION_PATH_)+"/someplayer_ru.qm")) {
109 } // refactor this when more translations will be added
110 connect (ui->albumsSortAButton, SIGNAL(toggled(bool)), this, SLOT(_set_album_sorting_alphabet(bool)));
111 connect (ui->albumsSortDButton, SIGNAL(toggled(bool)), this, SLOT(_set_album_sorting_date(bool)));
112 connect (ui->showTrackLenghtNButton, SIGNAL(toggled(bool)), this, SLOT(_set_track_lenght_show_no(bool)));
113 connect (ui->showTrackLenghtYButton, SIGNAL(toggled(bool)), this, SLOT(_set_track_lenght_show_yes(bool)));
114 connect (ui->orientationAButton, SIGNAL(toggled(bool)), this, SLOT(_set_orientation_auto(bool)));
115 connect (ui->orientationLButton, SIGNAL(toggled(bool)), this, SLOT(_set_orientation_landscape(bool)));
116 connect (ui->orientationPButton, SIGNAL(toggled(bool)), this, SLOT(_set_orientation_portrait(bool)));
117 connect (ui->iconstBButton, SIGNAL(toggled(bool)), this, SLOT(_set_icons_black(bool)));
118 connect (ui->iconsWButton, SIGNAL(toggled(bool)), this, SLOT(_set_icons_white(bool)));
119 connect (ui->gradientNButton, SIGNAL(toggled(bool)), this, SLOT(_set_gradient_no(bool)));
120 connect (ui->gradientYButton, SIGNAL(toggled(bool)), this, SLOT(_set_gradient_yes(bool)));
121 connect (ui->engLangButton, SIGNAL(toggled(bool)), this, SLOT(_set_lang_en(bool)));
122 connect (ui->ruLangButton, SIGNAL(toggled(bool)), this, SLOT(_set_lang_ru(bool)));
123 connect (ui->cBlackButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_black(bool)));
124 connect (ui->cBlueButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_blue(bool)));
125 connect (ui->cDarkButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_dark(bool)));
126 connect (ui->cLightButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_light(bool)));
127 connect (ui->cMagentaButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_magenta(bool)));
128 connect (ui->cRedButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_red(bool)));
129 connect (ui->cWhiteButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_white(bool)));
130 connect (ui->cYellowButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_yellow(bool)));
131 connect (ui->pauseHPNoButton, SIGNAL(toggled(bool)), this, SLOT(_set_pause_hp_no(bool)));
132 connect (ui->pauseHPYesButton, SIGNAL(toggled(bool)), this, SLOT(_set_pause_hp_yes(bool)));
133 connect (ui->hwKeysBox, SIGNAL(toggled(bool)), this, SLOT(_toggle_hw_settings(bool)));
134 connect (ui->hwVolumeButton, SIGNAL(toggled(bool)), this, SLOT(_set_hw_volume_control(bool)));
135 connect (ui->hwTControlButton, SIGNAL(toggled(bool)), this, SLOT(_set_hw_track_control(bool)));
136 connect (ui->uiButton, SIGNAL(clicked()), this, SLOT(_toggle_view_ui()));
137 connect (ui->hwButton, SIGNAL(clicked()), this, SLOT(_toggle_view_hw()));
138 connect (ui->libraryButton, SIGNAL(clicked()), this, SLOT(_toggle_view_lib()));
140 setAttribute(Qt::WA_Maemo5StackedWindow);
141 setWindowFlags(Qt::Window | windowFlags());
144 SettingsForm::~SettingsForm()
149 void SettingsForm::_set_album_sorting_date(bool checked) {
150 if (!checked) return;
152 config.setValue("ui/albumsorting", "date");
153 emit libraryOptionsChanged();
156 void SettingsForm::_set_album_sorting_alphabet(bool checked) {
157 if (!checked) return;
159 config.setValue("ui/albumsorting", "alphabet");
160 emit libraryOptionsChanged();
163 void SettingsForm::_set_track_lenght_show_no(bool checked) {
164 if (!checked) return;
166 config.setValue("ui/showtracklenght", "no");
167 emit libraryOptionsChanged();
170 void SettingsForm::_set_track_lenght_show_yes(bool checked) {
171 if (!checked) return;
173 config.setValue("ui/showtracklenght", "yes");
174 emit libraryOptionsChanged();
177 void SettingsForm::_set_orientation_auto(bool checked) {
178 if (!checked) return;
180 config.setValue("ui/orientation", "auto");
181 emit orientationChanged();
184 void SettingsForm::_set_orientation_landscape(bool checked) {
185 if (!checked) return;
187 config.setValue("ui/orientation", "landscape");
188 emit orientationChanged();
191 void SettingsForm::_set_orientation_portrait(bool checked) {
192 if (!checked) return;
194 config.setValue("ui/orientation", "portrait");
195 emit orientationChanged();
198 void SettingsForm::_set_icons_black(bool checked) {
199 if (!checked) return;
201 config.setValue("ui/iconstheme", "black");
205 void SettingsForm::_set_icons_white(bool checked) {
206 if (!checked) return;
208 config.setValue("ui/iconstheme", "white");
212 void SettingsForm::_set_gradient_no(bool checked) {
213 if (!checked) return;
215 config.setValue("ui/gradient", "no");
216 emit gradientChanged();
219 void SettingsForm::_set_gradient_yes(bool checked) {
220 if (!checked) return;
222 config.setValue("ui/gradient", "yes");
223 emit gradientChanged();
226 void SettingsForm::_set_color_black(bool checked) {
227 if (!checked) return;
229 config.setValue("ui/trackcolor", "black");
230 emit trackColorChanged();
233 void SettingsForm::_set_color_blue(bool checked) {
234 if (!checked) return;
236 config.setValue("ui/trackcolor", "blue");
237 emit trackColorChanged();
240 void SettingsForm::_set_color_dark(bool checked) {
241 if (!checked) return;
243 config.setValue("ui/trackcolor", "dark");
244 emit trackColorChanged();
247 void SettingsForm::_set_color_light(bool checked) {
248 if (!checked) return;
250 config.setValue("ui/trackcolor", "light");
251 emit trackColorChanged();
254 void SettingsForm::_set_color_magenta(bool checked) {
255 if (!checked) return;
257 config.setValue("ui/trackcolor", "magenta");
258 emit trackColorChanged();
261 void SettingsForm::_set_color_red(bool checked) {
262 if (!checked) return;
264 config.setValue("ui/trackcolor", "red");
265 emit trackColorChanged();
268 void SettingsForm::_set_color_white(bool checked) {
269 if (!checked) return;
271 config.setValue("ui/trackcolor", "white");
272 emit trackColorChanged();
275 void SettingsForm::_set_color_yellow(bool checked) {
276 if (!checked) return;
278 config.setValue("ui/trackcolor", "yellow");
279 emit trackColorChanged();
282 void SettingsForm::_set_lang_en(bool checked) {
283 if (!checked) return;
285 config.setValue("ui/language", "en");
286 emit translationChanged();
289 void SettingsForm::_set_lang_ru(bool checked) {
290 if (!checked) return;
292 config.setValue("ui/language", "ru");
293 emit translationChanged();
296 void SettingsForm::_set_pause_hp_no(bool checked) {
297 if (!checked) return;
299 config.setValue("hw/hpautopause", "no");
302 void SettingsForm::_set_pause_hp_yes(bool checked) {
303 if (!checked) return;
305 config.setValue("hw/hpautopause", "yes");
308 void SettingsForm::_toggle_hw_settings(bool checked) {
310 config.setValue("hw/zoomkeys", checked ? "enabled" : "disabled");
311 ui->hwkeysLabel->setEnabled(checked);
312 ui->hwTControlButton->setEnabled(checked);
313 ui->hwVolumeButton->setEnabled(checked);
314 emit hwZoomPolicyChanged();
317 void SettingsForm::_set_hw_track_control(bool checked) {
318 if (!checked) return;
320 config.setValue("hw/zoom_action", "track");
323 void SettingsForm::_set_hw_volume_control(bool checked) {
324 if (!checked) return;
326 config.setValue("hw/zoom_action", "volume");
329 void SettingsForm::_toggle_view_ui() {
330 ui->hwButton->setChecked(false);
331 ui->libraryButton->setChecked(false);
332 ui->uiButton->setChecked(true);
333 ui->stackedWidget->setCurrentIndex(0);
336 void SettingsForm::_toggle_view_lib() {
337 ui->hwButton->setChecked(false);
338 ui->uiButton->setChecked(false);
339 ui->libraryButton->setChecked(true);
340 ui->stackedWidget->setCurrentIndex(1);
343 void SettingsForm::_toggle_view_hw() {
344 ui->uiButton->setChecked(false);
345 ui->libraryButton->setChecked(false);
346 ui->hwButton->setChecked(true);
347 ui->stackedWidget->setCurrentIndex(2);
350 void SettingsForm::updateTranslations() {
351 ui->retranslateUi(this);
354 void SettingsForm::landscapeMode() {
355 ui->cButtonsLayout->removeWidget(ui->cBlueButton);
356 ui->cButtonsLayout->removeWidget(ui->cMagentaButton);
357 ui->cButtonsLayout->removeWidget(ui->cRedButton);
358 ui->cButtonsLayout->removeWidget(ui->cYellowButton);
359 ui->cButtonsLayout->removeWidget(ui->cWhiteButton);
360 ui->cButtonsLayout->removeWidget(ui->cBlackButton);
361 ui->cButtonsLayout->removeWidget(ui->cLightButton);
362 ui->cButtonsLayout->removeWidget(ui->cDarkButton);
363 ui->cButtonsLayout->addWidget(ui->cBlueButton, 0, 0);
364 ui->cButtonsLayout->addWidget(ui->cMagentaButton, 0, 1);
365 ui->cButtonsLayout->addWidget(ui->cRedButton, 0, 2);
366 ui->cButtonsLayout->addWidget(ui->cYellowButton, 0, 3);
367 ui->cButtonsLayout->addWidget(ui->cWhiteButton, 1, 0);
368 ui->cButtonsLayout->addWidget(ui->cBlackButton, 1, 1);
369 ui->cButtonsLayout->addWidget(ui->cLightButton, 1, 2);
370 ui->cButtonsLayout->addWidget(ui->cDarkButton, 1, 3);
372 ui->orientationGridLayout->removeWidget(ui->orientationAButton);
373 ui->orientationGridLayout->removeWidget(ui->orientationLButton);
374 ui->orientationGridLayout->removeWidget(ui->orientationPButton);
375 ui->orientationGridLayout->addWidget(ui->orientationLButton);
376 ui->orientationGridLayout->addWidget(ui->orientationAButton);
377 ui->orientationGridLayout->addWidget(ui->orientationPButton);
380 void SettingsForm::portraitMode() {
381 ui->cButtonsLayout->removeWidget(ui->cBlueButton);
382 ui->cButtonsLayout->removeWidget(ui->cMagentaButton);
383 ui->cButtonsLayout->removeWidget(ui->cRedButton);
384 ui->cButtonsLayout->removeWidget(ui->cYellowButton);
385 ui->cButtonsLayout->removeWidget(ui->cWhiteButton);
386 ui->cButtonsLayout->removeWidget(ui->cBlackButton);
387 ui->cButtonsLayout->removeWidget(ui->cLightButton);
388 ui->cButtonsLayout->removeWidget(ui->cDarkButton);
389 ui->cButtonsLayout->addWidget(ui->cBlueButton, 0, 0);
390 ui->cButtonsLayout->addWidget(ui->cMagentaButton, 0, 1);
391 ui->cButtonsLayout->addWidget(ui->cRedButton, 1, 0);
392 ui->cButtonsLayout->addWidget(ui->cYellowButton, 1, 1);
393 ui->cButtonsLayout->addWidget(ui->cWhiteButton, 2, 0);
394 ui->cButtonsLayout->addWidget(ui->cBlackButton, 2, 1);
395 ui->cButtonsLayout->addWidget(ui->cLightButton, 3, 0);
396 ui->cButtonsLayout->addWidget(ui->cDarkButton, 3, 1);
398 ui->orientationGridLayout->removeWidget(ui->orientationAButton);
399 ui->orientationGridLayout->removeWidget(ui->orientationLButton);
400 ui->orientationGridLayout->removeWidget(ui->orientationPButton);
401 ui->orientationGridLayout->addWidget(ui->orientationLButton, 0, 0);
402 ui->orientationGridLayout->addWidget(ui->orientationAButton, 0, 1);
403 ui->orientationGridLayout->addWidget(ui->orientationPButton, 1, 0, 1, 2);