diff --git a/Changelog b/Changelog index 7e284a9e6..5e339fb1f 100644 --- a/Changelog +++ b/Changelog @@ -8,6 +8,7 @@ - FEATURE: ETA calculation now relies on average speed over all sessions - FEATURE: Allow to force rechecking torrents - FEATURE: Added support for 2 new extensions (uTorrent metadata and smart ban plugin) + - FEATURE: Allow to change the save path of torrents after addition * Unknown - Christophe Dumez - v1.2.1 - BUGFIX: Fixed possible crash when deleting a torrent permanently diff --git a/src/properties.ui b/src/properties.ui index b41bb846f..ad4c93aa7 100644 --- a/src/properties.ui +++ b/src/properties.ui @@ -16,16 +16,7 @@ 6 - - 9 - - - 9 - - - 9 - - + 9 @@ -37,7 +28,7 @@ Main infos - + @@ -83,54 +74,15 @@ Torrent infos - - - 6 - - - 9 - - - 9 - - - 9 - - - 9 - + - - - 6 - - - 0 - - - 0 - - - 0 - - - 0 - + 6 - - 0 - - - 0 - - - 0 - - + 0 @@ -218,34 +170,42 @@ - - - 6 - - - 0 - - - 0 - - - 0 - - - 0 - + - - - - 0 - 29 - - - - - - + + + + + + 0 + 29 + + + + + + + + + + + + 21 + 0 + + + + + 21 + 16777215 + + + + ... + + + + @@ -299,7 +259,7 @@ Qt::Horizontal - + 40 20 @@ -363,16 +323,7 @@ 6 - - 9 - - - 9 - - - 9 - - + 9 @@ -380,16 +331,7 @@ 6 - - 0 - - - 0 - - - 0 - - + 0 @@ -397,16 +339,7 @@ 6 - - 0 - - - 0 - - - 0 - - + 0 @@ -488,16 +421,7 @@ 6 - - 0 - - - 0 - - - 0 - - + 0 @@ -535,7 +459,7 @@ Qt::Horizontal - + 181 20 @@ -578,16 +502,7 @@ 6 - - 0 - - - 0 - - - 0 - - + 0 @@ -613,16 +528,7 @@ 6 - - 0 - - - 0 - - - 0 - - + 0 @@ -643,16 +549,7 @@ 6 - - 0 - - - 0 - - - 0 - - + 0 @@ -660,7 +557,7 @@ Qt::Horizontal - + 40 20 @@ -711,7 +608,7 @@ Qt::Horizontal - + 40 20 @@ -728,16 +625,7 @@ 6 - - 0 - - - 0 - - - 0 - - + 0 @@ -745,7 +633,7 @@ Qt::Vertical - + 20 40 @@ -796,7 +684,7 @@ Qt::Vertical - + 20 40 @@ -813,16 +701,7 @@ 6 - - 0 - - - 0 - - - 0 - - + 0 @@ -867,7 +746,7 @@ Qt::Horizontal - + 40 20 @@ -885,7 +764,7 @@ QSizePolicy::Minimum - + 20 40 @@ -903,16 +782,7 @@ 6 - - 9 - - - 9 - - - 9 - - + 9 @@ -936,16 +806,7 @@ 6 - - 0 - - - 0 - - - 0 - - + 0 @@ -953,7 +814,7 @@ Qt::Horizontal - + 40 20 @@ -992,7 +853,7 @@ Qt::Horizontal - + 40 20 @@ -1007,7 +868,7 @@ Qt::Vertical - + 20 40 @@ -1066,7 +927,7 @@ Qt::Horizontal - + 40 20 @@ -1093,7 +954,7 @@ Qt::Horizontal - + 40 20 @@ -1136,16 +997,7 @@ 6 - - 0 - - - 0 - - - 0 - - + 0 @@ -1153,7 +1005,7 @@ Qt::Horizontal - + 40 20 @@ -1173,7 +1025,7 @@ Qt::Horizontal - + 40 20 diff --git a/src/properties_imp.cpp b/src/properties_imp.cpp index 741c60ff5..a7f55a4bb 100644 --- a/src/properties_imp.cpp +++ b/src/properties_imp.cpp @@ -35,6 +35,7 @@ #include #include #include +#include // Constructor properties::properties(QWidget *parent, bittorrent *BTSession, QTorrentHandle &h): QDialog(parent), h(h), BTSession(BTSession), changedFilteredfiles(false), hash(h.hash()) { @@ -677,6 +678,35 @@ void properties::on_incrementalDownload_stateChanged(int){ } } +void properties::on_changeSavePathButton_clicked() { + QString dir; + QDir saveDir(h.save_path()); + if(saveDir.exists()){ + dir = QFileDialog::getExistingDirectory(this, tr("Choose save path"), h.save_path()); + }else{ + dir = QFileDialog::getExistingDirectory(this, tr("Choose save path"), QDir::homePath()); + } + if(!dir.isNull()){ + // Check if savePath exists + QDir savePath(dir); + if(!savePath.exists()){ + if(!savePath.mkpath(savePath.path())){ + QMessageBox::critical(0, tr("Save path creation error"), tr("Could not create the save path")); + return; + } + } + // Save savepath + QFile savepath_file(misc::qBittorrentPath()+QString::fromUtf8("BT_backup")+QDir::separator()+hash+QString::fromUtf8(".savepath")); + savepath_file.open(QIODevice::WriteOnly | QIODevice::Text); + savepath_file.write(savePath.path().toUtf8()); + savepath_file.close(); + // Actually move storage + h.move_storage(savePath.path()); + // Update save_path in dialog + save_path->setText(savePath.path()); + } +} + void properties::on_okButton_clicked(){ if(savePiecesPriorities()) close(); diff --git a/src/properties_imp.h b/src/properties_imp.h index 073df95ec..d1ed50732 100644 --- a/src/properties_imp.h +++ b/src/properties_imp.h @@ -80,6 +80,7 @@ class properties : public QDialog, private Ui::properties{ void addTrackerList(QStringList myTrackers); void writeSettings(); void loadSettings(); + void on_changeSavePathButton_clicked(); signals: void filteredFilesChanged(QString hash); diff --git a/src/qtorrenthandle.cpp b/src/qtorrenthandle.cpp index 9a3a74dc0..3f01fc86c 100644 --- a/src/qtorrenthandle.cpp +++ b/src/qtorrenthandle.cpp @@ -393,6 +393,11 @@ void QTorrentHandle::force_recheck() const { h.force_recheck(); } +void QTorrentHandle::move_storage(QString new_path) const { + Q_ASSERT(h.is_valid()); + h.move_storage(new_path.toUtf8().data()); +} + // // Operators // diff --git a/src/qtorrenthandle.h b/src/qtorrenthandle.h index 387c66352..20d4920af 100644 --- a/src/qtorrenthandle.h +++ b/src/qtorrenthandle.h @@ -119,6 +119,7 @@ class QTorrentHandle { void queue_position_up() const; void auto_managed(bool) const; void force_recheck() const; + void move_storage(QString path) const; // // Operators