]> cloud.milkyroute.net Git - dolphin.git/blob - src/dolphinsettings.cpp
Allow zooming in and zooming out in the icons view.
[dolphin.git] / src / dolphinsettings.cpp
1 /***************************************************************************
2 * Copyright (C) 2006 by Peter Penz (peter.penz@gmx.at), *
3 * Cvetoslav Ludmiloff and Patrice Tremblay *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (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 *
17 * Free Software Foundation, Inc., *
18 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
19 ***************************************************************************/
20
21 #include "dolphinsettings.h"
22
23 #include <assert.h>
24 #include <qdir.h>
25
26 #include <kbookmark.h>
27 #include <kbookmarkmanager.h>
28 #include <kcomponentdata.h>
29 #include <kicontheme.h>
30 #include <klocale.h>
31 #include <kstandarddirs.h>
32
33 #include "dolphin_generalsettings.h"
34 #include "dolphin_iconsmodesettings.h"
35 #include "dolphin_detailsmodesettings.h"
36
37 #include <Q3IconView>
38
39 DolphinSettings& DolphinSettings::instance()
40 {
41 static DolphinSettings* instance = 0;
42 if (instance == 0) {
43 instance = new DolphinSettings();
44 }
45 return *instance;
46 }
47
48 KBookmark DolphinSettings::bookmark(int index) const
49 {
50 int i = 0;
51 KBookmarkGroup root = bookmarkManager()->root();
52 KBookmark bookmark = root.first();
53 while (!bookmark.isNull()) {
54 if (i == index) {
55 return bookmark;
56 }
57 ++i;
58 bookmark = root.next(bookmark);
59 }
60
61 return KBookmark();
62 }
63
64 KBookmarkManager* DolphinSettings::bookmarkManager() const
65 {
66 QString basePath = KGlobal::mainComponent().componentName();
67 basePath.append("/bookmarks.xml");
68 const QString file = KStandardDirs::locateLocal("data", basePath);
69
70 return KBookmarkManager::managerForFile(file, "dolphin", false);
71 }
72
73 void DolphinSettings::save()
74 {
75 m_generalSettings->writeConfig();
76 m_iconsModeSettings->writeConfig();
77 m_detailsModeSettings->writeConfig();
78
79 QString basePath = KGlobal::mainComponent().componentName();
80 basePath.append("/bookmarks.xml");
81 const QString file = KStandardDirs::locateLocal( "data", basePath);
82
83 KBookmarkManager* manager = KBookmarkManager::managerForFile(file, "dolphin", false);
84 manager->save(false);
85 }
86
87 DolphinSettings::DolphinSettings()
88 {
89 m_generalSettings = new GeneralSettings();
90 m_iconsModeSettings = new IconsModeSettings();
91 m_detailsModeSettings = new DetailsModeSettings();
92 }
93
94 DolphinSettings::~DolphinSettings()
95 {
96 delete m_generalSettings;
97 m_generalSettings = 0;
98
99 delete m_iconsModeSettings;
100 m_iconsModeSettings = 0;
101
102 delete m_detailsModeSettings;
103 m_detailsModeSettings = 0;
104 }