Opened 8 years ago

Closed 8 years ago

#5374 closed Enhancement (fixed)

QT Transmission can not add more than one torrent file via drag and drop

Reported by: kernel_daemon Owned by: jordan
Priority: Normal Milestone: 2.80
Component: Qt Client Version: 2.77
Severity: Normal Keywords:
Cc:

Description

If you try to drop multiple torrent files over QT Version of transmission, the files can not be added.

I attached a patch that fix that issue.


Index: mainwin.cc =================================================================== --- mainwin.cc (revision 14083) +++ mainwin.cc (working copy) @@ -1407,13 +1407,19 @@

void

TrMainWindow?
dropEvent (QDropEvent * event) {
QString key = event->mimeData ()->text ().trimmed ();

+ QStringList list = event->mimeData()->text().trimmed().split('\n');

  • const QUrl url (key);
  • if (url.scheme () == "file")
  • key = QUrl::fromPercentEncoding (url.path ().toUtf8 ());

+ foreach (QString entry, list) { + QString key = entry.trimmed(); + if (!key.isEmpty()){ + const QUrl url (key); + if (url.scheme () == "file") + key = QUrl::fromPercentEncoding (url.path ().toUtf8 ());

  • dynamic_cast<MyApp?*> (QApplication::instance ())->addTorrent (key);

+ dynamic_cast<MyApp?*> (QApplication::instance ())->addTorrent (key); + } + } + qDebug() << "Added " << list.size() << " entries.";

}

/*

Attachments (2)

transmission_add_multifiles.diff (976 bytes) - added by kernel_daemon 8 years ago.
drag and drop fix issue
001-DnD_torrent_files.patch (1.2 KB) - added by rb07 8 years ago.

Download all attachments as: .zip

Change History (6)

Changed 8 years ago by kernel_daemon

drag and drop fix issue

comment:1 Changed 8 years ago by jordan

  • Milestone changed from None Set to 2.80
  • Status changed from new to assigned

comment:2 Changed 8 years ago by jordan

  • Resolution set to fixed
  • Status changed from assigned to closed

Thanks for the patch!

Added in r14092.

comment:3 Changed 8 years ago by rb07

  • Resolution fixed deleted
  • Status changed from closed to reopened

Does this work with actual files? On Windows it doesn't.

It works fine with URLs and magnets (I don't know how to select more than one, but it works with one); doesn't work with files... in fact, D&D never worked with files, they where rejected at dragEnterEvent().

The attached patch fixes that.

Explanation: (At least on Windows, where there is no "application/x-bittorrent" MIME type, unless I define it) a files' MIME type includes "text/uri-list", but no "text/plain". URLs & magnets include both, I use that difference to keep the current behavior, and add the file list for the missing functionality (I don't think we need to differentiate OSes with #if defined... I expect Linux does include the uri-list for files too).

I left the test for empty string, which I suspect was a workaround for the file case (i.e. files have no text/plain, so if a list reached dropEvent(), the list as text was empty, or a list of empty strings -- besides, if the files have foreign characters, even if you get the list as text, its probably wrong).

Last edited 8 years ago by rb07 (previous) (diff)

Changed 8 years ago by rb07

comment:4 Changed 8 years ago by jordan

  • Resolution set to fixed
  • Status changed from reopened to closed

revision added in r14098, thanks :)

Note: See TracTickets for help on using tickets.