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.
10 #include "btsettingswidget.h"
12 #include "kget_export.h"
13 #include "bittorrentsettings.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
)
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"));
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"