mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
- Fix several bugs in new "Append label to save path" feature
This commit is contained in:
parent
dc0ad73eca
commit
411a1c641d
@ -1325,18 +1325,25 @@ void Bittorrent::changeLabelInTorrentSavePath(QTorrentHandle h, QString old_labe
|
|||||||
bool move_storage = (old_dir == QDir(h.save_path()));
|
bool move_storage = (old_dir == QDir(h.save_path()));
|
||||||
if(!old_label.isEmpty()) {
|
if(!old_label.isEmpty()) {
|
||||||
Q_ASSERT(old_dir.dirName() == old_label);
|
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;
|
QString new_save_path;
|
||||||
if(new_label.isEmpty())
|
if(new_label.isEmpty())
|
||||||
new_save_path = old_dir.absolutePath();
|
new_save_path = old_dir.absolutePath();
|
||||||
else
|
else
|
||||||
old_dir.absoluteFilePath(new_label);
|
new_save_path = old_dir.absoluteFilePath(new_label);
|
||||||
TorrentPersistentData::saveSavePath(h.hash(), new_save_path);
|
TorrentPersistentData::saveSavePath(h.hash(), new_save_path);
|
||||||
if(move_storage) {
|
if(move_storage) {
|
||||||
// Move storage
|
// Move storage
|
||||||
h.move_storage(new_save_path);
|
h.move_storage(new_save_path);
|
||||||
}
|
}
|
||||||
|
emit savePathChanged(h);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Bittorrent::appendLabelToTorrentSavePath(QTorrentHandle h) {
|
void Bittorrent::appendLabelToTorrentSavePath(QTorrentHandle h) {
|
||||||
@ -1353,6 +1360,7 @@ void Bittorrent::appendLabelToTorrentSavePath(QTorrentHandle h) {
|
|||||||
// Move storage
|
// Move storage
|
||||||
h.move_storage(new_save_path);
|
h.move_storage(new_save_path);
|
||||||
}
|
}
|
||||||
|
emit savePathChanged(h);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -245,6 +245,7 @@ signals:
|
|||||||
void downloadFromUrlFailure(QString url, QString reason);
|
void downloadFromUrlFailure(QString url, QString reason);
|
||||||
void torrentFinishedChecking(QTorrentHandle& h);
|
void torrentFinishedChecking(QTorrentHandle& h);
|
||||||
void metadataReceived(QTorrentHandle &h);
|
void metadataReceived(QTorrentHandle &h);
|
||||||
|
void savePathChanged(QTorrentHandle &h);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -98,6 +98,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, GUI* main_window, TransferLi
|
|||||||
connect(transferList, SIGNAL(currentTorrentChanged(QTorrentHandle&)), this, SLOT(loadTorrentInfos(QTorrentHandle &)));
|
connect(transferList, SIGNAL(currentTorrentChanged(QTorrentHandle&)), this, SLOT(loadTorrentInfos(QTorrentHandle &)));
|
||||||
connect(PropDelegate, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged()));
|
connect(PropDelegate, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged()));
|
||||||
connect(stackedProperties, SIGNAL(currentChanged(int)), this, SLOT(loadDynamicData()));
|
connect(stackedProperties, SIGNAL(currentChanged(int)), this, SLOT(loadDynamicData()));
|
||||||
|
connect(BTSession, SIGNAL(savePathChanged(QTorrentHandle&)), this, SLOT(updateSavePath(QTorrentHandle&)));
|
||||||
|
|
||||||
// Downloaded pieces progress bar
|
// Downloaded pieces progress bar
|
||||||
downloaded_pieces = new DownloadedPiecesBar(this);
|
downloaded_pieces = new DownloadedPiecesBar(this);
|
||||||
@ -211,6 +212,12 @@ Bittorrent* PropertiesWidget::getBTSession() const {
|
|||||||
return BTSession;
|
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) {
|
void PropertiesWidget::loadTorrentInfos(QTorrentHandle &_h) {
|
||||||
clear();
|
clear();
|
||||||
h = _h;
|
h = _h;
|
||||||
|
@ -97,6 +97,7 @@ protected slots:
|
|||||||
void filteredFilesChanged();
|
void filteredFilesChanged();
|
||||||
void showPiecesDownloaded(bool show);
|
void showPiecesDownloaded(bool show);
|
||||||
void showPiecesAvailability(bool show);
|
void showPiecesAvailability(bool show);
|
||||||
|
void updateSavePath(QTorrentHandle& h);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void loadDynamicData();
|
void loadDynamicData();
|
||||||
|
Loading…
Reference in New Issue
Block a user