kget
btsettingswidget.cpp
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010 #include "btsettingswidget.h"
00011
00012 #include "kget_export.h"
00013 #include "bittorrentsettings.h"
00014
00015 #include <kdebug.h>
00016 #include <kfiledialog.h>
00017
00018 KGET_EXPORT_PLUGIN_CONFIG(BTSettingsWidget)
00019
00020 BTSettingsWidget::BTSettingsWidget(QWidget * parent = 0, const QVariantList &args = QVariantList())
00021 : KCModule(KGetFactory::componentData(), parent, args)
00022 {
00023 setupUi(this);
00024
00025 connect(portBox, SIGNAL(valueChanged(int)), SLOT(changed()));
00026 connect(uploadBox, SIGNAL(valueChanged(int)), SLOT(changed()));
00027 connect(downloadBox, SIGNAL(valueChanged(int)), SLOT(changed()));
00028 connect(torrentEdit, SIGNAL(textChanged(const QString &)), SLOT(changed()));
00029 connect(tempEdit, SIGNAL(textChanged(const QString &)), SLOT(changed()));
00030 connect(preallocBox, SIGNAL(stateChanged(int)), SLOT(changed()));
00031 connect(shareRatioSpin, SIGNAL(valueChanged(int)), SLOT(changed()));
00032 }
00033
00034 void BTSettingsWidget::load()
00035 {
00036 torrentEdit->setMode(KFile::Directory);
00037 torrentEdit->fileDialog()->setCaption(i18n("Select a default Torrent-Folder"));
00038 tempEdit->setMode(KFile::Directory);
00039 tempEdit->fileDialog()->setCaption(i18n("Select a default Temporary-Folder"));
00040 defaults();
00041 }
00042
00043 void BTSettingsWidget::save()
00044 {
00045 kDebug(5001) << "Save Bittorrent-config";
00046 BittorrentSettings::setPort(portBox->value());
00047 BittorrentSettings::setUploadLimit(uploadBox->value());
00048 BittorrentSettings::setDownloadLimit(downloadBox->value());
00049 BittorrentSettings::setTorrentDir(torrentEdit->url().url());
00050 BittorrentSettings::setTmpDir(tempEdit->url().url());
00051 BittorrentSettings::setPreAlloc(preallocBox->isChecked());
00052 BittorrentSettings::setMaxShareRatio(shareRatioSpin->value());
00053
00054 BittorrentSettings::self()->writeConfig();
00055 }
00056
00057 void BTSettingsWidget::defaults()
00058 {
00059 portBox->setValue(BittorrentSettings::port());
00060 uploadBox->setValue(BittorrentSettings::uploadLimit());
00061 downloadBox->setValue(BittorrentSettings::downloadLimit());
00062 shareRatioSpin->setValue(BittorrentSettings::maxShareRatio());
00063 torrentEdit->setUrl(BittorrentSettings::torrentDir());
00064 tempEdit->setUrl(BittorrentSettings::tmpDir());
00065 preallocBox->setChecked(BittorrentSettings::preAlloc());
00066 }
00067
00068 #include "btsettingswidget.moc"
00069