Fixed broken image issue in taglib
[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         QString language = config.getValue("ui/language").toString();
38         ui->albumsSortDButton->setChecked(true);        // defaule sorting
39         ui->showTrackLenghtYButton->setChecked(true);   // show by default
40         ui->orientationLButton->setChecked(true);
41         ui->iconsWButton->setChecked(true);
42         ui->gradientYButton->setChecked(true);
43         ui->engLangButton->setChecked(true);
44         if (albumSorting == "alphabet") {
45                 ui->albumsSortAButton->setChecked(true);
46         }
47         if (showTrackLenght == "no") {
48                 ui->showTrackLenghtNButton->setChecked(true);
49         }
50         if (orientation == "portrait") {
51                 ui->orientationPButton->setChecked(true);
52         } else if (orientation == "auto") {
53                 ui->orientationAButton->setChecked(true);
54         }
55         if (icons_theme == "black") {
56                 ui->iconstBButton->setChecked(true);
57         }
58         if (gradient == "no") {
59                 ui->gradientNButton->setChecked(true);
60         }
61         if (language == "ru") {
62                 ui->ruLangButton->setChecked(true);
63         }
64         connect (ui->albumsSortAButton, SIGNAL(toggled(bool)), this, SLOT(_set_album_sorting_alphabet(bool)));
65         connect (ui->albumsSortDButton, SIGNAL(toggled(bool)), this, SLOT(_set_album_sorting_date(bool)));
66         connect (ui->showTrackLenghtNButton, SIGNAL(toggled(bool)), this, SLOT(_set_track_lenght_show_no(bool)));
67         connect (ui->showTrackLenghtYButton, SIGNAL(toggled(bool)), this, SLOT(_set_track_lenght_show_yes(bool)));
68         connect (ui->orientationAButton, SIGNAL(toggled(bool)), this, SLOT(_set_orientation_auto(bool)));
69         connect (ui->orientationLButton, SIGNAL(toggled(bool)), this, SLOT(_set_orientation_landscape(bool)));
70         connect (ui->orientationPButton, SIGNAL(toggled(bool)), this, SLOT(_set_orientation_portrait(bool)));
71         connect (ui->iconstBButton, SIGNAL(toggled(bool)), this, SLOT(_set_icons_black(bool)));
72         connect (ui->iconsWButton, SIGNAL(toggled(bool)), this, SLOT(_set_icons_white(bool)));
73         connect (ui->gradientNButton, SIGNAL(toggled(bool)), this, SLOT(_set_gradient_no(bool)));
74         connect (ui->gradientYButton, SIGNAL(toggled(bool)), this, SLOT(_set_gradient_yes(bool)));
75         connect (ui->engLangButton, SIGNAL(toggled(bool)), this, SLOT(_set_lang_en(bool)));
76         connect (ui->ruLangButton, SIGNAL(toggled(bool)), this, SLOT(_set_lang_ru(bool)));
77 }
78
79 SettingsDialog::~SettingsDialog()
80 {
81         delete ui;
82 }
83
84 void SettingsDialog::_set_album_sorting_date(bool checked) {
85         if (!checked) return;
86         Config config;
87         config.setValue("ui/albumsorting", "date");
88 }
89
90 void SettingsDialog::_set_album_sorting_alphabet(bool checked) {
91         if (!checked) return;
92         Config config;
93         config.setValue("ui/albumsorting", "alphabet");
94 }
95
96 void SettingsDialog::_set_track_lenght_show_no(bool checked) {
97         if (!checked) return;
98         Config config;
99         config.setValue("ui/showtracklenght", "no");
100 }
101
102 void SettingsDialog::_set_track_lenght_show_yes(bool checked) {
103         if (!checked) return;
104         Config config;
105         config.setValue("ui/showtracklenght", "yes");
106 }
107
108 void SettingsDialog::_set_orientation_auto(bool checked) {
109         if (!checked) return;
110         Config config;
111         config.setValue("ui/orientation", "auto");
112 }
113
114 void SettingsDialog::_set_orientation_landscape(bool checked) {
115         if (!checked) return;
116         Config config;
117         config.setValue("ui/orientation", "landscape");
118 }
119
120 void SettingsDialog::_set_orientation_portrait(bool checked) {
121         if (!checked) return;
122         Config config;
123         config.setValue("ui/orientation", "portrait");
124 }
125
126 void SettingsDialog::_set_icons_black(bool checked) {
127         if (!checked) return;
128         Config config;
129         config.setValue("ui/iconstheme", "black");
130 }
131
132 void SettingsDialog::_set_icons_white(bool checked) {
133         if (!checked) return;
134         Config config;
135         config.setValue("ui/iconstheme", "white");
136 }
137
138 void SettingsDialog::_set_gradient_no(bool checked) {
139         if (!checked) return;
140         Config config;
141         config.setValue("ui/gradient", "no");
142 }
143
144 void SettingsDialog::_set_gradient_yes(bool checked) {
145         if (!checked) return;
146         Config config;
147         config.setValue("ui/gradient", "yes");
148 }
149
150 void SettingsDialog::_set_lang_en(bool checked) {
151         if (!checked) return;
152         Config config;
153         config.setValue("ui/language", "en");
154 }
155
156 void SettingsDialog::_set_lang_ru(bool checked) {
157         if (!checked) return;
158         Config config;
159         config.setValue("ui/language", "ru");
160 }