diff --git a/Changelog b/Changelog index 1499ba65e..51c4711fd 100644 --- a/Changelog +++ b/Changelog @@ -11,6 +11,7 @@ - FEATURE: qBittorrent can identify itself as uTorrent, Vuze or KTorrent (Any stable version) - FEATURE: Torrents can be renamed in transfer list - FEATURE: Display torrent addition dialog for magnet links too + - FEATURE: Files contained in a torrent are opened on double click (files panel) - BUGFIX: Use XDG folders (.cache, .local) instead of .qbittorrent - COSMETIC: Use checkboxes to filter torrent content instead of comboboxes - COSMETIC: Use alternating row colors in transfer list (set in program preferences) diff --git a/src/propertieswidget.cpp b/src/propertieswidget.cpp index 6fc683f63..2fca3fdae 100644 --- a/src/propertieswidget.cpp +++ b/src/propertieswidget.cpp @@ -38,6 +38,7 @@ #include #include #include +#include #include #include "propertieswidget.h" #include "transferlistwidget.h" @@ -83,6 +84,7 @@ PropertiesWidget::PropertiesWidget(QWidget *parent, GUI* main_window, TransferLi connect(collapseAllButton, SIGNAL(clicked()), filesList, SLOT(collapseAll())); connect(expandAllButton, SIGNAL(clicked()), filesList, SLOT(expandAll())); connect(filesList, SIGNAL(customContextMenuRequested(const QPoint&)), this, SLOT(displayFilesListMenu(const QPoint&))); + connect(filesList, SIGNAL(doubleClicked(QModelIndex)), this, SLOT(openDoubleClickedFile(QModelIndex))); connect(PropListModel, SIGNAL(filteredFilesChanged()), this, SLOT(filteredFilesChanged())); connect(addWS_button, SIGNAL(clicked()), this, SLOT(askWebSeed())); connect(deleteWS_button, SIGNAL(clicked()), this, SLOT(deleteSelectedUrlSeeds())); @@ -467,6 +469,22 @@ void PropertiesWidget::on_files_button_clicked() { } } +void PropertiesWidget::openDoubleClickedFile(QModelIndex index) { + if(!index.isValid()) return; + if(!h.is_valid() || !h.has_metadata()) return; + if(PropListModel->getType(index) == TFILE) { + int i = PropListModel->getFileIndex(index); + QDir saveDir(h.save_path()); + QString filename = misc::toQString(h.get_torrent_info().file_at(i).path.string()); + QString file_path = QDir::cleanPath(saveDir.absoluteFilePath(filename)); + qDebug("Trying to open file at %s", file_path.toLocal8Bit().data()); + if(QFile::exists(file_path)) + QDesktopServices::openUrl("file://"+file_path); + else + QMessageBox::warning(this, tr("I/O Error"), tr("This file does not exist yet.")); + } +} + void PropertiesWidget::displayFilesListMenu(const QPoint&){ QMenu myFilesLlistMenu; QModelIndexList selectedRows = filesList->selectionModel()->selectedRows(0); diff --git a/src/propertieswidget.h b/src/propertieswidget.h index f8e987953..31436676b 100644 --- a/src/propertieswidget.h +++ b/src/propertieswidget.h @@ -100,6 +100,7 @@ public slots: void readSettings(); void saveSettings(); void reloadPreferences(); + void openDoubleClickedFile(QModelIndex); public: PropertiesWidget(QWidget *parent, GUI* main_window, TransferListWidget *transferList, Bittorrent* BTSession); diff --git a/src/qtorrenthandle.cpp b/src/qtorrenthandle.cpp index 004f9004f..00a33971f 100644 --- a/src/qtorrenthandle.cpp +++ b/src/qtorrenthandle.cpp @@ -357,11 +357,11 @@ size_type QTorrentHandle::total_payload_upload() { // to all files in a torrent QStringList QTorrentHandle::files_path() const { Q_ASSERT(h.is_valid()); - QString saveDir = misc::toQString(h.save_path().string()) + QDir::separator(); + QDir saveDir(misc::toQString(h.save_path().string())); QStringList res; torrent_info::file_iterator fi = h.get_torrent_info().begin_files(); while(fi != h.get_torrent_info().end_files()) { - res << QDir::cleanPath(saveDir + misc::toQString(fi->path.string())); + res << QDir::cleanPath(saveDir.absoluteFilePath(misc::toQString(fi->path.string()))); fi++; } return res;