mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-02-04 19:04:30 +00:00
Fix "Open destination folder" functionality to consider torrent root folder
This commit is contained in:
parent
ee96f83211
commit
02c4be4eaa
@ -551,6 +551,18 @@ QString QTorrentHandle::firstFileSavePath() const {
|
||||
return fsave_path;
|
||||
}
|
||||
|
||||
QString QTorrentHandle::root_path() const
|
||||
{
|
||||
if (num_files() < 2)
|
||||
return save_path();
|
||||
QString first_filepath = filepath_at(0);
|
||||
const int slashIndex = first_filepath.indexOf(QRegExp("[/\\\\]"));
|
||||
QString root_folder;
|
||||
if (slashIndex >= 0)
|
||||
return QDir(save_path()).absoluteFilePath(first_filepath.left(slashIndex));
|
||||
return save_path();
|
||||
}
|
||||
|
||||
bool QTorrentHandle::has_error() const {
|
||||
#if LIBTORRENT_VERSION_MINOR > 15
|
||||
torrent_status st = torrent_handle::status(0x0);
|
||||
|
@ -402,16 +402,16 @@ void TransferListWidget::hidePriorityColumn(bool hide) {
|
||||
}
|
||||
|
||||
void TransferListWidget::openSelectedTorrentsFolder() const {
|
||||
QStringList pathsList;
|
||||
QSet<QString> pathsList;
|
||||
const QStringList hashes = getSelectedTorrentsHashes();
|
||||
foreach (const QString &hash, hashes) {
|
||||
const QTorrentHandle h = BTSession->getTorrentHandle(hash);
|
||||
if (h.is_valid()) {
|
||||
const QString savePath = h.save_path();
|
||||
qDebug("Opening path at %s", qPrintable(savePath));
|
||||
if (!pathsList.contains(savePath)) {
|
||||
pathsList.append(savePath);
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(savePath));
|
||||
QString rootFolder = h.root_path();
|
||||
qDebug("Opening path at %s", qPrintable(rootFolder));
|
||||
if (!pathsList.contains(rootFolder)) {
|
||||
pathsList.insert(rootFolder);
|
||||
QDesktopServices::openUrl(QUrl::fromLocalFile(rootFolder));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user