mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2025-01-12 18:24:58 +08:00
Merge pull request #7915 from Chocobo1/dragndrop
Allow to drag-n-drop URLs into mainwindow to initiate download
This commit is contained in:
commit
c9720cad81
@ -1225,25 +1225,26 @@ void MainWindow::dropEvent(QDropEvent *event)
|
|||||||
// remove scheme
|
// remove scheme
|
||||||
QStringList files;
|
QStringList files;
|
||||||
if (event->mimeData()->hasUrls()) {
|
if (event->mimeData()->hasUrls()) {
|
||||||
const QList<QUrl> urls = event->mimeData()->urls();
|
foreach (const QUrl &url, event->mimeData()->urls()) {
|
||||||
foreach (const QUrl &url, urls) {
|
if (url.isEmpty())
|
||||||
if (!url.isEmpty()) {
|
continue;
|
||||||
if (url.scheme().compare("file", Qt::CaseInsensitive) == 0)
|
|
||||||
files << url.toLocalFile();
|
files << ((url.scheme().compare("file", Qt::CaseInsensitive) == 0)
|
||||||
else
|
? url.toLocalFile()
|
||||||
files << url.toString();
|
: url.toString());
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
files = event->mimeData()->text().split('\n');
|
files = event->mimeData()->text().split('\n');
|
||||||
}
|
}
|
||||||
|
|
||||||
// differentiate ".torrent" files and others
|
// differentiate ".torrent" files/links & magnet links from others
|
||||||
QStringList torrentFiles, otherFiles;
|
QStringList torrentFiles, otherFiles;
|
||||||
foreach (const QString &file, files) {
|
foreach (const QString &file, files) {
|
||||||
if (file.startsWith("magnet:", Qt::CaseInsensitive)
|
const bool isTorrentLink = (file.startsWith("magnet:", Qt::CaseInsensitive)
|
||||||
|| file.endsWith(C_TORRENT_FILE_EXTENSION, Qt::CaseInsensitive))
|
|| file.endsWith(C_TORRENT_FILE_EXTENSION, Qt::CaseInsensitive)
|
||||||
|
|| Utils::Misc::isUrl(file));
|
||||||
|
if (isTorrentLink)
|
||||||
torrentFiles << file;
|
torrentFiles << file;
|
||||||
else
|
else
|
||||||
otherFiles << file;
|
otherFiles << file;
|
||||||
|
Loading…
Reference in New Issue
Block a user