2 Copyright (C) 2008 Xavier Vello <xavier.vello@gmail.com>
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20 #include "bookmarks.h"
23 #include <QtGui/QBoxLayout>
24 #include <QtGui/QCheckBox>
25 #include <QtGui/QLabel>
26 #include <QtGui/QLayout>
27 #include <QtGui/QPushButton>
28 #include <QtGui/QRadioButton>
32 #include <kgenericfactory.h>
34 #include <knuminput.h>
35 #include <kpixmapcache.h>
37 K_PLUGIN_FACTORY_DECLARATION(KioConfigFactory
)
39 BookmarksConfigModule::BookmarksConfigModule(QWidget
*parent
, const QVariantList
&)
40 :KCModule(KioConfigFactory::componentData(), parent
)
45 BookmarksConfigModule::~BookmarksConfigModule()
49 void BookmarksConfigModule::clearCache()
51 KPixmapCache
* cache
= new KPixmapCache("kio_bookmarks");
56 void BookmarksConfigModule::load()
58 KConfig
*c
= new KConfig("kiobookmarksrc");
59 KConfigGroup group
= c
->group("General");
61 ui
.sbColumns
->setValue(group
.readEntry("Columns", 4));
62 ui
.cbShowBackgrounds
->setChecked(group
.readEntry("ShowBackgrounds", true));
63 ui
.cbShowRoot
->setChecked(group
.readEntry("ShowRoot", true));
64 ui
.cbFlattenTree
->setChecked(group
.readEntry("FlattenTree", false));
65 ui
.cbShowPlaces
->setChecked(group
.readEntry("ShowPlaces", true));
66 ui
.sbCacheSize
->setValue(group
.readEntry("CacheSize", 5*1024));
68 // Config changed notifications...
69 connect ( ui
.sbColumns
, SIGNAL(valueChanged(int)), SLOT(configChanged()) );
70 connect ( ui
.cbShowBackgrounds
, SIGNAL(toggled(bool)), SLOT(configChanged()) );
71 connect ( ui
.cbShowRoot
, SIGNAL(toggled(bool)), SLOT(configChanged()) );
72 connect ( ui
.cbFlattenTree
, SIGNAL(toggled(bool)), SLOT(configChanged()) );
73 connect ( ui
.cbShowPlaces
, SIGNAL(toggled(bool)), SLOT(configChanged()) );
74 connect ( ui
.sbCacheSize
, SIGNAL(valueChanged(int)), SLOT(configChanged()) );
76 connect ( ui
.clearCacheButton
, SIGNAL(clicked(bool)), SLOT(clearCache()) );
79 emit
changed( false );
82 void BookmarksConfigModule::save()
84 KConfig
*c
= new KConfig("kiobookmarksrc");
85 KConfigGroup group
= c
->group("General");
86 group
.writeEntry("Columns", ui
.sbColumns
->value() );
87 group
.writeEntry("ShowBackgrounds", ui
.cbShowBackgrounds
->isChecked() );
88 group
.writeEntry("ShowRoot", ui
.cbShowRoot
->isChecked() );
89 group
.writeEntry("FlattenTree", ui
.cbFlattenTree
->isChecked() );
90 group
.writeEntry("ShowPlaces", ui
.cbShowPlaces
->isChecked() );
91 group
.writeEntry("CacheSize", ui
.sbCacheSize
->value() );
95 emit
changed( false );
98 void BookmarksConfigModule::defaults()
100 ui
.sbColumns
->setValue( 4 );
101 ui
.cbShowBackgrounds
->setChecked( true );
102 ui
.cbShowRoot
->setChecked( true );
103 ui
.cbShowPlaces
->setChecked( true );
104 ui
.cbFlattenTree
->setChecked( false );
105 ui
.sbCacheSize
->setValue( 5*1024 );
108 QString
BookmarksConfigModule::quickHelp() const
110 return i18n( "<h1>My Bookmarks</h1><p>This module lets you configure the bookmarks home page.</p>"
111 "<p>The bookmarks home page is accessible at <a href=\"bookmarks:/\">bookmarks:/</a>.</p>" );
114 void BookmarksConfigModule::configChanged()
116 emit
changed( true );
119 #include "bookmarks.moc"