delay a few things on startup, such as setting the visibility mode, which ensures...
[personal-kdebase.git] / apps / konqueror / settings / kio / cache.cpp
blobfb3c76c6c0dd01dbe1cafdeb2ce4a8195d67da08
1 /*
2 cache.cpp - Proxy configuration dialog
4 Copyright (C) 2001,02,03 Dawit Alemayehu <adawit@kde.org>
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU General Public
8 License (GPL) version 2 as published by the Free Software
9 Foundation.
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
22 // Own
23 #include "cache.h"
25 // Qt
26 #include <QtGui/QBoxLayout>
27 #include <QtGui/QCheckBox>
28 #include <QtGui/QLabel>
29 #include <QtGui/QLayout>
30 #include <QtGui/QPushButton>
31 #include <QtGui/QRadioButton>
33 // KDE
34 #include <kprocess.h>
35 #include <kdebug.h>
36 #include <kgenericfactory.h>
37 #include <kio/http_slave_defaults.h>
38 #include <klocale.h>
39 #include <knuminput.h>
40 #include <kstandarddirs.h>
42 // Local
43 #include "ksaveioconfig.h"
45 K_PLUGIN_FACTORY_DECLARATION(KioConfigFactory)
47 CacheConfigModule::CacheConfigModule(QWidget *parent, const QVariantList &)
48 :KCModule(KioConfigFactory::componentData(), parent)
50 ui.setupUi(this);
53 CacheConfigModule::~CacheConfigModule()
57 void CacheConfigModule::load()
59 ui.cbUseCache->setChecked(KProtocolManager::useCache());
60 ui.sbMaxCacheSize->setValue( KProtocolManager::maxCacheSize() );
62 KIO::CacheControl cc = KProtocolManager::cacheControl();
64 if (cc==KIO::CC_Verify)
65 ui.rbVerifyCache->setChecked( true );
66 else if (cc==KIO::CC_Refresh)
67 ui.rbVerifyCache->setChecked( true );
68 else if (cc==KIO::CC_CacheOnly)
69 ui.rbOfflineMode->setChecked( true );
70 else if (cc==KIO::CC_Cache)
71 ui.rbCacheIfPossible->setChecked( true );
73 // Config changed notifications...
74 connect ( ui.cbUseCache, SIGNAL(toggled(bool)), SLOT(configChanged()) );
75 connect ( ui.rbVerifyCache, SIGNAL(toggled(bool)), SLOT(configChanged()) );
76 connect ( ui.rbOfflineMode, SIGNAL(toggled(bool)), SLOT(configChanged()) );
77 connect ( ui.rbCacheIfPossible, SIGNAL(toggled(bool)), SLOT(configChanged()) );
78 connect ( ui.sbMaxCacheSize, SIGNAL(valueChanged(int)), SLOT(configChanged()) );
79 emit changed( false );
82 void CacheConfigModule::save()
84 KSaveIOConfig::setUseCache( ui.cbUseCache->isChecked() );
85 KSaveIOConfig::setMaxCacheSize( ui.sbMaxCacheSize->value() );
87 if ( !ui.cbUseCache->isChecked() )
88 KSaveIOConfig::setCacheControl(KIO::CC_Refresh);
89 else if ( ui.rbVerifyCache->isChecked() )
90 KSaveIOConfig::setCacheControl(KIO::CC_Refresh);
91 else if ( ui.rbOfflineMode->isChecked() )
92 KSaveIOConfig::setCacheControl(KIO::CC_CacheOnly);
93 else if ( ui.rbCacheIfPossible->isChecked() )
94 KSaveIOConfig::setCacheControl(KIO::CC_Cache);
96 // Update running io-slaves...
97 KSaveIOConfig::updateRunningIOSlaves (this);
99 emit changed( false );
102 void CacheConfigModule::defaults()
104 ui.cbUseCache->setChecked( true );
105 ui.rbVerifyCache->setChecked( true );
106 ui.sbMaxCacheSize->setValue( DEFAULT_MAX_CACHE_SIZE );
109 QString CacheConfigModule::quickHelp() const
111 return i18n( "<h1>Cache</h1><p>This module lets you configure your cache settings.</p>"
112 "<p>The cache is an internal memory in Konqueror where recently "
113 "read web pages are stored. If you want to retrieve a web "
114 "page again that you have recently read, it will not be "
115 "downloaded from the Internet, but rather retrieved from the "
116 "cache, which is a lot faster.</p>" );
119 void CacheConfigModule::configChanged()
121 emit changed( true );
124 void CacheConfigModule::on_clearCacheButton_clicked()
126 KProcess::startDetached(KStandardDirs::findExe("kio_http_cache_cleaner"),
127 QStringList(QLatin1String("--clear-all")));
130 #include "cache.moc"