1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
/*
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.
*/
#include <tqlabel.h>
#include <tqlayout.h>
#include <tqcheckbox.h>
#include <tqwhatsthis.h>
#include <tqpushbutton.h>
#include <tqbuttongroup.h>
#include <tqradiobutton.h>
#include <kdebug.h>
#include <tdelocale.h>
#include <kprocess.h>
#include <knuminput.h>
#include "ksaveioconfig.h"
#include <tdeio/http_slave_defaults.h>
#include "cache.h"
#include "cache_ui.h"
KCacheConfigDialog::KCacheConfigDialog( TQWidget* parent )
:TDECModule( parent, "kcmtdeio" )
{
TQVBoxLayout* mainLayout = new TQVBoxLayout(this, 0, 0);
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() );
TDEIO::CacheControl cc = KProtocolManager::cacheControl();
if (cc==TDEIO::CC_Verify)
m_dlg->rbVerifyCache->setChecked( true );
else if (cc==TDEIO::CC_Refresh)
m_dlg->rbVerifyCache->setChecked( true );
else if (cc==TDEIO::CC_CacheOnly)
m_dlg->rbOfflineMode->setChecked( true );
else if (cc==TDEIO::CC_Cache)
m_dlg->rbCacheIfPossible->setChecked( true );
// Config changed notifications...
connect ( m_dlg->cbUseCache, TQ_SIGNAL(toggled(bool)), TQ_SLOT(configChanged()) );
connect ( m_dlg->bgCachePolicy, TQ_SIGNAL(clicked (int)), TQ_SLOT(configChanged()) );
connect ( m_dlg->sbMaxCacheSize, TQ_SIGNAL(valueChanged(int)), TQ_SLOT(configChanged()) );
connect ( m_dlg->pbClearCache, TQ_SIGNAL(clicked()), TQ_SLOT(slotClearCache()) );
emit changed( false );
}
void KCacheConfigDialog::save()
{
KSaveIOConfig::setUseCache( m_dlg->cbUseCache->isChecked() );
KSaveIOConfig::setMaxCacheSize( m_dlg->sbMaxCacheSize->value() );
if ( !m_dlg->cbUseCache->isChecked() )
KSaveIOConfig::setCacheControl(TDEIO::CC_Refresh);
else if ( m_dlg->rbVerifyCache->isChecked() )
KSaveIOConfig::setCacheControl(TDEIO::CC_Refresh);
else if ( m_dlg->rbOfflineMode->isChecked() )
KSaveIOConfig::setCacheControl(TDEIO::CC_CacheOnly);
else if ( m_dlg->rbCacheIfPossible->isChecked() )
KSaveIOConfig::setCacheControl(TDEIO::CC_Cache);
// 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 );
}
TQString KCacheConfigDialog::quickHelp() const
{
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()
{
TDEProcess process;
process << "tdeio_http_cache_cleaner" << "--clear-all";
process.start(TDEProcess::DontCare);
// Cleaning up might take a while. Better detach.
process.detach();
}
#include "cache.moc"
|