|
|
@ -28,7 +28,6 @@ |
|
|
|
|
|
|
|
|
|
|
|
#include "propertieswidget.h" |
|
|
|
#include "propertieswidget.h" |
|
|
|
|
|
|
|
|
|
|
|
#include <QAction> |
|
|
|
|
|
|
|
#include <QClipboard> |
|
|
|
#include <QClipboard> |
|
|
|
#include <QDateTime> |
|
|
|
#include <QDateTime> |
|
|
|
#include <QDebug> |
|
|
|
#include <QDebug> |
|
|
@ -586,57 +585,82 @@ void PropertiesWidget::displayFilesListMenu(const QPoint &) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const QModelIndex index = selectedRows[0]; |
|
|
|
const QModelIndex index = selectedRows[0]; |
|
|
|
|
|
|
|
|
|
|
|
const QAction *actOpen = menu->addAction(UIThemeManager::instance()->getIcon("folder-documents"), tr("Open")); |
|
|
|
menu->addAction(UIThemeManager::instance()->getIcon("folder-documents"), tr("Open") |
|
|
|
connect(actOpen, &QAction::triggered, this, [this, index]() { openItem(index); }); |
|
|
|
, this, [this, index]() { openItem(index); }); |
|
|
|
|
|
|
|
menu->addAction(UIThemeManager::instance()->getIcon("inode-directory"), tr("Open Containing Folder") |
|
|
|
const QAction *actOpenContainingFolder = menu->addAction(UIThemeManager::instance()->getIcon("inode-directory"), tr("Open Containing Folder")); |
|
|
|
, this, [this, index]() { openParentFolder(index); }); |
|
|
|
connect(actOpenContainingFolder, &QAction::triggered, this, [this, index]() { openParentFolder(index); }); |
|
|
|
menu->addAction(UIThemeManager::instance()->getIcon("edit-rename"), tr("Rename...") |
|
|
|
|
|
|
|
, this, [this]() { m_ui->filesList->renameSelectedFile(*m_torrent); }); |
|
|
|
const QAction *actRename = menu->addAction(UIThemeManager::instance()->getIcon("edit-rename"), tr("Rename...")); |
|
|
|
|
|
|
|
connect(actRename, &QAction::triggered, this, [this]() { m_ui->filesList->renameSelectedFile(*m_torrent); }); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
menu->addSeparator(); |
|
|
|
menu->addSeparator(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
if (!m_torrent->isSeed()) |
|
|
|
if (!m_torrent->isSeed()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
QMenu *subMenu = menu->addMenu(tr("Priority")); |
|
|
|
const auto applyPriorities = [this](const BitTorrent::DownloadPriority prio) |
|
|
|
|
|
|
|
|
|
|
|
const auto applyPriorities = [this, selectedRows](const BitTorrent::DownloadPriority prio) |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
const QModelIndexList selectedRows = m_ui->filesList->selectionModel()->selectedRows(0); |
|
|
|
for (const QModelIndex &index : selectedRows) |
|
|
|
for (const QModelIndex &index : selectedRows) |
|
|
|
{ |
|
|
|
{ |
|
|
|
m_propListModel->setData( |
|
|
|
m_propListModel->setData(index.sibling(index.row(), PRIORITY) |
|
|
|
m_propListModel->index(index.row(), PRIORITY, index.parent()), static_cast<int>(prio)); |
|
|
|
, static_cast<int>(prio)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Save changes
|
|
|
|
// Save changes
|
|
|
|
filteredFilesChanged(); |
|
|
|
filteredFilesChanged(); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
connect(m_ui->actionNotDownloaded, &QAction::triggered, subMenu, [applyPriorities]() |
|
|
|
QMenu *subMenu = menu->addMenu(tr("Priority")); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subMenu->addAction(tr("Do not download"), subMenu, [applyPriorities]() |
|
|
|
{ |
|
|
|
{ |
|
|
|
applyPriorities(BitTorrent::DownloadPriority::Ignored); |
|
|
|
applyPriorities(BitTorrent::DownloadPriority::Ignored); |
|
|
|
}); |
|
|
|
}); |
|
|
|
subMenu->addAction(m_ui->actionNotDownloaded); |
|
|
|
subMenu->addAction(tr("Normal"), subMenu, [applyPriorities]() |
|
|
|
|
|
|
|
|
|
|
|
connect(m_ui->actionNormal, &QAction::triggered, subMenu, [applyPriorities]() |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
applyPriorities(BitTorrent::DownloadPriority::Normal); |
|
|
|
applyPriorities(BitTorrent::DownloadPriority::Normal); |
|
|
|
}); |
|
|
|
}); |
|
|
|
subMenu->addAction(m_ui->actionNormal); |
|
|
|
subMenu->addAction(tr("High"), subMenu, [applyPriorities]() |
|
|
|
|
|
|
|
|
|
|
|
connect(m_ui->actionHigh, &QAction::triggered, subMenu, [applyPriorities]() |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
applyPriorities(BitTorrent::DownloadPriority::High); |
|
|
|
applyPriorities(BitTorrent::DownloadPriority::High); |
|
|
|
}); |
|
|
|
}); |
|
|
|
subMenu->addAction(m_ui->actionHigh); |
|
|
|
subMenu->addAction(tr("Maximum"), subMenu, [applyPriorities]() |
|
|
|
|
|
|
|
|
|
|
|
connect(m_ui->actionMaximum, &QAction::triggered, subMenu, [applyPriorities]() |
|
|
|
|
|
|
|
{ |
|
|
|
{ |
|
|
|
applyPriorities(BitTorrent::DownloadPriority::Maximum); |
|
|
|
applyPriorities(BitTorrent::DownloadPriority::Maximum); |
|
|
|
}); |
|
|
|
}); |
|
|
|
subMenu->addAction(m_ui->actionMaximum); |
|
|
|
subMenu->addSeparator(); |
|
|
|
|
|
|
|
subMenu->addAction(tr("By shown file order"), subMenu, [this]() |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
// Equally distribute the selected items into groups and for each group assign
|
|
|
|
|
|
|
|
// a download priority that will apply to each item. The number of groups depends on how
|
|
|
|
|
|
|
|
// many "download priority" are available to be assigned
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const QModelIndexList selectedRows = m_ui->filesList->selectionModel()->selectedRows(0); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const int priorityGroups = 3; |
|
|
|
|
|
|
|
const int priorityGroupSize = std::max((selectedRows.length() / priorityGroups), 1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < selectedRows.length(); ++i) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
auto priority = BitTorrent::DownloadPriority::Ignored; |
|
|
|
|
|
|
|
switch (i / priorityGroupSize) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
case 0: |
|
|
|
|
|
|
|
priority = BitTorrent::DownloadPriority::Maximum; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case 1: |
|
|
|
|
|
|
|
priority = BitTorrent::DownloadPriority::High; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
default: |
|
|
|
|
|
|
|
case 2: |
|
|
|
|
|
|
|
priority = BitTorrent::DownloadPriority::Normal; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const QModelIndex &index = selectedRows[i]; |
|
|
|
|
|
|
|
m_propListModel->setData(index.sibling(index.row(), PRIORITY) |
|
|
|
|
|
|
|
, static_cast<int>(priority)); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// The selected torrent might have disappeared during exec()
|
|
|
|
// The selected torrent might have disappeared during exec()
|
|
|
@ -660,21 +684,17 @@ void PropertiesWidget::displayWebSeedListMenu(const QPoint &) |
|
|
|
QMenu *menu = new QMenu(this); |
|
|
|
QMenu *menu = new QMenu(this); |
|
|
|
menu->setAttribute(Qt::WA_DeleteOnClose); |
|
|
|
menu->setAttribute(Qt::WA_DeleteOnClose); |
|
|
|
|
|
|
|
|
|
|
|
const QAction *actAdd = menu->addAction(UIThemeManager::instance()->getIcon("list-add"), tr("New Web seed")); |
|
|
|
menu->addAction(UIThemeManager::instance()->getIcon("list-add"), tr("New Web seed"), this, &PropertiesWidget::askWebSeed); |
|
|
|
connect(actAdd, &QAction::triggered, this, &PropertiesWidget::askWebSeed); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!rows.isEmpty()) |
|
|
|
if (!rows.isEmpty()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
const QAction *actDel = menu->addAction(UIThemeManager::instance()->getIcon("list-remove"), tr("Remove Web seed")); |
|
|
|
menu->addAction(UIThemeManager::instance()->getIcon("list-remove"), tr("Remove Web seed") |
|
|
|
connect(actDel, &QAction::triggered, this, &PropertiesWidget::deleteSelectedUrlSeeds); |
|
|
|
, this, &PropertiesWidget::deleteSelectedUrlSeeds); |
|
|
|
|
|
|
|
|
|
|
|
menu->addSeparator(); |
|
|
|
menu->addSeparator(); |
|
|
|
|
|
|
|
menu->addAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Copy Web seed URL") |
|
|
|
const QAction *actCpy = menu->addAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Copy Web seed URL")); |
|
|
|
, this, &PropertiesWidget::copySelectedWebSeedsToClipboard); |
|
|
|
connect(actCpy, &QAction::triggered, this, &PropertiesWidget::copySelectedWebSeedsToClipboard); |
|
|
|
menu->addAction(UIThemeManager::instance()->getIcon("edit-rename"), tr("Edit Web seed URL") |
|
|
|
|
|
|
|
, this, &PropertiesWidget::editWebSeed); |
|
|
|
const QAction *actEdit = menu->addAction(UIThemeManager::instance()->getIcon("edit-rename"), tr("Edit Web seed URL")); |
|
|
|
|
|
|
|
connect(actEdit, &QAction::triggered, this, &PropertiesWidget::editWebSeed); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
menu->popup(QCursor::pos()); |
|
|
|
menu->popup(QCursor::pos()); |
|
|
|