Fix crash if key bindings specified in profile cannot be found. Improve
[personal-kdebase.git] / apps / konqueror / settings / kio / netpref.cpp
blob3e9f629db1a54dd66c89875c477e4449f6d745ef
2 // Own
3 #include "netpref.h"
5 // Qt
6 #include <QtGui/QLayout>
7 #include <QtGui/QCheckBox>
8 #include <QtGui/QGroupBox>
9 #include <QtGui/QBoxLayout>
11 // KDE
12 #include <kio/ioslave_defaults.h>
13 #include <knuminput.h>
14 #include <klocale.h>
15 #include <kdialog.h>
16 #include <kconfig.h>
17 #include <kgenericfactory.h>
19 // Local
20 #include "ksaveioconfig.h"
22 #define MAX_TIMEOUT_VALUE 3600
24 K_PLUGIN_FACTORY_DECLARATION(KioConfigFactory)
26 KIOPreferences::KIOPreferences(QWidget *parent, const QVariantList &)
27 :KCModule(KioConfigFactory::componentData(), parent)
29 QVBoxLayout* mainLayout = new QVBoxLayout( this );
30 mainLayout->setMargin(0);
31 gb_Timeout = new QGroupBox( i18n("Timeout Values"), this );
32 gb_Timeout->setWhatsThis( i18n("Here you can set timeout values. "
33 "You might want to tweak them if your "
34 "connection is very slow. The maximum "
35 "allowed value is %1 seconds.", MAX_TIMEOUT_VALUE));
36 mainLayout->addWidget( gb_Timeout );
38 QVBoxLayout* timeoutLayout = new QVBoxLayout(gb_Timeout);
39 sb_socketRead = new KIntNumInput( this );
40 sb_socketRead->setSuffix( i18n( " sec" ) );
41 sb_socketRead->setLabel( i18n( "Soc&ket read:" ), Qt::AlignVCenter);
42 connect(sb_socketRead, SIGNAL(valueChanged(int)), SLOT(configChanged()));
43 timeoutLayout->addWidget(sb_socketRead);
45 sb_proxyConnect = new KIntNumInput( this );
46 sb_proxyConnect->setSuffix( i18n( " sec" ) );
47 sb_proxyConnect->setLabel( i18n( "Pro&xy connect:" ), Qt::AlignVCenter);
48 connect(sb_proxyConnect, SIGNAL(valueChanged(int)), SLOT(configChanged()));
49 timeoutLayout->addWidget(sb_proxyConnect);
51 sb_serverConnect = new KIntNumInput( this );
52 sb_serverConnect->setSuffix( i18n( " sec" ) );
53 sb_serverConnect->setLabel( i18n("Server co&nnect:"), Qt::AlignVCenter);
54 connect(sb_serverConnect, SIGNAL(valueChanged(int)), SLOT(configChanged()));
55 timeoutLayout->addWidget(sb_serverConnect);
57 sb_serverResponse = new KIntNumInput( this );
58 sb_serverResponse->setSuffix( i18n( " sec" ) );
59 sb_serverResponse->setLabel( i18n("&Server response:"), Qt::AlignVCenter);
60 connect(sb_serverResponse, SIGNAL(valueChanged(int)), SLOT(configChanged()));
61 timeoutLayout->addWidget(sb_serverResponse);
63 gb_Ftp = new QGroupBox( i18n( "FTP Options" ), this );
64 mainLayout->addWidget( gb_Ftp );
65 QVBoxLayout* ftpLayout = new QVBoxLayout(gb_Ftp);
67 cb_ftpEnablePasv = new QCheckBox( i18n( "Enable passive &mode (PASV)" ), this );
68 cb_ftpEnablePasv->setWhatsThis( i18n("Enables FTP's \"passive\" mode. "
69 "This is required to allow FTP to "
70 "work from behind firewalls.") );
71 connect(cb_ftpEnablePasv, SIGNAL(toggled(bool)), SLOT(configChanged()));
72 ftpLayout->addWidget(cb_ftpEnablePasv);
74 cb_ftpMarkPartial = new QCheckBox( i18n( "Mark &partially uploaded files" ), this );
75 cb_ftpMarkPartial->setWhatsThis( i18n( "<p>Marks partially uploaded FTP "
76 "files.</p><p>When this option is "
77 "enabled, partially uploaded files "
78 "will have a \".part\" extension. "
79 "This extension will be removed "
80 "once the transfer is complete.</p>") );
81 connect(cb_ftpMarkPartial, SIGNAL(toggled(bool)), SLOT(configChanged()));
82 ftpLayout->addWidget(cb_ftpMarkPartial);
84 mainLayout->addStretch( 1 );
87 KIOPreferences::~KIOPreferences()
91 void KIOPreferences::load()
93 KProtocolManager proto;
95 sb_socketRead->setRange( MIN_TIMEOUT_VALUE, MAX_TIMEOUT_VALUE );
96 sb_serverResponse->setRange( MIN_TIMEOUT_VALUE, MAX_TIMEOUT_VALUE );
97 sb_serverConnect->setRange( MIN_TIMEOUT_VALUE, MAX_TIMEOUT_VALUE );
98 sb_proxyConnect->setRange( MIN_TIMEOUT_VALUE, MAX_TIMEOUT_VALUE );
100 sb_socketRead->setValue( proto.readTimeout() );
101 sb_serverResponse->setValue( proto.responseTimeout() );
102 sb_serverConnect->setValue( proto.connectTimeout() );
103 sb_proxyConnect->setValue( proto.proxyConnectTimeout() );
105 KConfig config( "kio_ftprc", KConfig::NoGlobals );
106 cb_ftpEnablePasv->setChecked( !config.group("").readEntry( "DisablePassiveMode", false ) );
107 cb_ftpMarkPartial->setChecked( config.group("").readEntry( "MarkPartial", true ) );
108 emit changed( false );
111 void KIOPreferences::save()
113 KSaveIOConfig::setReadTimeout( sb_socketRead->value() );
114 KSaveIOConfig::setResponseTimeout( sb_serverResponse->value() );
115 KSaveIOConfig::setConnectTimeout( sb_serverConnect->value() );
116 KSaveIOConfig::setProxyConnectTimeout( sb_proxyConnect->value() );
118 KConfig config("kio_ftprc", KConfig::NoGlobals);
119 config.group("").writeEntry( "DisablePassiveMode", !cb_ftpEnablePasv->isChecked() );
120 config.group("").writeEntry( "MarkPartial", cb_ftpMarkPartial->isChecked() );
121 config.sync();
123 KSaveIOConfig::updateRunningIOSlaves(this);
125 emit changed( false );
128 void KIOPreferences::defaults()
130 sb_socketRead->setValue( DEFAULT_READ_TIMEOUT );
131 sb_serverResponse->setValue( DEFAULT_RESPONSE_TIMEOUT );
132 sb_serverConnect->setValue( DEFAULT_CONNECT_TIMEOUT );
133 sb_proxyConnect->setValue( DEFAULT_PROXY_CONNECT_TIMEOUT );
135 cb_ftpEnablePasv->setChecked( true );
136 cb_ftpMarkPartial->setChecked( true );
138 emit changed(true);
141 QString KIOPreferences::quickHelp() const
143 return i18n("<h1>Network Preferences</h1>Here you can define"
144 " the behavior of KDE programs when using Internet"
145 " and network connections. If you experience timeouts"
146 " or use a modem to connect to the Internet, you might"
147 " want to adjust these settings." );
150 #include "netpref.moc"