added cache configuration and cleanup to kio_bookmarks kcm

svn path=/trunk/KDE/kdebase/apps/; revision=871446
This commit is contained in:
Xavier Vello 2008-10-14 22:25:31 +00:00
parent ef93a39c72
commit f12010a065
3 changed files with 85 additions and 5 deletions

View file

@ -32,7 +32,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include <kgenericfactory.h>
#include <klocale.h>
#include <knuminput.h>
#include <kpixmapcache.h>
K_PLUGIN_FACTORY_DECLARATION(KioConfigFactory)
@ -47,6 +47,13 @@ BookmarksConfigModule::~BookmarksConfigModule()
{
}
void BookmarksConfigModule::clearCache()
{
KPixmapCache* cache = new KPixmapCache("kio_bookmarks");
cache->discard();
delete cache;
}
void BookmarksConfigModule::load()
{
KConfig *c = new KConfig("kiobookmarksrc");
@ -57,6 +64,7 @@ void BookmarksConfigModule::load()
ui.cbShowRoot->setChecked(group.readEntry("ShowRoot", true));
ui.cbFlattenTree->setChecked(group.readEntry("FlattenTree", false));
ui.cbShowPlaces->setChecked(group.readEntry("ShowPlaces", true));
ui.sbCacheSize->setValue(group.readEntry("CacheSize", 4));
// Config changed notifications...
connect ( ui.sbColumns, SIGNAL(valueChanged(int)), SLOT(configChanged()) );
@ -64,6 +72,9 @@ void BookmarksConfigModule::load()
connect ( ui.cbShowRoot, SIGNAL(toggled(bool)), SLOT(configChanged()) );
connect ( ui.cbFlattenTree, SIGNAL(toggled(bool)), SLOT(configChanged()) );
connect ( ui.cbShowPlaces, SIGNAL(toggled(bool)), SLOT(configChanged()) );
connect ( ui.sbCacheSize, SIGNAL(valueChanged(int)), SLOT(configChanged()) );
connect ( ui.clearCacheButton, SIGNAL(clicked(bool)), SLOT(clearCache()) );
delete c;
emit changed( false );
@ -78,6 +89,7 @@ void BookmarksConfigModule::save()
group.writeEntry("ShowRoot", ui.cbShowRoot->isChecked() );
group.writeEntry("FlattenTree", ui.cbFlattenTree->isChecked() );
group.writeEntry("ShowPlaces", ui.cbShowPlaces->isChecked() );
group.writeEntry("CacheSize", ui.sbCacheSize->value() );
c->sync();
delete c;
@ -91,6 +103,7 @@ void BookmarksConfigModule::defaults()
ui.cbShowRoot->setChecked( true );
ui.cbShowPlaces->setChecked( true );
ui.cbFlattenTree->setChecked( false );
ui.sbCacheSize->setValue( 5*1024 );
}
QString BookmarksConfigModule::quickHelp() const

View file

@ -33,12 +33,13 @@ public:
BookmarksConfigModule(QWidget *parent, const QVariantList &args);
~BookmarksConfigModule();
virtual void load();
virtual void save();
virtual void defaults();
void load();
void save();
void defaults();
QString quickHelp() const;
private Q_SLOTS:
void clearCache();
void configChanged();
private:

View file

@ -119,7 +119,7 @@ It looks less nice but it may help if you have a very big folder you want to spr
</layout>
</widget>
</item>
<item row="2" column="0" >
<item row="3" column="0" >
<spacer name="verticalSpacer" >
<property name="orientation" >
<enum>Qt::Vertical</enum>
@ -132,11 +132,77 @@ It looks less nice but it may help if you have a very big folder you want to spr
</property>
</spacer>
</item>
<item row="2" column="0" >
<widget class="QGroupBox" name="groupBox_3" >
<property name="whatsThis" >
<string>How many disk space is used to cache the pixmaps</string>
</property>
<property name="title" >
<string>Pixmap cache</string>
</property>
<layout class="QHBoxLayout" name="horizontalLayout_2" >
<item>
<widget class="QLabel" name="lbMaxCacheSize" >
<property name="enabled" >
<bool>true</bool>
</property>
<property name="text" >
<string>Disk cache size:</string>
</property>
<property name="buddy" >
<cstring>sbCacheSize</cstring>
</property>
</widget>
</item>
<item>
<widget class="KIntNumInput" name="sbCacheSize" >
<property name="enabled" >
<bool>true</bool>
</property>
<property name="suffix" >
<string> kB</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="clearCacheButton" >
<property name="enabled" >
<bool>true</bool>
</property>
<property name="whatsThis" >
<string>Clear the pixmap cache</string>
</property>
<property name="text" >
<string>&amp;Clear Cache</string>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_2" >
<property name="orientation" >
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0" >
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
</layout>
</widget>
</item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11" />
<pixmapfunction>qPixmapFromMimeSource</pixmapfunction>
<customwidgets>
<customwidget>
<class>KIntNumInput</class>
<extends>QWidget</extends>
<header>knuminput.h</header>
</customwidget>
<customwidget>
<class>KIntSpinBox</class>
<extends>QSpinBox</extends>