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.
24 using namespace SomePlayer::Storage;
28 _settings = new QSettings(QString(applicationDir())+"/settings.ini", QSettings::IniFormat);
29 if (_settings->value("ui/iconstheme").toString() == "")
30 _settings->setValue("ui/iconstheme", "white");
31 if (_settings->value("ui/albumsorting").toString() == "")
32 _settings->setValue("ui/albumsorting", "date");
33 if (_settings->value("ui/gradient").toString() == "")
34 _settings->setValue("ui/gradient", "yes");
35 if (_settings->value("ui/language").toString() == "")
36 _settings->setValue("ui/language", "en");
37 if (_settings->value("ui/trackcolor").toString() == "")
38 _settings->setValue("ui/trackcolor", "blue");
39 _equalizer_settings = new QSettings(QString(applicationDir())+"/equalizer.ini", QSettings::IniFormat);
44 delete _equalizer_settings;
47 QString Config::applicationDir() {
48 QString path = QDir::homePath()+"/.someplayer";
50 if (!appdir.exists(path)) {
56 QVariant Config::getValue(QString key) {
57 return _settings->value(key);
60 void Config::setValue(QString key, QVariant value) {
61 _settings->setValue(key, value);
64 QStringList Config::getEqualizerPresets() {
65 QStringList presets = _equalizer_settings->value("equalizer/presets").toStringList();
69 double Config::getEqualizerValue(QString band, QString preset) {
71 if (preset.isEmpty()) {
72 section = "equalizer";
74 section = "equalizer_preset_"+preset;
76 return _equalizer_settings->value(section+"/"+band).toDouble();
79 void Config::setEqualizerValue(QString band, double value) {
80 _equalizer_settings->setValue("equalizer/"+band, value);
83 void Config::saveEqualizer(QString preset) {
84 QString section = QString("equalizer_preset_%1/%2").arg(preset);
85 QStringList presets = getEqualizerPresets();
86 if (!presets.contains(preset)) presets.append(preset);
87 _equalizer_settings->setValue("equalizer/presets", presets);
88 for (int i = 0; i < 10; i++) {
89 QString band = QString("band%1").arg(i);
90 _equalizer_settings->setValue(section.arg(band), getEqualizerValue(band));
94 bool Config::equalizerEnabled() {
95 return _equalizer_settings->value("equalizer/enabled").toBool();
98 void Config::setEqualizerEnabled(bool enabled) {
99 _equalizer_settings->setValue("equalizer/enabled", enabled);