Extensive proof-reading.
[kdenetwork.git] / kget / transfer-plugins / bittorrent / btsettingswidget.cpp
blob76b7f61d4aed2a798e406a8032218e71e46e35f2
1 /* This file is part of the KDE project
3 Copyright (C) 2007 Lukas Appelhans <l.appelhans@gmx.de>
5 This program is free software; you can redistribute it and/or
6 modify it under the terms of the GNU General Public
7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version.
9 */
10 #include "btsettingswidget.h"
12 #include "kget_export.h"
13 #include "bittorrentsettings.h"
15 #include <kdebug.h>
16 #include <kfiledialog.h>
18 KGET_EXPORT_PLUGIN_CONFIG(BTSettingsWidget)
20 BTSettingsWidget::BTSettingsWidget(QWidget * parent = 0, const QVariantList &args = QVariantList())
21 : KCModule(KGetFactory::componentData(), parent, args)
23 setupUi(this);
25 connect(portBox, SIGNAL(valueChanged(int)), SLOT(changed()));
26 connect(uploadBox, SIGNAL(valueChanged(int)), SLOT(changed()));
27 connect(downloadBox, SIGNAL(valueChanged(int)), SLOT(changed()));
28 connect(torrentEdit, SIGNAL(textChanged(const QString &)), SLOT(changed()));
29 connect(tempEdit, SIGNAL(textChanged(const QString &)), SLOT(changed()));
30 connect(preallocBox, SIGNAL(stateChanged(int)), SLOT(changed()));
33 void BTSettingsWidget::load()
35 torrentEdit->setMode(KFile::Directory);
36 torrentEdit->fileDialog()->setCaption(i18n("Select a default torrent folder"));
37 tempEdit->setMode(KFile::Directory);
38 tempEdit->fileDialog()->setCaption(i18n("Select a default temporary folder"));
39 defaults();
42 void BTSettingsWidget::save()
44 kDebug(5001) << "Save Bittorrent-config";
45 BittorrentSettings::setPort(portBox->value());
46 BittorrentSettings::setUploadLimit(uploadBox->value());
47 BittorrentSettings::setDownloadLimit(downloadBox->value());
48 BittorrentSettings::setTorrentDir(torrentEdit->url().url());
49 BittorrentSettings::setTmpDir(tempEdit->url().url());
50 BittorrentSettings::setPreAlloc(preallocBox->isChecked());
52 BittorrentSettings::self()->writeConfig();
55 void BTSettingsWidget::defaults()
57 portBox->setValue(BittorrentSettings::port());
58 uploadBox->setValue(BittorrentSettings::uploadLimit());
59 downloadBox->setValue(BittorrentSettings::downloadLimit());
60 torrentEdit->setUrl(BittorrentSettings::torrentDir());
61 tempEdit->setUrl(BittorrentSettings::tmpDir());
62 preallocBox->setChecked(BittorrentSettings::preAlloc());
65 #include "btsettingswidget.moc"