Black icons came back
[someplayer] / src / settingsdialog.cpp
1 /*
2  * SomePlayer - An alternate music player for Maemo 5
3  * Copyright (C) 2010 Nikolay (somebody) Tischenko <niktischenko@gmail.com>
4  *
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.
9  *
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.
14  *
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.
18  */
19
20
21 #include "settingsdialog.h"
22 #include "ui_settingsdialog.h"
23
24 using namespace SomePlayer::Storage;
25
26 SettingsDialog::SettingsDialog(QWidget *parent) :
27                 QDialog(parent),
28                 ui(new Ui::SettingsDialog)
29 {
30         ui->setupUi(this);
31         Config config;
32         QString albumSorting = config.getValue("ui/albumsorting").toString();
33         QString showTrackLenght = config.getValue("ui/showtracklenght").toString();
34         QString orientation = config.getValue("ui/orientation").toString();
35         QString icons_theme = config.getValue("ui/iconstheme").toString();
36         QString gradient = config.getValue("ui/gradient").toString();
37         ui->albumsSortAButton->setChecked(true);        // defaule sorting
38         ui->showTrackLenghtYButton->setChecked(true);   // show by default
39         ui->orientationLButton->setChecked(true);
40         ui->iconsWButton->setChecked(true);
41         ui->gradientYButton->setChecked(true);
42         if (albumSorting == "date") {
43                 ui->albumsSortDButton->setChecked(true);
44         }
45         if (showTrackLenght == "no") {
46                 ui->showTrackLenghtNButton->setChecked(true);
47         }
48         if (orientation == "portrait") {
49                 ui->orientationPButton->setChecked(true);
50         } else if (orientation == "auto") {
51                 ui->orientationAButton->setChecked(true);
52         }
53         if (icons_theme == "black") {
54                 ui->iconstBButton->setChecked(true);
55         }
56         if (gradient == "no") {
57                 ui->gradientNButton->setChecked(true);
58         }
59         connect (ui->albumsSortAButton, SIGNAL(toggled(bool)), this, SLOT(_set_album_sorting_alphabet(bool)));
60         connect (ui->albumsSortDButton, SIGNAL(toggled(bool)), this, SLOT(_set_album_sorting_date(bool)));
61         connect (ui->showTrackLenghtNButton, SIGNAL(toggled(bool)), this, SLOT(_set_track_lenght_show_no(bool)));
62         connect (ui->showTrackLenghtYButton, SIGNAL(toggled(bool)), this, SLOT(_set_track_lenght_show_yes(bool)));
63         connect (ui->orientationAButton, SIGNAL(toggled(bool)), this, SLOT(_set_orientation_auto(bool)));
64         connect (ui->orientationLButton, SIGNAL(toggled(bool)), this, SLOT(_set_orientation_landscape(bool)));
65         connect (ui->orientationPButton, SIGNAL(toggled(bool)), this, SLOT(_set_orientation_portrait(bool)));
66         connect (ui->iconstBButton, SIGNAL(toggled(bool)), this, SLOT(_set_icons_black(bool)));
67         connect (ui->iconsWButton, SIGNAL(toggled(bool)), this, SLOT(_set_icons_white(bool)));
68         connect (ui->gradientNButton, SIGNAL(toggled(bool)), this, SLOT(_set_gradient_no(bool)));
69         connect (ui->gradientYButton, SIGNAL(toggled(bool)), this, SLOT(_set_gradient_yes(bool)));
70
71         // disabled to 1.4.0
72         ui->albumSortingGroupBox->setVisible(false);
73 }
74
75 SettingsDialog::~SettingsDialog()
76 {
77         delete ui;
78 }
79
80 void SettingsDialog::_set_album_sorting_date(bool checked) {
81         if (!checked) return;
82         Config config;
83         config.setValue("ui/albumsorting", "date");
84 }
85
86 void SettingsDialog::_set_album_sorting_alphabet(bool checked) {
87         if (!checked) return;
88         Config config;
89         config.setValue("ui/albumsorting", "alphabet");
90 }
91
92 void SettingsDialog::_set_track_lenght_show_no(bool checked) {
93         if (!checked) return;
94         Config config;
95         config.setValue("ui/showtracklenght", "no");
96 }
97
98 void SettingsDialog::_set_track_lenght_show_yes(bool checked) {
99         if (!checked) return;
100         Config config;
101         config.setValue("ui/showtracklenght", "yes");
102 }
103
104 void SettingsDialog::_set_orientation_auto(bool checked) {
105         if (!checked) return;
106         Config config;
107         config.setValue("ui/orientation", "auto");
108 }
109
110 void SettingsDialog::_set_orientation_landscape(bool checked) {
111         if (!checked) return;
112         Config config;
113         config.setValue("ui/orientation", "landscape");
114 }
115
116 void SettingsDialog::_set_orientation_portrait(bool checked) {
117         if (!checked) return;
118         Config config;
119         config.setValue("ui/orientation", "portrait");
120 }
121
122 void SettingsDialog::_set_icons_black(bool checked) {
123         if (!checked) return;
124         Config config;
125         config.setValue("ui/iconstheme", "black");
126 }
127
128 void SettingsDialog::_set_icons_white(bool checked) {
129         if (!checked) return;
130         Config config;
131         config.setValue("ui/iconstheme", "white");
132 }
133
134 void SettingsDialog::_set_gradient_no(bool checked) {
135         if (!checked) return;
136         Config config;
137         config.setValue("ui/gradient", "no");
138 }
139
140 void SettingsDialog::_set_gradient_yes(bool checked) {
141         if (!checked) return;
142         Config config;
143         config.setValue("ui/gradient", "yes");
144 }