Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport changes to v4.4 branch #16215

Merged
merged 2 commits into from
Jan 22, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 27 additions & 10 deletions src/gui/transferlistwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,19 +334,35 @@ QVector<BitTorrent::Torrent *> TransferListWidget::getVisibleTorrents() const
void TransferListWidget::setSelectedTorrentsLocation()
{
const QVector<BitTorrent::Torrent *> torrents = getSelectedTorrents();
if (torrents.isEmpty()) return;
if (torrents.isEmpty())
return;

const QString oldLocation = torrents[0]->savePath();
const QString newLocation = QFileDialog::getExistingDirectory(this, tr("Choose save path"), oldLocation,
(QFileDialog::DontConfirmOverwrite | QFileDialog::ShowDirsOnly | QFileDialog::HideNameFilterDetails));
if (newLocation.isEmpty() || !QDir(newLocation).exists()) return;

// Actually move storage
for (BitTorrent::Torrent *const torrent : torrents)
auto fileDialog = new QFileDialog(this, tr("Choose save path"), oldLocation);
fileDialog->setAttribute(Qt::WA_DeleteOnClose);
fileDialog->setFileMode(QFileDialog::Directory);
fileDialog->setModal(true);
fileDialog->setOptions(QFileDialog::DontConfirmOverwrite | QFileDialog::ShowDirsOnly | QFileDialog::HideNameFilterDetails);
connect(fileDialog, &QDialog::accepted, this, [this, fileDialog]()
{
torrent->setAutoTMMEnabled(false);
torrent->setSavePath(Utils::Fs::expandPathAbs(newLocation));
}
const QVector<BitTorrent::Torrent *> torrents = getSelectedTorrents();
if (torrents.isEmpty())
return;

const QString newLocation = fileDialog->selectedFiles().constFirst();
if (newLocation.isEmpty() || !QDir(newLocation).exists())
return;

// Actually move storage
for (BitTorrent::Torrent *const torrent : torrents)
{
torrent->setAutoTMMEnabled(false);
torrent->setSavePath(newLocation);
}
});

fileDialog->show();
}

void TransferListWidget::pauseAllTorrents()
Expand Down Expand Up @@ -1100,8 +1116,9 @@ void TransferListWidget::displayListMenu(const QPoint &)
? (prioritizeFirstLast ? Qt::Checked : Qt::Unchecked)
: Qt::PartiallyChecked);
listMenu->addAction(actionFirstLastPiecePrio);
}

addedPreviewAction = true;
}

if (addedPreviewAction)
listMenu->addSeparator();
Expand Down