Skip to content

Commit

Permalink
Add "Preview file" double-click action
Browse files Browse the repository at this point in the history
  • Loading branch information
j1warren committed Nov 11, 2019
1 parent d12468f commit 74009f1
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/gui/optionsdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ enum DoubleClickAction
{
TOGGLE_PAUSE,
OPEN_DEST,
PREVIEW_FILE,
NO_ACTION
};

Expand Down
5 changes: 5 additions & 0 deletions src/gui/optionsdialog.ui
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,11 @@
<string>Open destination folder</string>
</property>
</item>
<item>
<property name="text">
<string>Preview file, otherwise open destination folder</string>
</property>
</item>
<item>
<property name="text">
<string>No action</string>
Expand Down
32 changes: 24 additions & 8 deletions src/gui/transferlistwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,18 @@ namespace
return false;
}

void openDestinationFolder(const BitTorrent::TorrentHandle *const torrent)
{
#ifdef Q_OS_MACOS
MacUtils::openFiles(QSet<QString>{torrent->contentPath(true)});
#else
if (torrent->filesCount() == 1)
Utils::Gui::openFolderSelect(torrent->contentPath(true));
else
Utils::Gui::openPath(torrent->contentPath(true));
#endif
}

void removeTorrents(const QVector<BitTorrent::TorrentHandle *> &torrents, const bool isDeleteFileSelected)
{
auto *session = BitTorrent::Session::instance();
Expand Down Expand Up @@ -269,15 +281,19 @@ void TransferListWidget::torrentDoubleClicked()
else
torrent->pause();
break;
case PREVIEW_FILE:
if (torrentContainsPreviewableFiles(torrent)) {
auto *dialog = new PreviewSelectDialog(this, torrent);
dialog->setAttribute(Qt::WA_DeleteOnClose);
connect(dialog, &PreviewSelectDialog::readyToPreviewFile, this, &TransferListWidget::previewFile);
dialog->show();
}
else {
openDestinationFolder(torrent);
}
break;
case OPEN_DEST:
#ifdef Q_OS_MACOS
MacUtils::openFiles(QSet<QString>{torrent->contentPath(true)});
#else
if (torrent->filesCount() == 1)
Utils::Gui::openFolderSelect(torrent->contentPath(true));
else
Utils::Gui::openPath(torrent->contentPath(true));
#endif
openDestinationFolder(torrent);
break;
}
}
Expand Down

0 comments on commit 74009f1

Please sign in to comment.