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 if (albumSorting == "alphabet") {
51 ui->albumsSortAButton->setChecked(true);
53 if (showTrackLenght == "no") {
54 ui->showTrackLenghtNButton->setChecked(true);
56 if (orientation == "portrait") {
57 ui->orientationPButton->setChecked(true);
58 } else if (orientation == "auto") {
59 ui->orientationAButton->setChecked(true);
61 if (icons_theme == "black") {
62 ui->iconstBButton->setChecked(true);
64 if (gradient == "no") {
65 ui->gradientNButton->setChecked(true);
67 if (language == "ru") {
68 ui->ruLangButton->setChecked(true);
70 if (track_color == "black") {
71 ui->cBlackButton->setChecked(true);
72 } else if (track_color == "magenta") {
73 ui->cMagentaButton->setChecked(true);
74 } else if (track_color == "Red") {
75 ui->cRedButton->setChecked(true);
76 } else if (track_color == "yellow") {
77 ui->cYellowButton->setChecked(true);
78 } else if (track_color == "white") {
79 ui->cWhiteButton->setChecked(true);
80 } else if (track_color == "dark") {
81 ui->cDarkButton->setChecked(true);
82 } else if (track_color == "light") {
83 ui->cLightButton->setChecked(true);
85 if (config.getValue("playback/hpautopause").toString() == "yes") {
86 ui->pauseHPYesButton->setChecked(true);
88 if (!QFile::exists(QString(_APPLICATION_PATH_)+"/someplayer_ru.qm")) {
90 } // refactor this when more translations will be added
91 connect (ui->albumsSortAButton, SIGNAL(toggled(bool)), this, SLOT(_set_album_sorting_alphabet(bool)));
92 connect (ui->albumsSortDButton, SIGNAL(toggled(bool)), this, SLOT(_set_album_sorting_date(bool)));
93 connect (ui->showTrackLenghtNButton, SIGNAL(toggled(bool)), this, SLOT(_set_track_lenght_show_no(bool)));
94 connect (ui->showTrackLenghtYButton, SIGNAL(toggled(bool)), this, SLOT(_set_track_lenght_show_yes(bool)));
95 connect (ui->orientationAButton, SIGNAL(toggled(bool)), this, SLOT(_set_orientation_auto(bool)));
96 connect (ui->orientationLButton, SIGNAL(toggled(bool)), this, SLOT(_set_orientation_landscape(bool)));
97 connect (ui->orientationPButton, SIGNAL(toggled(bool)), this, SLOT(_set_orientation_portrait(bool)));
98 connect (ui->iconstBButton, SIGNAL(toggled(bool)), this, SLOT(_set_icons_black(bool)));
99 connect (ui->iconsWButton, SIGNAL(toggled(bool)), this, SLOT(_set_icons_white(bool)));
100 connect (ui->gradientNButton, SIGNAL(toggled(bool)), this, SLOT(_set_gradient_no(bool)));
101 connect (ui->gradientYButton, SIGNAL(toggled(bool)), this, SLOT(_set_gradient_yes(bool)));
102 connect (ui->engLangButton, SIGNAL(toggled(bool)), this, SLOT(_set_lang_en(bool)));
103 connect (ui->ruLangButton, SIGNAL(toggled(bool)), this, SLOT(_set_lang_ru(bool)));
104 connect (ui->cBlackButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_black(bool)));
105 connect (ui->cBlueButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_blue(bool)));
106 connect (ui->cDarkButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_dark(bool)));
107 connect (ui->cLightButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_light(bool)));
108 connect (ui->cMagentaButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_magenta(bool)));
109 connect (ui->cRedButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_red(bool)));
110 connect (ui->cWhiteButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_white(bool)));
111 connect (ui->cYellowButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_yellow(bool)));
112 connect (ui->pauseHPNoButton, SIGNAL(toggled(bool)), this, SLOT(_set_pause_hp_no(bool)));
113 connect (ui->pauseHPYesButton, SIGNAL(toggled(bool)), this, SLOT(_set_pause_hp_yes(bool)));
114 setAttribute(Qt::WA_Maemo5StackedWindow);
115 setWindowFlags(Qt::Window | windowFlags());
118 SettingsForm::~SettingsForm()
123 void SettingsForm::_set_album_sorting_date(bool checked) {
124 if (!checked) return;
126 config.setValue("ui/albumsorting", "date");
127 emit libraryOptionsChanged();
130 void SettingsForm::_set_album_sorting_alphabet(bool checked) {
131 if (!checked) return;
133 config.setValue("ui/albumsorting", "alphabet");
134 emit libraryOptionsChanged();
137 void SettingsForm::_set_track_lenght_show_no(bool checked) {
138 if (!checked) return;
140 config.setValue("ui/showtracklenght", "no");
141 emit libraryOptionsChanged();
144 void SettingsForm::_set_track_lenght_show_yes(bool checked) {
145 if (!checked) return;
147 config.setValue("ui/showtracklenght", "yes");
148 emit libraryOptionsChanged();
151 void SettingsForm::_set_orientation_auto(bool checked) {
152 if (!checked) return;
154 config.setValue("ui/orientation", "auto");
155 emit orientationChanged();
158 void SettingsForm::_set_orientation_landscape(bool checked) {
159 if (!checked) return;
161 config.setValue("ui/orientation", "landscape");
162 emit orientationChanged();
165 void SettingsForm::_set_orientation_portrait(bool checked) {
166 if (!checked) return;
168 config.setValue("ui/orientation", "portrait");
169 emit orientationChanged();
172 void SettingsForm::_set_icons_black(bool checked) {
173 if (!checked) return;
175 config.setValue("ui/iconstheme", "black");
179 void SettingsForm::_set_icons_white(bool checked) {
180 if (!checked) return;
182 config.setValue("ui/iconstheme", "white");
186 void SettingsForm::_set_gradient_no(bool checked) {
187 if (!checked) return;
189 config.setValue("ui/gradient", "no");
190 emit gradientChanged();
193 void SettingsForm::_set_gradient_yes(bool checked) {
194 if (!checked) return;
196 config.setValue("ui/gradient", "yes");
197 emit gradientChanged();
200 void SettingsForm::_set_color_black(bool checked) {
201 if (!checked) return;
203 config.setValue("ui/trackcolor", "black");
204 emit trackColorChanged();
207 void SettingsForm::_set_color_blue(bool checked) {
208 if (!checked) return;
210 config.setValue("ui/trackcolor", "blue");
211 emit trackColorChanged();
214 void SettingsForm::_set_color_dark(bool checked) {
215 if (!checked) return;
217 config.setValue("ui/trackcolor", "dark");
218 emit trackColorChanged();
221 void SettingsForm::_set_color_light(bool checked) {
222 if (!checked) return;
224 config.setValue("ui/trackcolor", "light");
225 emit trackColorChanged();
228 void SettingsForm::_set_color_magenta(bool checked) {
229 if (!checked) return;
231 config.setValue("ui/trackcolor", "magenta");
232 emit trackColorChanged();
235 void SettingsForm::_set_color_red(bool checked) {
236 if (!checked) return;
238 config.setValue("ui/trackcolor", "red");
239 emit trackColorChanged();
242 void SettingsForm::_set_color_white(bool checked) {
243 if (!checked) return;
245 config.setValue("ui/trackcolor", "white");
246 emit trackColorChanged();
249 void SettingsForm::_set_color_yellow(bool checked) {
250 if (!checked) return;
252 config.setValue("ui/trackcolor", "yellow");
253 emit trackColorChanged();
256 void SettingsForm::_set_lang_en(bool checked) {
257 if (!checked) return;
259 config.setValue("ui/language", "en");
260 emit translationChanged();
263 void SettingsForm::_set_lang_ru(bool checked) {
264 if (!checked) return;
266 config.setValue("ui/language", "ru");
267 emit translationChanged();
270 void SettingsForm::_set_pause_hp_no(bool checked) {
271 if (!checked) return;
273 config.setValue("playback/hpautopause", "no");
276 void SettingsForm::_set_pause_hp_yes(bool checked) {
277 if (!checked) return;
279 config.setValue("playback/hpautopause", "yes");
282 void SettingsForm::updateTranslations() {
283 ui->retranslateUi(this);
286 void SettingsForm::landscapeMode() {
287 ui->cButtonsLayout->removeWidget(ui->cBlueButton);
288 ui->cButtonsLayout->removeWidget(ui->cMagentaButton);
289 ui->cButtonsLayout->removeWidget(ui->cRedButton);
290 ui->cButtonsLayout->removeWidget(ui->cYellowButton);
291 ui->cButtonsLayout->removeWidget(ui->cWhiteButton);
292 ui->cButtonsLayout->removeWidget(ui->cBlackButton);
293 ui->cButtonsLayout->removeWidget(ui->cLightButton);
294 ui->cButtonsLayout->removeWidget(ui->cDarkButton);
295 ui->cButtonsLayout->addWidget(ui->cBlueButton, 0, 0);
296 ui->cButtonsLayout->addWidget(ui->cMagentaButton, 0, 1);
297 ui->cButtonsLayout->addWidget(ui->cRedButton, 0, 2);
298 ui->cButtonsLayout->addWidget(ui->cYellowButton, 0, 3);
299 ui->cButtonsLayout->addWidget(ui->cWhiteButton, 1, 0);
300 ui->cButtonsLayout->addWidget(ui->cBlackButton, 1, 1);
301 ui->cButtonsLayout->addWidget(ui->cLightButton, 1, 2);
302 ui->cButtonsLayout->addWidget(ui->cDarkButton, 1, 3);
304 ui->orientationGridLayout->removeWidget(ui->orientationAButton);
305 ui->orientationGridLayout->removeWidget(ui->orientationLButton);
306 ui->orientationGridLayout->removeWidget(ui->orientationPButton);
307 ui->orientationGridLayout->addWidget(ui->orientationLButton);
308 ui->orientationGridLayout->addWidget(ui->orientationAButton);
309 ui->orientationGridLayout->addWidget(ui->orientationPButton);
312 void SettingsForm::portraitMode() {
313 ui->cButtonsLayout->removeWidget(ui->cBlueButton);
314 ui->cButtonsLayout->removeWidget(ui->cMagentaButton);
315 ui->cButtonsLayout->removeWidget(ui->cRedButton);
316 ui->cButtonsLayout->removeWidget(ui->cYellowButton);
317 ui->cButtonsLayout->removeWidget(ui->cWhiteButton);
318 ui->cButtonsLayout->removeWidget(ui->cBlackButton);
319 ui->cButtonsLayout->removeWidget(ui->cLightButton);
320 ui->cButtonsLayout->removeWidget(ui->cDarkButton);
321 ui->cButtonsLayout->addWidget(ui->cBlueButton, 0, 0);
322 ui->cButtonsLayout->addWidget(ui->cMagentaButton, 0, 1);
323 ui->cButtonsLayout->addWidget(ui->cRedButton, 1, 0);
324 ui->cButtonsLayout->addWidget(ui->cYellowButton, 1, 1);
325 ui->cButtonsLayout->addWidget(ui->cWhiteButton, 2, 0);
326 ui->cButtonsLayout->addWidget(ui->cBlackButton, 2, 1);
327 ui->cButtonsLayout->addWidget(ui->cLightButton, 3, 0);
328 ui->cButtonsLayout->addWidget(ui->cDarkButton, 3, 1);
330 ui->orientationGridLayout->removeWidget(ui->orientationAButton);
331 ui->orientationGridLayout->removeWidget(ui->orientationLButton);
332 ui->orientationGridLayout->removeWidget(ui->orientationPButton);
333 ui->orientationGridLayout->addWidget(ui->orientationLButton, 0, 0);
334 ui->orientationGridLayout->addWidget(ui->orientationAButton, 0, 1);
335 ui->orientationGridLayout->addWidget(ui->orientationPButton, 1, 0, 1, 2);