Browse Source

- Allow to define a temporary download folder

adaptive-webui-19844
Christophe Dumez 16 years ago
parent
commit
f4502367f3
  1. 3
      Changelog
  2. 5
      src/GUI.cpp
  3. 40
      src/bittorrent.cpp
  4. 2
      src/bittorrent.h
  5. 2
      src/options.ui
  6. 4
      src/options_imp.cpp

3
Changelog

@ -1,4 +1,5 @@ @@ -1,4 +1,5 @@
* Unknown - Christophe Dumez <chris@qbittorrent.org> - v1.3.3
* Unknown - Christophe Dumez <chris@qbittorrent.org> - v1.4.0
- FEATURE: Allow to define temporary download folder
- COSMETIC: Redesigned program preferences
- COSMETIC: Updated icons set

5
src/GUI.cpp

@ -945,6 +945,11 @@ void GUI::configureSession(bool deleteOptions) { @@ -945,6 +945,11 @@ void GUI::configureSession(bool deleteOptions) {
// Downloads
// * Save path
BTSession->setDefaultSavePath(options->getSavePath());
if(options->isTempPathEnabled()) {
BTSession->setDefaultTempPath(options->getTempPath());
} else {
BTSession->setDefaultTempPath(QString::null);
}
BTSession->preAllocateAllFiles(options->preAllocateAllFiles());
BTSession->startTorrentsInPause(options->addTorrentsInPause());
// * Scan dir

40
src/bittorrent.cpp

@ -439,7 +439,11 @@ QTorrentHandle bittorrent::addTorrent(QString path, bool fromScanDir, QString fr @@ -439,7 +439,11 @@ QTorrentHandle bittorrent::addTorrent(QString path, bool fromScanDir, QString fr
savepath_file.write(savePath.toUtf8());
savepath_file.close();
}
p.save_path = savePath.toUtf8().data();
if(defaultTempPath.isEmpty()) {
p.save_path = savePath.toUtf8().data();
} else {
p.save_path = defaultTempPath.toUtf8().data();
}
p.ti = t;
// Preallocate all?
if(preAllocateAll)
@ -895,6 +899,31 @@ void bittorrent::setDefaultSavePath(QString savepath) { @@ -895,6 +899,31 @@ void bittorrent::setDefaultSavePath(QString savepath) {
defaultSavePath = savepath;
}
void bittorrent::setDefaultTempPath(QString temppath) {
if(defaultTempPath == temppath)
return;
if(temppath.isEmpty()) {
// Disabling temp dir
// Moving all torrents to their destination folder
std::vector<torrent_handle> torrents = getTorrents();
std::vector<torrent_handle>::iterator torrentIT;
for(torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) {
QTorrentHandle h = QTorrentHandle(*torrentIT);
if(!h.is_valid()) continue;
h.move_storage(getSavePath(h.hash()));
}
} else {
std::vector<torrent_handle> torrents = getTorrents();
std::vector<torrent_handle>::iterator torrentIT;
for(torrentIT = torrents.begin(); torrentIT != torrents.end(); torrentIT++) {
QTorrentHandle h = QTorrentHandle(*torrentIT);
if(!h.is_valid()) continue;
h.move_storage(temppath);
}
}
defaultTempPath = temppath;
}
// Enable directory scanning
void bittorrent::enableDirectoryScanning(QString scan_dir) {
if(!scan_dir.isEmpty()) {
@ -1111,6 +1140,15 @@ void bittorrent::readAlerts() { @@ -1111,6 +1140,15 @@ void bittorrent::readAlerts() {
finished_file.open(QIODevice::WriteOnly | QIODevice::Text);
finished_file.close();
h.save_resume_data();
// Move to download directory if necessary
if(!defaultTempPath.isEmpty()) {
// Check if directory is different
QDir current_dir(h.save_path());
QDir save_dir(getSavePath(h.hash()));
if(current_dir != save_dir) {
h.move_storage(save_dir.path());
}
}
qDebug("Received finished alert for %s", h.name().toUtf8().data());
}
}

2
src/bittorrent.h

@ -51,6 +51,7 @@ class bittorrent : public QObject { @@ -51,6 +51,7 @@ class bittorrent : public QObject {
bool DHTEnabled;
QPointer<downloadThread> downloader;
QString defaultSavePath;
QString defaultTempPath;
QHash<QString, QHash<QString, QString> > trackersErrors;
QStringList consoleMessages;
QStringList peerBanMessages;
@ -142,6 +143,7 @@ class bittorrent : public QObject { @@ -142,6 +143,7 @@ class bittorrent : public QObject {
void setSessionSettings(session_settings sessionSettings);
void startTorrentsInPause(bool b);
void setDefaultSavePath(QString savepath);
void setDefaultTempPath(QString temppath);
void applyEncryptionSettings(pe_settings se);
void loadFilesPriorities(QTorrentHandle& h);
void setDownloadLimit(QString hash, long val);

2
src/options.ui

@ -200,7 +200,7 @@ @@ -200,7 +200,7 @@
<item>
<widget class="QStackedWidget" name="tabOption">
<property name="currentIndex">
<number>1</number>
<number>0</number>
</property>
<widget class="QWidget" name="tabOptionPage1">
<layout class="QVBoxLayout" name="verticalLayout_10">

4
src/options_imp.cpp

@ -515,11 +515,13 @@ void options_imp::loadOptions(){ @@ -515,11 +515,13 @@ void options_imp::loadOptions(){
textSavePath->setText(settings.value(QString::fromUtf8("SavePath"), home+"qBT_dir").toString());
if(settings.value(QString::fromUtf8("TempPathEnabled"), false).toBool()) {
// enable
checkTempFolder->setChecked(true);
enableTempPathInput(2);
} else {
checkTempFolder->setChecked(false);
enableTempPathInput(0);
}
textTempPath->setText(settings.value(QString::fromUtf8("TempPath"), home+"qBT_dir").toString());
textTempPath->setText(settings.value(QString::fromUtf8("TempPath"), home+"qBT_dir"+QDir::separator()+"temp").toString());
checkPreallocateAll->setChecked(settings.value(QString::fromUtf8("PreAllocation"), false).toBool());
checkAdditionDialog->setChecked(settings.value(QString::fromUtf8("AdditionDialog"), true).toBool());
checkStartPaused->setChecked(settings.value(QString::fromUtf8("StartInPause"), false).toBool());

Loading…
Cancel
Save