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 using namespace SomePlayer::Storage;
27 SettingsForm::SettingsForm(QWidget *parent) :
29 ui(new Ui::SettingsForm)
33 QString albumSorting = config.getValue("ui/albumsorting").toString();
34 QString showTrackLenght = config.getValue("ui/showtracklenght").toString();
35 QString orientation = config.getValue("ui/orientation").toString();
36 QString icons_theme = config.getValue("ui/iconstheme").toString();
37 QString gradient = config.getValue("ui/gradient").toString();
38 QString language = config.getValue("ui/language").toString();
39 QString track_color = config.getValue("ui/trackcolor").toString();
40 ui->albumsSortDButton->setChecked(true); // defaule sorting
41 ui->showTrackLenghtYButton->setChecked(true); // show by default
42 ui->orientationLButton->setChecked(true);
43 ui->iconsWButton->setChecked(true);
44 ui->gradientYButton->setChecked(true);
45 ui->engLangButton->setChecked(true);
46 ui->cBlueButton->setChecked(true);
47 if (albumSorting == "alphabet") {
48 ui->albumsSortAButton->setChecked(true);
50 if (showTrackLenght == "no") {
51 ui->showTrackLenghtNButton->setChecked(true);
53 if (orientation == "portrait") {
54 ui->orientationPButton->setChecked(true);
55 } else if (orientation == "auto") {
56 ui->orientationAButton->setChecked(true);
58 if (icons_theme == "black") {
59 ui->iconstBButton->setChecked(true);
61 if (gradient == "no") {
62 ui->gradientNButton->setChecked(true);
64 if (language == "ru") {
65 ui->ruLangButton->setChecked(true);
67 if (track_color == "black") {
68 ui->cBlackButton->setChecked(true);
69 } else if (track_color == "magenta") {
70 ui->cMagentaButton->setChecked(true);
71 } else if (track_color == "Red") {
72 ui->cRedButton->setChecked(true);
73 } else if (track_color == "yellow") {
74 ui->cYellowButton->setChecked(true);
75 } else if (track_color == "white") {
76 ui->cWhiteButton->setChecked(true);
77 } else if (track_color == "dark") {
78 ui->cDarkButton->setChecked(true);
79 } else if (track_color == "light") {
80 ui->cLightButton->setChecked(true);
82 connect (ui->albumsSortAButton, SIGNAL(toggled(bool)), this, SLOT(_set_album_sorting_alphabet(bool)));
83 connect (ui->albumsSortDButton, SIGNAL(toggled(bool)), this, SLOT(_set_album_sorting_date(bool)));
84 connect (ui->showTrackLenghtNButton, SIGNAL(toggled(bool)), this, SLOT(_set_track_lenght_show_no(bool)));
85 connect (ui->showTrackLenghtYButton, SIGNAL(toggled(bool)), this, SLOT(_set_track_lenght_show_yes(bool)));
86 connect (ui->orientationAButton, SIGNAL(toggled(bool)), this, SLOT(_set_orientation_auto(bool)));
87 connect (ui->orientationLButton, SIGNAL(toggled(bool)), this, SLOT(_set_orientation_landscape(bool)));
88 connect (ui->orientationPButton, SIGNAL(toggled(bool)), this, SLOT(_set_orientation_portrait(bool)));
89 connect (ui->iconstBButton, SIGNAL(toggled(bool)), this, SLOT(_set_icons_black(bool)));
90 connect (ui->iconsWButton, SIGNAL(toggled(bool)), this, SLOT(_set_icons_white(bool)));
91 connect (ui->gradientNButton, SIGNAL(toggled(bool)), this, SLOT(_set_gradient_no(bool)));
92 connect (ui->gradientYButton, SIGNAL(toggled(bool)), this, SLOT(_set_gradient_yes(bool)));
93 connect (ui->engLangButton, SIGNAL(toggled(bool)), this, SLOT(_set_lang_en(bool)));
94 connect (ui->ruLangButton, SIGNAL(toggled(bool)), this, SLOT(_set_lang_ru(bool)));
95 connect (ui->cBlackButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_black(bool)));
96 connect (ui->cBlueButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_blue(bool)));
97 connect (ui->cDarkButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_dark(bool)));
98 connect (ui->cLightButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_light(bool)));
99 connect (ui->cMagentaButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_magenta(bool)));
100 connect (ui->cRedButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_red(bool)));
101 connect (ui->cWhiteButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_white(bool)));
102 connect (ui->cYellowButton, SIGNAL(toggled(bool)), this, SLOT(_set_color_yellow(bool)));
103 setAttribute(Qt::WA_Maemo5StackedWindow);
104 setWindowFlags(Qt::Window | windowFlags());
107 SettingsForm::~SettingsForm()
112 void SettingsForm::_set_album_sorting_date(bool checked) {
113 if (!checked) return;
115 config.setValue("ui/albumsorting", "date");
116 emit libraryOptionsChanged();
119 void SettingsForm::_set_album_sorting_alphabet(bool checked) {
120 if (!checked) return;
122 config.setValue("ui/albumsorting", "alphabet");
123 emit libraryOptionsChanged();
126 void SettingsForm::_set_track_lenght_show_no(bool checked) {
127 if (!checked) return;
129 config.setValue("ui/showtracklenght", "no");
130 emit libraryOptionsChanged();
133 void SettingsForm::_set_track_lenght_show_yes(bool checked) {
134 if (!checked) return;
136 config.setValue("ui/showtracklenght", "yes");
137 emit libraryOptionsChanged();
140 void SettingsForm::_set_orientation_auto(bool checked) {
141 if (!checked) return;
143 config.setValue("ui/orientation", "auto");
144 emit orientationChanged();
147 void SettingsForm::_set_orientation_landscape(bool checked) {
148 if (!checked) return;
150 config.setValue("ui/orientation", "landscape");
151 emit orientationChanged();
154 void SettingsForm::_set_orientation_portrait(bool checked) {
155 if (!checked) return;
157 config.setValue("ui/orientation", "portrait");
158 emit orientationChanged();
161 void SettingsForm::_set_icons_black(bool checked) {
162 if (!checked) return;
164 config.setValue("ui/iconstheme", "black");
168 void SettingsForm::_set_icons_white(bool checked) {
169 if (!checked) return;
171 config.setValue("ui/iconstheme", "white");
175 void SettingsForm::_set_gradient_no(bool checked) {
176 if (!checked) return;
178 config.setValue("ui/gradient", "no");
179 emit gradientChanged();
182 void SettingsForm::_set_gradient_yes(bool checked) {
183 if (!checked) return;
185 config.setValue("ui/gradient", "yes");
186 emit gradientChanged();
189 void SettingsForm::_set_color_black(bool checked) {
190 if (!checked) return;
192 config.setValue("ui/trackcolor", "black");
193 emit trackColorChanged();
196 void SettingsForm::_set_color_blue(bool checked) {
197 if (!checked) return;
199 config.setValue("ui/trackcolor", "blue");
200 emit trackColorChanged();
203 void SettingsForm::_set_color_dark(bool checked) {
204 if (!checked) return;
206 config.setValue("ui/trackcolor", "dark");
207 emit trackColorChanged();
210 void SettingsForm::_set_color_light(bool checked) {
211 if (!checked) return;
213 config.setValue("ui/trackcolor", "light");
214 emit trackColorChanged();
217 void SettingsForm::_set_color_magenta(bool checked) {
218 if (!checked) return;
220 config.setValue("ui/trackcolor", "magenta");
221 emit trackColorChanged();
224 void SettingsForm::_set_color_red(bool checked) {
225 if (!checked) return;
227 config.setValue("ui/trackcolor", "red");
228 emit trackColorChanged();
231 void SettingsForm::_set_color_white(bool checked) {
232 if (!checked) return;
234 config.setValue("ui/trackcolor", "white");
235 emit trackColorChanged();
238 void SettingsForm::_set_color_yellow(bool checked) {
239 if (!checked) return;
241 config.setValue("ui/trackcolor", "yellow");
242 emit trackColorChanged();
245 void SettingsForm::_set_lang_en(bool checked) {
246 if (!checked) return;
248 config.setValue("ui/language", "en");
249 emit translationChanged();
252 void SettingsForm::_set_lang_ru(bool checked) {
253 if (!checked) return;
255 config.setValue("ui/language", "ru");
256 emit translationChanged();
259 void SettingsForm::updateTranslations() {
260 ui->retranslateUi(this);
263 void SettingsForm::landscapeMode() {
264 ui->cButtonsLayout->removeWidget(ui->cBlueButton);
265 ui->cButtonsLayout->removeWidget(ui->cMagentaButton);
266 ui->cButtonsLayout->removeWidget(ui->cRedButton);
267 ui->cButtonsLayout->removeWidget(ui->cYellowButton);
268 ui->cButtonsLayout->removeWidget(ui->cWhiteButton);
269 ui->cButtonsLayout->removeWidget(ui->cBlackButton);
270 ui->cButtonsLayout->removeWidget(ui->cLightButton);
271 ui->cButtonsLayout->removeWidget(ui->cDarkButton);
272 ui->cButtonsLayout->addWidget(ui->cBlueButton, 0, 0);
273 ui->cButtonsLayout->addWidget(ui->cMagentaButton, 0, 1);
274 ui->cButtonsLayout->addWidget(ui->cRedButton, 0, 2);
275 ui->cButtonsLayout->addWidget(ui->cYellowButton, 0, 3);
276 ui->cButtonsLayout->addWidget(ui->cWhiteButton, 1, 0);
277 ui->cButtonsLayout->addWidget(ui->cBlackButton, 1, 1);
278 ui->cButtonsLayout->addWidget(ui->cLightButton, 1, 2);
279 ui->cButtonsLayout->addWidget(ui->cDarkButton, 1, 3);
281 ui->orientationGridLayout->removeWidget(ui->orientationAButton);
282 ui->orientationGridLayout->removeWidget(ui->orientationLButton);
283 ui->orientationGridLayout->removeWidget(ui->orientationPButton);
284 ui->orientationGridLayout->addWidget(ui->orientationLButton);
285 ui->orientationGridLayout->addWidget(ui->orientationAButton);
286 ui->orientationGridLayout->addWidget(ui->orientationPButton);
289 void SettingsForm::portraitMode() {
290 ui->cButtonsLayout->removeWidget(ui->cBlueButton);
291 ui->cButtonsLayout->removeWidget(ui->cMagentaButton);
292 ui->cButtonsLayout->removeWidget(ui->cRedButton);
293 ui->cButtonsLayout->removeWidget(ui->cYellowButton);
294 ui->cButtonsLayout->removeWidget(ui->cWhiteButton);
295 ui->cButtonsLayout->removeWidget(ui->cBlackButton);
296 ui->cButtonsLayout->removeWidget(ui->cLightButton);
297 ui->cButtonsLayout->removeWidget(ui->cDarkButton);
298 ui->cButtonsLayout->addWidget(ui->cBlueButton, 0, 0);
299 ui->cButtonsLayout->addWidget(ui->cMagentaButton, 0, 1);
300 ui->cButtonsLayout->addWidget(ui->cRedButton, 1, 0);
301 ui->cButtonsLayout->addWidget(ui->cYellowButton, 1, 1);
302 ui->cButtonsLayout->addWidget(ui->cWhiteButton, 2, 0);
303 ui->cButtonsLayout->addWidget(ui->cBlackButton, 2, 1);
304 ui->cButtonsLayout->addWidget(ui->cLightButton, 3, 0);
305 ui->cButtonsLayout->addWidget(ui->cDarkButton, 3, 1);
307 ui->orientationGridLayout->removeWidget(ui->orientationAButton);
308 ui->orientationGridLayout->removeWidget(ui->orientationLButton);
309 ui->orientationGridLayout->removeWidget(ui->orientationPButton);
310 ui->orientationGridLayout->addWidget(ui->orientationLButton, 0, 0);
311 ui->orientationGridLayout->addWidget(ui->orientationAButton, 0, 1);
312 ui->orientationGridLayout->addWidget(ui->orientationPButton, 1, 0, 1, 2);