1 /* VLC-REMOTE for MAEMO 5
2 * Copyright (C) 2010 Schutz Sacha <istdasklar@gmail.com>, Dru Moore <usr@dru-id.co.uk>, Yann Nave <yannux@onbebop.net>
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2,
5 * or (at your option) any later version, as published by the Free
8 * This program is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 * GNU General Public License for more details
13 * You should have received a copy of the GNU General Public
14 * License along with this program; if not, write to the
15 * Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 #include <QStringList>
19 #include "appsettings.h"
21 AppSettings::AppSettings() {
24 AppSettings::~AppSettings() {
28 QString AppSettings::getCurrentKey() {
30 return sets.value("config/currentKey", "").toString();
32 QString AppSettings::getCurrentIp() {
34 return sets.value("account/" + getCurrentKey(), "").toString();
36 VlcDirectory AppSettings::getHomeDirectory() {
39 home.name = sets.value("config/accounts/" + getCurrentKey() + "/homeDirName", "Default").toString();
40 home.path = sets.value("config/accounts/" + getCurrentKey() + "/homeDirPath", "~/").toString();
43 bool AppSettings::setHomeDirectory(VlcDirectory dir) {
45 sets.setValue("config/accounts/" + getCurrentKey() + "/homeDirName", dir.name);
46 sets.setValue("config/accounts/" + getCurrentKey() + "/homeDirPath", dir.path);
49 QList<VlcDirectory>* AppSettings::getFavourites() {
51 QList<VlcDirectory> * favourites = new QList<VlcDirectory>();
53 sets.beginGroup("config/accounts/" + getCurrentKey() + "/favourites");
54 foreach ( QString key, sets.allKeys())
60 dir.path = sets.value(key, "~/").toString();
61 favourites->append(dir);
66 bool AppSettings::addFavourite(VlcDirectory dir) {
68 // should check for existing first otherwise it overwrites
69 if (0 < sets.value("config/accounts/" + getCurrentKey() + "/favourites/" + dir.name, "").toString().length()) {
70 dir.name = "_" + dir.name;
71 return addFavourite(dir);
73 sets.setValue("config/accounts/" + getCurrentKey() + "/favourites/" + dir.name, dir.path);
76 bool AppSettings::deleteFavourite(VlcDirectory dir) {
78 sets.remove("config/accounts/" + getCurrentKey() + "/favourites/" + dir.name);
81 Orientation AppSettings::setOrientation(Orientation orientation) {
83 sets.setValue("config/orientation", (int)orientation);
86 Orientation AppSettings::getOrientation() {
88 return (Orientation)(sets.value("config/orientation", AUTO_ROTATE).toInt());