|
|
@ -34,6 +34,8 @@ |
|
|
|
|
|
|
|
|
|
|
|
FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession){ |
|
|
|
FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession){ |
|
|
|
setupUi(this); |
|
|
|
setupUi(this); |
|
|
|
|
|
|
|
actionStart->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/play.png"))); |
|
|
|
|
|
|
|
actionPause->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/pause.png"))); |
|
|
|
nbFinished = 0; |
|
|
|
nbFinished = 0; |
|
|
|
this->BTSession = BTSession; |
|
|
|
this->BTSession = BTSession; |
|
|
|
this->parent = parent; |
|
|
|
this->parent = parent; |
|
|
@ -65,6 +67,8 @@ FinishedTorrents::FinishedTorrents(QObject *parent, bittorrent *BTSession){ |
|
|
|
actionDelete_Permanently->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/delete_perm.png"))); |
|
|
|
actionDelete_Permanently->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/delete_perm.png"))); |
|
|
|
actionTorrent_Properties->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/properties.png"))); |
|
|
|
actionTorrent_Properties->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/properties.png"))); |
|
|
|
actionSet_upload_limit->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/seeding.png"))); |
|
|
|
actionSet_upload_limit->setIcon(QIcon(QString::fromUtf8(":/Icons/skin/seeding.png"))); |
|
|
|
|
|
|
|
connect(actionPause, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionPause_triggered())); |
|
|
|
|
|
|
|
connect(actionStart, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionStart_triggered())); |
|
|
|
connect(actionDelete, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionDelete_triggered())); |
|
|
|
connect(actionDelete, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionDelete_triggered())); |
|
|
|
connect(actionPreview_file, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionPreview_file_triggered())); |
|
|
|
connect(actionPreview_file, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionPreview_file_triggered())); |
|
|
|
connect(actionDelete_Permanently, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionDelete_Permanently_triggered())); |
|
|
|
connect(actionDelete_Permanently, SIGNAL(triggered()), (GUI*)parent, SLOT(on_actionDelete_Permanently_triggered())); |
|
|
@ -301,21 +305,39 @@ void FinishedTorrents::displayFinishedListMenu(const QPoint& pos){ |
|
|
|
QModelIndexList selectedIndexes = finishedList->selectionModel()->selectedIndexes(); |
|
|
|
QModelIndexList selectedIndexes = finishedList->selectionModel()->selectedIndexes(); |
|
|
|
QSettings settings("qBittorrent", "qBittorrent"); |
|
|
|
QSettings settings("qBittorrent", "qBittorrent"); |
|
|
|
QString previewProgram = settings.value("Options/Misc/PreviewProgram", QString()).toString(); |
|
|
|
QString previewProgram = settings.value("Options/Misc/PreviewProgram", QString()).toString(); |
|
|
|
foreach(index, selectedIndexes){ |
|
|
|
bool has_pause = false, has_start = false, has_preview = false; |
|
|
|
if(index.column() == F_NAME){ |
|
|
|
foreach(index, selectedIndexes) { |
|
|
|
|
|
|
|
if(index.column() == F_NAME) { |
|
|
|
// Get the file name
|
|
|
|
// Get the file name
|
|
|
|
QString hash = finishedListModel->data(finishedListModel->index(index.row(), F_HASH)).toString(); |
|
|
|
QString hash = finishedListModel->data(finishedListModel->index(index.row(), F_HASH)).toString(); |
|
|
|
|
|
|
|
// Get handle and pause the torrent
|
|
|
|
QTorrentHandle h = BTSession->getTorrentHandle(hash); |
|
|
|
QTorrentHandle h = BTSession->getTorrentHandle(hash); |
|
|
|
myFinishedListMenu.addAction(actionDelete); |
|
|
|
if(!h.is_valid()) continue; |
|
|
|
myFinishedListMenu.addAction(actionDelete_Permanently); |
|
|
|
if(h.is_paused()) { |
|
|
|
myFinishedListMenu.addAction(actionSet_upload_limit); |
|
|
|
if(!has_start) { |
|
|
|
myFinishedListMenu.addAction(actionTorrent_Properties); |
|
|
|
myFinishedListMenu.addAction(actionStart); |
|
|
|
if(!previewProgram.isEmpty() && BTSession->isFilePreviewPossible(hash) && selectedIndexes.size()<=finishedListModel->columnCount()){ |
|
|
|
has_start = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}else{ |
|
|
|
|
|
|
|
if(!has_pause) { |
|
|
|
|
|
|
|
myFinishedListMenu.addAction(actionPause); |
|
|
|
|
|
|
|
has_pause = true; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
if(!previewProgram.isEmpty() && BTSession->isFilePreviewPossible(hash) && !has_preview) { |
|
|
|
myFinishedListMenu.addAction(actionPreview_file); |
|
|
|
myFinishedListMenu.addAction(actionPreview_file); |
|
|
|
|
|
|
|
has_preview = true; |
|
|
|
} |
|
|
|
} |
|
|
|
break; |
|
|
|
if(has_pause && has_start && has_preview) break; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
myFinishedListMenu.addSeparator(); |
|
|
|
|
|
|
|
myFinishedListMenu.addAction(actionDelete); |
|
|
|
|
|
|
|
myFinishedListMenu.addAction(actionDelete_Permanently); |
|
|
|
|
|
|
|
myFinishedListMenu.addSeparator(); |
|
|
|
|
|
|
|
myFinishedListMenu.addAction(actionSet_upload_limit); |
|
|
|
|
|
|
|
myFinishedListMenu.addSeparator(); |
|
|
|
|
|
|
|
myFinishedListMenu.addAction(actionTorrent_Properties); |
|
|
|
// Call menu
|
|
|
|
// Call menu
|
|
|
|
// XXX: why mapToGlobal() is not enough?
|
|
|
|
// XXX: why mapToGlobal() is not enough?
|
|
|
|
myFinishedListMenu.exec(mapToGlobal(pos)+QPoint(10,55)); |
|
|
|
myFinishedListMenu.exec(mapToGlobal(pos)+QPoint(10,55)); |
|
|
|