You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
128 lines
4.1 KiB
128 lines
4.1 KiB
15 years ago
|
/*
|
||
|
cache.cpp - Proxy configuration dialog
|
||
|
|
||
|
Copyright (C) 2001,02,03 Dawit Alemayehu <adawit@kde.org>
|
||
|
|
||
|
This library is free software; you can redistribute it and/or
|
||
|
modify it under the terms of the GNU General Public
|
||
|
License (GPL) version 2 as published by the Free Software
|
||
|
Foundation.
|
||
|
|
||
|
This library is distributed in the hope that it will be useful,
|
||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||
|
Library General Public License for more details.
|
||
|
|
||
|
You should have received a copy of the GNU General Public License
|
||
|
along with this library; see the file COPYING.LIB. If not, write to
|
||
|
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
||
|
Boston, MA 02110-1301, USA.
|
||
|
*/
|
||
|
|
||
14 years ago
|
#include <tqlabel.h>
|
||
13 years ago
|
#include <tqlayout.h>
|
||
14 years ago
|
#include <tqcheckbox.h>
|
||
|
#include <tqwhatsthis.h>
|
||
|
#include <tqpushbutton.h>
|
||
|
#include <tqbuttongroup.h>
|
||
|
#include <tqradiobutton.h>
|
||
15 years ago
|
|
||
|
#include <kdebug.h>
|
||
|
#include <klocale.h>
|
||
|
#include <kprocess.h>
|
||
|
#include <knuminput.h>
|
||
|
|
||
|
#include "ksaveioconfig.h"
|
||
12 years ago
|
#include <tdeio/http_slave_defaults.h>
|
||
15 years ago
|
|
||
|
#include "cache.h"
|
||
|
#include "cache_ui.h"
|
||
|
|
||
14 years ago
|
KCacheConfigDialog::KCacheConfigDialog( TQWidget* parent )
|
||
12 years ago
|
:TDECModule( parent, "kcmtdeio" )
|
||
15 years ago
|
{
|
||
14 years ago
|
TQVBoxLayout* mainLayout = new TQVBoxLayout(this, 0, 0);
|
||
15 years ago
|
m_dlg = new CacheDlgUI(this);
|
||
|
mainLayout->addWidget(m_dlg);
|
||
|
mainLayout->addStretch();
|
||
|
|
||
|
load();
|
||
|
}
|
||
|
|
||
|
void KCacheConfigDialog::load()
|
||
|
{
|
||
|
m_dlg->cbUseCache->setChecked(KProtocolManager::useCache());
|
||
|
m_dlg->sbMaxCacheSize->setValue( KProtocolManager::maxCacheSize() );
|
||
|
|
||
12 years ago
|
TDEIO::CacheControl cc = KProtocolManager::cacheControl();
|
||
15 years ago
|
|
||
12 years ago
|
if (cc==TDEIO::CC_Verify)
|
||
15 years ago
|
m_dlg->rbVerifyCache->setChecked( true );
|
||
12 years ago
|
else if (cc==TDEIO::CC_Refresh)
|
||
15 years ago
|
m_dlg->rbVerifyCache->setChecked( true );
|
||
12 years ago
|
else if (cc==TDEIO::CC_CacheOnly)
|
||
15 years ago
|
m_dlg->rbOfflineMode->setChecked( true );
|
||
12 years ago
|
else if (cc==TDEIO::CC_Cache)
|
||
15 years ago
|
m_dlg->rbCacheIfPossible->setChecked( true );
|
||
|
|
||
|
// Config changed notifications...
|
||
14 years ago
|
connect ( m_dlg->cbUseCache, TQT_SIGNAL(toggled(bool)), TQT_SLOT(configChanged()) );
|
||
|
connect ( m_dlg->bgCachePolicy, TQT_SIGNAL(clicked (int)), TQT_SLOT(configChanged()) );
|
||
|
connect ( m_dlg->sbMaxCacheSize, TQT_SIGNAL(valueChanged(int)), TQT_SLOT(configChanged()) );
|
||
|
connect ( m_dlg->pbClearCache, TQT_SIGNAL(clicked()), TQT_SLOT(slotClearCache()) );
|
||
15 years ago
|
emit changed( false );
|
||
|
}
|
||
|
|
||
|
void KCacheConfigDialog::save()
|
||
|
{
|
||
|
KSaveIOConfig::setUseCache( m_dlg->cbUseCache->isChecked() );
|
||
|
KSaveIOConfig::setMaxCacheSize( m_dlg->sbMaxCacheSize->value() );
|
||
|
|
||
|
if ( !m_dlg->cbUseCache->isChecked() )
|
||
12 years ago
|
KSaveIOConfig::setCacheControl(TDEIO::CC_Refresh);
|
||
15 years ago
|
else if ( m_dlg->rbVerifyCache->isChecked() )
|
||
12 years ago
|
KSaveIOConfig::setCacheControl(TDEIO::CC_Refresh);
|
||
15 years ago
|
else if ( m_dlg->rbOfflineMode->isChecked() )
|
||
12 years ago
|
KSaveIOConfig::setCacheControl(TDEIO::CC_CacheOnly);
|
||
15 years ago
|
else if ( m_dlg->rbCacheIfPossible->isChecked() )
|
||
12 years ago
|
KSaveIOConfig::setCacheControl(TDEIO::CC_Cache);
|
||
15 years ago
|
|
||
|
// Update running io-slaves...
|
||
|
KSaveIOConfig::updateRunningIOSlaves (this);
|
||
|
|
||
|
emit changed( false );
|
||
|
}
|
||
|
|
||
|
void KCacheConfigDialog::defaults()
|
||
|
{
|
||
|
m_dlg->cbUseCache->setChecked( true );
|
||
|
m_dlg->rbVerifyCache->setChecked( true );
|
||
|
m_dlg->sbMaxCacheSize->setValue( DEFAULT_MAX_CACHE_SIZE );
|
||
|
}
|
||
|
|
||
14 years ago
|
TQString KCacheConfigDialog::quickHelp() const
|
||
15 years ago
|
{
|
||
|
return i18n( "<h1>Cache</h1><p>This module lets you configure your cache settings.</p>"
|
||
|
"<p>The cache is an internal memory in Konqueror where recently "
|
||
|
"read web pages are stored. If you want to retrieve a web "
|
||
|
"page again that you have recently read, it will not be "
|
||
|
"downloaded from the Internet, but rather retrieved from the "
|
||
|
"cache, which is a lot faster.</p>" );
|
||
|
}
|
||
|
|
||
|
void KCacheConfigDialog::configChanged()
|
||
|
{
|
||
|
emit changed( true );
|
||
|
}
|
||
|
|
||
|
void KCacheConfigDialog::slotClearCache()
|
||
|
{
|
||
12 years ago
|
TDEProcess process;
|
||
12 years ago
|
process << "tdeio_http_cache_cleaner" << "--clear-all";
|
||
12 years ago
|
process.start(TDEProcess::DontCare);
|
||
15 years ago
|
// Cleaning up might take a while. Better detach.
|
||
|
process.detach();
|
||
|
}
|
||
|
|
||
|
#include "cache.moc"
|