Fixed bug with incorrect highlighting after deleting track
[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 iconsTheme = config.getValue("ui/iconstheme").toString();
33         QString albumSorting = config.getValue("ui/albumsorting").toString();
34         QString showTrackLenght = config.getValue("ui/showtracklenght").toString();
35         QString portraitEnabled = config.getValue("ui/portraitmode").toString();
36         ui->iconsWButton->setChecked(true);             // "white" by default
37         ui->albumsSortAButton->setChecked(true);        // defaule sorting
38         ui->showTrackLenghtYButton->setChecked(true);   // show by default
39         ui->portraitEnableButton->setChecked(true);     // enabled by default
40         if (iconsTheme == "black") {
41                 ui->iconsBButton->setChecked(true);
42         }
43         if (albumSorting == "date") {
44                 ui->albumsSortDButton->setChecked(true);
45         }
46         if (showTrackLenght == "no") {
47                 ui->showTrackLenghtNButton->setChecked(true);
48         }
49         if (portraitEnabled == "disabled") {
50                 ui->portraitDisableButton->setChecked(true);
51         }
52         connect (ui->iconsBButton, SIGNAL(toggled(bool)), this, SLOT(_set_icons_black(bool)));
53         connect (ui->iconsWButton, SIGNAL(toggled(bool)), this, SLOT(_set_icons_white(bool)));
54         connect (ui->albumsSortAButton, SIGNAL(toggled(bool)), this, SLOT(_set_album_sorting_alphabet(bool)));
55         connect (ui->albumsSortDButton, SIGNAL(toggled(bool)), this, SLOT(_set_album_sorting_date(bool)));
56         connect (ui->showTrackLenghtNButton, SIGNAL(toggled(bool)), this, SLOT(_set_track_lenght_show_no(bool)));
57         connect (ui->showTrackLenghtYButton, SIGNAL(toggled(bool)), this, SLOT(_set_track_lenght_show_yes(bool)));
58         connect (ui->portraitDisableButton, SIGNAL(toggled(bool)), this, SLOT(_set_portrait_disabled(bool)));
59         connect (ui->portraitEnableButton, SIGNAL(toggled(bool)), this, SLOT(_set_portrait_enabled(bool)));
60
61         // disabled to 1.4.0
62         ui->albumSortingGroupBox->setVisible(false);
63 }
64
65 SettingsDialog::~SettingsDialog()
66 {
67         delete ui;
68 }
69
70 void SettingsDialog::_set_icons_black(bool checked) {
71         if (!checked) return;
72         Config config;
73         config.setValue("ui/iconstheme", "black");
74 }
75
76 void SettingsDialog::_set_icons_white(bool checked) {
77         if (!checked) return;
78         Config config;
79         config.setValue("ui/iconstheme", "white");
80 }
81
82 void SettingsDialog::_set_album_sorting_date(bool checked) {
83         if (!checked) return;
84         Config config;
85         config.setValue("ui/albumsorting", "date");
86 }
87
88 void SettingsDialog::_set_album_sorting_alphabet(bool checked) {
89         if (!checked) return;
90         Config config;
91         config.setValue("ui/albumsorting", "alphabet");
92 }
93
94 void SettingsDialog::_set_track_lenght_show_no(bool checked) {
95         if (!checked) return;
96         Config config;
97         config.setValue("ui/showtracklenght", "no");
98 }
99
100 void SettingsDialog::_set_track_lenght_show_yes(bool checked) {
101         if (!checked) return;
102         Config config;
103         config.setValue("ui/showtracklenght", "yes");
104 }
105
106 void SettingsDialog::_set_portrait_disabled(bool checked) {
107         if (!checked) return;
108         Config config;
109         config.setValue("ui/portraitmode", "disabled");
110 }
111
112 void SettingsDialog::_set_portrait_enabled(bool checked) {
113         if (!checked) return;
114         Config config;
115         config.setValue("ui/portraitmode", "enabled");
116 }