diff --git a/src/bittorrent.cpp b/src/bittorrent.cpp index fdeb030e3..c71e25ed7 100644 --- a/src/bittorrent.cpp +++ b/src/bittorrent.cpp @@ -1325,18 +1325,25 @@ void Bittorrent::changeLabelInTorrentSavePath(QTorrentHandle h, QString old_labe bool move_storage = (old_dir == QDir(h.save_path())); if(!old_label.isEmpty()) { Q_ASSERT(old_dir.dirName() == old_label); - old_dir.cdUp(); + QString path = old_save_path; + // Cd UP + if(path.endsWith(QDir::separator())) + path.chop(1); + QStringList path_items = path.split(QDir::separator()); + path_items.removeLast(); + old_dir = QDir(path_items.join(QDir::separator())); } QString new_save_path; if(new_label.isEmpty()) new_save_path = old_dir.absolutePath(); else - old_dir.absoluteFilePath(new_label); + new_save_path = old_dir.absoluteFilePath(new_label); TorrentPersistentData::saveSavePath(h.hash(), new_save_path); if(move_storage) { // Move storage h.move_storage(new_save_path); } + emit savePathChanged(h); } void Bittorrent::appendLabelToTorrentSavePath(QTorrentHandle h) { @@ -1353,6 +1360,7 @@ void Bittorrent::appendLabelToTorrentSavePath(QTorrentHandle h) { // Move storage h.move_storage(new_save_path); } + emit savePathChanged(h); } } diff --git a/src/bittorrent.h b/src/bittorrent.h index 58f7f48a5..417418163 100644 --- a/src/bittorrent.h +++ b/src/bittorrent.h @@ -245,6 +245,7 @@ signals: void downloadFromUrlFailure(QString url, QString reason); void torrentFinishedChecking(QTorrentHandle& h); void metadataReceived(QTorrentHandle &h); + void savePathChanged(QTorrentHandle &h); }; #endif diff --git a/src/propertieswidget.cpp b/src/propertieswidget.cpp index f9a66adab..e751bd53d 100644 --- a/src/propertieswidget.cpp +++ b/src/propertieswidget.cpp @@ -98,6 +98,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, GUI* main_window, TransferLi connect(transferList, SIGNAL(currentTorrentChanged(QTorrentHandle&)), this, SLOT(loadTorrentInfos(QTorrentHandle &))); connect(PropDelegate, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged())); connect(stackedProperties, SIGNAL(currentChanged(int)), this, SLOT(loadDynamicData())); + connect(BTSession, SIGNAL(savePathChanged(QTorrentHandle&)), this, SLOT(updateSavePath(QTorrentHandle&))); // Downloaded pieces progress bar downloaded_pieces = new DownloadedPiecesBar(this); @@ -211,6 +212,12 @@ Bittorrent* PropertiesWidget::getBTSession() const { return BTSession; } +void PropertiesWidget::updateSavePath(QTorrentHandle& _h) { + if(h.is_valid() && h == _h) { + save_path->setText(TorrentPersistentData::getSavePath(h.hash())); + } +} + void PropertiesWidget::loadTorrentInfos(QTorrentHandle &_h) { clear(); h = _h; diff --git a/src/propertieswidget.h b/src/propertieswidget.h index 44d481b05..206ceee26 100644 --- a/src/propertieswidget.h +++ b/src/propertieswidget.h @@ -97,6 +97,7 @@ protected slots: void filteredFilesChanged(); void showPiecesDownloaded(bool show); void showPiecesAvailability(bool show); + void updateSavePath(QTorrentHandle& h); public slots: void loadDynamicData();