Suggesting default playlist name in save dialog based on playlist
[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->albumsSortDButton->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 == "alphabet") {
43                 ui->albumsSortAButton->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
72 SettingsDialog::~SettingsDialog()
73 {
74         delete ui;
75 }
76
77 void SettingsDialog::_set_album_sorting_date(bool checked) {
78         if (!checked) return;
79         Config config;
80         config.setValue("ui/albumsorting", "date");
81 }
82
83 void SettingsDialog::_set_album_sorting_alphabet(bool checked) {
84         if (!checked) return;
85         Config config;
86         config.setValue("ui/albumsorting", "alphabet");
87 }
88
89 void SettingsDialog::_set_track_lenght_show_no(bool checked) {
90         if (!checked) return;
91         Config config;
92         config.setValue("ui/showtracklenght", "no");
93 }
94
95 void SettingsDialog::_set_track_lenght_show_yes(bool checked) {
96         if (!checked) return;
97         Config config;
98         config.setValue("ui/showtracklenght", "yes");
99 }
100
101 void SettingsDialog::_set_orientation_auto(bool checked) {
102         if (!checked) return;
103         Config config;
104         config.setValue("ui/orientation", "auto");
105 }
106
107 void SettingsDialog::_set_orientation_landscape(bool checked) {
108         if (!checked) return;
109         Config config;
110         config.setValue("ui/orientation", "landscape");
111 }
112
113 void SettingsDialog::_set_orientation_portrait(bool checked) {
114         if (!checked) return;
115         Config config;
116         config.setValue("ui/orientation", "portrait");
117 }
118
119 void SettingsDialog::_set_icons_black(bool checked) {
120         if (!checked) return;
121         Config config;
122         config.setValue("ui/iconstheme", "black");
123 }
124
125 void SettingsDialog::_set_icons_white(bool checked) {
126         if (!checked) return;
127         Config config;
128         config.setValue("ui/iconstheme", "white");
129 }
130
131 void SettingsDialog::_set_gradient_no(bool checked) {
132         if (!checked) return;
133         Config config;
134         config.setValue("ui/gradient", "no");
135 }
136
137 void SettingsDialog::_set_gradient_yes(bool checked) {
138         if (!checked) return;
139         Config config;
140         config.setValue("ui/gradient", "yes");
141 }