mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-08-21 05:43:32 -07:00
Don't start separate event loop for QFileDialog
It conflicts with QMenu on Qt6 that causes the crash. PR #16158.
This commit is contained in:
parent
4d54fb675f
commit
5d69334287
1 changed files with 25 additions and 9 deletions
|
@ -331,19 +331,35 @@ QVector<BitTorrent::Torrent *> TransferListWidget::getVisibleTorrents() const
|
||||||
void TransferListWidget::setSelectedTorrentsLocation()
|
void TransferListWidget::setSelectedTorrentsLocation()
|
||||||
{
|
{
|
||||||
const QVector<BitTorrent::Torrent *> torrents = getSelectedTorrents();
|
const QVector<BitTorrent::Torrent *> torrents = getSelectedTorrents();
|
||||||
if (torrents.isEmpty()) return;
|
if (torrents.isEmpty())
|
||||||
|
return;
|
||||||
|
|
||||||
const QString oldLocation = torrents[0]->savePath();
|
const QString oldLocation = torrents[0]->savePath();
|
||||||
const QString newLocation = QFileDialog::getExistingDirectory(this, tr("Choose save path"), oldLocation,
|
|
||||||
(QFileDialog::DontConfirmOverwrite | QFileDialog::ShowDirsOnly | QFileDialog::HideNameFilterDetails));
|
auto fileDialog = new QFileDialog(this, tr("Choose save path"), oldLocation);
|
||||||
if (newLocation.isEmpty() || !QDir(newLocation).exists()) return;
|
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]()
|
||||||
|
{
|
||||||
|
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
|
// Actually move storage
|
||||||
for (BitTorrent::Torrent *const torrent : torrents)
|
for (BitTorrent::Torrent *const torrent : torrents)
|
||||||
{
|
{
|
||||||
torrent->setAutoTMMEnabled(false);
|
torrent->setAutoTMMEnabled(false);
|
||||||
torrent->setSavePath(Utils::Fs::expandPathAbs(newLocation));
|
torrent->setSavePath(newLocation);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
fileDialog->show();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListWidget::pauseAllTorrents()
|
void TransferListWidget::pauseAllTorrents()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue