mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-11-28 13:28:50 +03:00
Merge pull request #14233 from Chocobo1/menu
Add ability to prioritize selected items by shown file order
This commit is contained in:
commit
f0b78ffc04
14 changed files with 196 additions and 269 deletions
|
@ -502,12 +502,12 @@ void AddNewTorrentDialog::displayContentTreeMenu(const QPoint &)
|
|||
{
|
||||
const QModelIndexList selectedRows = m_ui->contentTreeView->selectionModel()->selectedRows(0);
|
||||
|
||||
const auto applyPriorities = [this, selectedRows](const BitTorrent::DownloadPriority prio)
|
||||
const auto applyPriorities = [this](const BitTorrent::DownloadPriority prio)
|
||||
{
|
||||
const QModelIndexList selectedRows = m_ui->contentTreeView->selectionModel()->selectedRows(0);
|
||||
for (const QModelIndex &index : selectedRows)
|
||||
{
|
||||
m_contentModel->setData(
|
||||
m_contentModel->index(index.row(), PRIORITY, index.parent())
|
||||
m_contentModel->setData(index.sibling(index.row(), PRIORITY)
|
||||
, static_cast<int>(prio));
|
||||
}
|
||||
};
|
||||
|
@ -517,37 +517,63 @@ void AddNewTorrentDialog::displayContentTreeMenu(const QPoint &)
|
|||
|
||||
if (selectedRows.size() == 1)
|
||||
{
|
||||
QAction *actRename = menu->addAction(UIThemeManager::instance()->getIcon("edit-rename"), tr("Rename..."));
|
||||
connect(actRename, &QAction::triggered, this, [this]() { m_ui->contentTreeView->renameSelectedFile(m_torrentInfo); });
|
||||
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("edit-rename"), tr("Rename...")
|
||||
, this, [this]() { m_ui->contentTreeView->renameSelectedFile(m_torrentInfo); });
|
||||
menu->addSeparator();
|
||||
}
|
||||
|
||||
QMenu *subMenu = menu->addMenu(tr("Priority"));
|
||||
|
||||
connect(m_ui->actionNotDownloaded, &QAction::triggered, subMenu, [applyPriorities]()
|
||||
subMenu->addAction(tr("Do not download"), subMenu, [applyPriorities]()
|
||||
{
|
||||
applyPriorities(BitTorrent::DownloadPriority::Ignored);
|
||||
});
|
||||
subMenu->addAction(m_ui->actionNotDownloaded);
|
||||
|
||||
connect(m_ui->actionNormal, &QAction::triggered, subMenu, [applyPriorities]()
|
||||
subMenu->addAction(tr("Normal"), subMenu, [applyPriorities]()
|
||||
{
|
||||
applyPriorities(BitTorrent::DownloadPriority::Normal);
|
||||
});
|
||||
subMenu->addAction(m_ui->actionNormal);
|
||||
|
||||
connect(m_ui->actionHigh, &QAction::triggered, subMenu, [applyPriorities]()
|
||||
subMenu->addAction(tr("High"), subMenu, [applyPriorities]()
|
||||
{
|
||||
applyPriorities(BitTorrent::DownloadPriority::High);
|
||||
});
|
||||
subMenu->addAction(m_ui->actionHigh);
|
||||
|
||||
connect(m_ui->actionMaximum, &QAction::triggered, subMenu, [applyPriorities]()
|
||||
subMenu->addAction(tr("Maximum"), subMenu, [applyPriorities]()
|
||||
{
|
||||
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->contentTreeView->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_contentModel->setData(index.sibling(index.row(), PRIORITY)
|
||||
, static_cast<int>(priority));
|
||||
}
|
||||
});
|
||||
|
||||
menu->popup(QCursor::pos());
|
||||
}
|
||||
|
|
|
@ -449,26 +449,6 @@
|
|||
</layout>
|
||||
</item>
|
||||
</layout>
|
||||
<action name="actionNormal">
|
||||
<property name="text">
|
||||
<string>Normal</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionHigh">
|
||||
<property name="text">
|
||||
<string>High</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMaximum">
|
||||
<property name="text">
|
||||
<string>Maximum</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionNotDownloaded">
|
||||
<property name="text">
|
||||
<string>Do not download</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
#include "categoryfilterwidget.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
|
||||
#include "base/bittorrent/session.h"
|
||||
|
@ -110,54 +109,33 @@ void CategoryFilterWidget::showMenu(const QPoint &)
|
|||
QMenu *menu = new QMenu(this);
|
||||
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
const QAction *addAct = menu->addAction(
|
||||
UIThemeManager::instance()->getIcon("list-add")
|
||||
, tr("Add category..."));
|
||||
connect(addAct, &QAction::triggered, this, &CategoryFilterWidget::addCategory);
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("list-add"), tr("Add category...")
|
||||
, this, &CategoryFilterWidget::addCategory);
|
||||
|
||||
const auto selectedRows = selectionModel()->selectedRows();
|
||||
if (!selectedRows.empty() && !CategoryFilterModel::isSpecialItem(selectedRows.first()))
|
||||
{
|
||||
if (BitTorrent::Session::instance()->isSubcategoriesEnabled())
|
||||
{
|
||||
const QAction *addSubAct = menu->addAction(
|
||||
UIThemeManager::instance()->getIcon("list-add")
|
||||
, tr("Add subcategory..."));
|
||||
connect(addSubAct, &QAction::triggered, this, &CategoryFilterWidget::addSubcategory);
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("list-add"), tr("Add subcategory...")
|
||||
, this, &CategoryFilterWidget::addSubcategory);
|
||||
}
|
||||
|
||||
const QAction *editAct = menu->addAction(
|
||||
UIThemeManager::instance()->getIcon("document-edit")
|
||||
, tr("Edit category..."));
|
||||
connect(editAct, &QAction::triggered, this, &CategoryFilterWidget::editCategory);
|
||||
|
||||
const QAction *removeAct = menu->addAction(
|
||||
UIThemeManager::instance()->getIcon("list-remove")
|
||||
, tr("Remove category"));
|
||||
connect(removeAct, &QAction::triggered, this, &CategoryFilterWidget::removeCategory);
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("document-edit"), tr("Edit category...")
|
||||
, this, &CategoryFilterWidget::editCategory);
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("list-remove"), tr("Remove category")
|
||||
, this, &CategoryFilterWidget::removeCategory);
|
||||
}
|
||||
|
||||
const QAction *removeUnusedAct = menu->addAction(
|
||||
UIThemeManager::instance()->getIcon("list-remove")
|
||||
, tr("Remove unused categories"));
|
||||
connect(removeUnusedAct, &QAction::triggered, this, &CategoryFilterWidget::removeUnusedCategories);
|
||||
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("list-remove"), tr("Remove unused categories")
|
||||
, this, &CategoryFilterWidget::removeUnusedCategories);
|
||||
menu->addSeparator();
|
||||
|
||||
const QAction *startAct = menu->addAction(
|
||||
UIThemeManager::instance()->getIcon("media-playback-start")
|
||||
, tr("Resume torrents"));
|
||||
connect(startAct, &QAction::triggered, this, &CategoryFilterWidget::actionResumeTorrentsTriggered);
|
||||
|
||||
const QAction *pauseAct = menu->addAction(
|
||||
UIThemeManager::instance()->getIcon("media-playback-pause")
|
||||
, tr("Pause torrents"));
|
||||
connect(pauseAct, &QAction::triggered, this, &CategoryFilterWidget::actionPauseTorrentsTriggered);
|
||||
|
||||
const QAction *deleteTorrentsAct = menu->addAction(
|
||||
UIThemeManager::instance()->getIcon("edit-delete")
|
||||
, tr("Delete torrents"));
|
||||
connect(deleteTorrentsAct, &QAction::triggered, this, &CategoryFilterWidget::actionDeleteTorrentsTriggered);
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("media-playback-start"), tr("Resume torrents")
|
||||
, this, &CategoryFilterWidget::actionResumeTorrentsTriggered);
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("media-playback-pause"), tr("Pause torrents")
|
||||
, this, &CategoryFilterWidget::actionPauseTorrentsTriggered);
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("edit-delete"), tr("Delete torrents")
|
||||
, this, &CategoryFilterWidget::actionDeleteTorrentsTriggered);
|
||||
|
||||
menu->popup(QCursor::pos());
|
||||
}
|
||||
|
|
|
@ -91,12 +91,12 @@ void ExecutionLogWidget::displayContextMenu(const QPoint &pos, const LogListView
|
|||
// only show copy action if any of the row is selected
|
||||
if (view->currentIndex().isValid())
|
||||
{
|
||||
const QAction *copyAct = menu->addAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Copy"));
|
||||
connect(copyAct, &QAction::triggered, view, &LogListView::copySelection);
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Copy")
|
||||
, view, &LogListView::copySelection);
|
||||
}
|
||||
|
||||
const QAction *clearAct = menu->addAction(UIThemeManager::instance()->getIcon("edit-clear"), tr("Clear"));
|
||||
connect(clearAct, &QAction::triggered, model, &BaseLogModel::reset);
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("edit-clear"), tr("Clear")
|
||||
, model, &BaseLogModel::reset);
|
||||
|
||||
menu->popup(view->mapToGlobal(pos));
|
||||
}
|
||||
|
|
|
@ -195,10 +195,8 @@ MainWindow::MainWindow(QWidget *parent)
|
|||
m_ui->actionManageCookies->setIcon(UIThemeManager::instance()->getIcon("preferences-web-browser-cookies"));
|
||||
|
||||
auto *lockMenu = new QMenu(this);
|
||||
QAction *defineUiLockPasswdAct = lockMenu->addAction(tr("&Set Password"));
|
||||
connect(defineUiLockPasswdAct, &QAction::triggered, this, &MainWindow::defineUILockPassword);
|
||||
QAction *clearUiLockPasswdAct = lockMenu->addAction(tr("&Clear Password"));
|
||||
connect(clearUiLockPasswdAct, &QAction::triggered, this, &MainWindow::clearUILockPassword);
|
||||
lockMenu->addAction(tr("&Set Password"), this, &MainWindow::defineUILockPassword);
|
||||
lockMenu->addAction(tr("&Clear Password"), this, &MainWindow::clearUILockPassword);
|
||||
m_ui->actionLock->setMenu(lockMenu);
|
||||
|
||||
// Creating Bittorrent session
|
||||
|
@ -550,16 +548,11 @@ void MainWindow::addToolbarContextMenu()
|
|||
m_ui->toolBar->setContextMenuPolicy(Qt::CustomContextMenu);
|
||||
connect(m_ui->toolBar, &QWidget::customContextMenuRequested, this, &MainWindow::toolbarMenuRequested);
|
||||
|
||||
QAction *iconsOnly = m_toolbarMenu->addAction(tr("Icons Only"));
|
||||
connect(iconsOnly, &QAction::triggered, this, &MainWindow::toolbarIconsOnly);
|
||||
QAction *textOnly = m_toolbarMenu->addAction(tr("Text Only"));
|
||||
connect(textOnly, &QAction::triggered, this, &MainWindow::toolbarTextOnly);
|
||||
QAction *textBesideIcons = m_toolbarMenu->addAction(tr("Text Alongside Icons"));
|
||||
connect(textBesideIcons, &QAction::triggered, this, &MainWindow::toolbarTextBeside);
|
||||
QAction *textUnderIcons = m_toolbarMenu->addAction(tr("Text Under Icons"));
|
||||
connect(textUnderIcons, &QAction::triggered, this, &MainWindow::toolbarTextUnder);
|
||||
QAction *followSystemStyle = m_toolbarMenu->addAction(tr("Follow System Style"));
|
||||
connect(followSystemStyle, &QAction::triggered, this, &MainWindow::toolbarFollowSystem);
|
||||
QAction *iconsOnly = m_toolbarMenu->addAction(tr("Icons Only"), this, &MainWindow::toolbarIconsOnly);
|
||||
QAction *textOnly = m_toolbarMenu->addAction(tr("Text Only"), this, &MainWindow::toolbarTextOnly);
|
||||
QAction *textBesideIcons = m_toolbarMenu->addAction(tr("Text Alongside Icons"), this, &MainWindow::toolbarTextBeside);
|
||||
QAction *textUnderIcons = m_toolbarMenu->addAction(tr("Text Under Icons"), this, &MainWindow::toolbarTextUnder);
|
||||
QAction *followSystemStyle = m_toolbarMenu->addAction(tr("Follow System Style"), this, &MainWindow::toolbarFollowSystem);
|
||||
|
||||
auto *textPositionGroup = new QActionGroup(m_toolbarMenu);
|
||||
textPositionGroup->addAction(iconsOnly);
|
||||
|
@ -1804,21 +1797,21 @@ void MainWindow::on_actionOptions_triggered()
|
|||
|
||||
void MainWindow::on_actionTopToolBar_triggered()
|
||||
{
|
||||
const bool isVisible = static_cast<QAction*>(sender())->isChecked();
|
||||
const bool isVisible = static_cast<QAction *>(sender())->isChecked();
|
||||
m_ui->toolBar->setVisible(isVisible);
|
||||
Preferences::instance()->setToolbarDisplayed(isVisible);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionShowStatusbar_triggered()
|
||||
{
|
||||
const bool isVisible = static_cast<QAction*>(sender())->isChecked();
|
||||
const bool isVisible = static_cast<QAction *>(sender())->isChecked();
|
||||
Preferences::instance()->setStatusbarDisplayed(isVisible);
|
||||
showStatusBar(isVisible);
|
||||
}
|
||||
|
||||
void MainWindow::on_actionSpeedInTitleBar_triggered()
|
||||
{
|
||||
m_displaySpeedInTitle = static_cast<QAction * >(sender())->isChecked();
|
||||
m_displaySpeedInTitle = static_cast<QAction *>(sender())->isChecked();
|
||||
Preferences::instance()->showSpeedInTitleBar(m_displaySpeedInTitle);
|
||||
if (m_displaySpeedInTitle)
|
||||
reloadSessionStats();
|
||||
|
@ -2097,7 +2090,7 @@ void MainWindow::checkProgramUpdate()
|
|||
m_ui->actionCheckForUpdates->setEnabled(false);
|
||||
m_ui->actionCheckForUpdates->setText(tr("Checking for Updates..."));
|
||||
m_ui->actionCheckForUpdates->setToolTip(tr("Already checking for program updates in the background"));
|
||||
bool invokedByUser = m_ui->actionCheckForUpdates == qobject_cast<QAction * >(sender());
|
||||
bool invokedByUser = m_ui->actionCheckForUpdates == qobject_cast<QAction *>(sender());
|
||||
ProgramUpdater *updater = new ProgramUpdater(this, invokedByUser);
|
||||
connect(updater, &ProgramUpdater::updateCheckFinished, this, &MainWindow::handleUpdateCheckFinished);
|
||||
updater->checkForUpdates();
|
||||
|
|
|
@ -270,8 +270,8 @@ void PeerListWidget::showPeerListMenu(const QPoint &)
|
|||
// Do not allow user to add peers in a private torrent
|
||||
if (!torrent->isQueued() && !torrent->isChecking() && !torrent->isPrivate())
|
||||
{
|
||||
const QAction *addPeerAct = menu->addAction(UIThemeManager::instance()->getIcon("user-group-new"), tr("Add a new peer..."));
|
||||
connect(addPeerAct, &QAction::triggered, this, [this, torrent]()
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("user-group-new"), tr("Add a new peer...")
|
||||
, this, [this, torrent]()
|
||||
{
|
||||
const QVector<BitTorrent::PeerAddress> peersList = PeersAdditionDialog::askForPeers(this);
|
||||
const int peerCount = std::count_if(peersList.cbegin(), peersList.cend(), [torrent](const BitTorrent::PeerAddress &peer)
|
||||
|
@ -287,13 +287,11 @@ void PeerListWidget::showPeerListMenu(const QPoint &)
|
|||
|
||||
if (!selectionModel()->selectedRows().isEmpty())
|
||||
{
|
||||
const QAction *copyPeerAct = menu->addAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Copy IP:port"));
|
||||
connect(copyPeerAct, &QAction::triggered, this, &PeerListWidget::copySelectedPeers);
|
||||
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Copy IP:port")
|
||||
, this, &PeerListWidget::copySelectedPeers);
|
||||
menu->addSeparator();
|
||||
|
||||
const QAction *banAct = menu->addAction(UIThemeManager::instance()->getIcon("user-group-delete"), tr("Ban peer permanently"));
|
||||
connect(banAct, &QAction::triggered, this, &PeerListWidget::banSelectedPeers);
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("user-group-delete"), tr("Ban peer permanently")
|
||||
, this, &PeerListWidget::banSelectedPeers);
|
||||
}
|
||||
|
||||
if (menu->isEmpty())
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
#include "propertieswidget.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QClipboard>
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
|
@ -586,57 +585,82 @@ void PropertiesWidget::displayFilesListMenu(const QPoint &)
|
|||
{
|
||||
const QModelIndex index = selectedRows[0];
|
||||
|
||||
const QAction *actOpen = menu->addAction(UIThemeManager::instance()->getIcon("folder-documents"), tr("Open"));
|
||||
connect(actOpen, &QAction::triggered, this, [this, index]() { openItem(index); });
|
||||
|
||||
const QAction *actOpenContainingFolder = menu->addAction(UIThemeManager::instance()->getIcon("inode-directory"), tr("Open Containing Folder"));
|
||||
connect(actOpenContainingFolder, &QAction::triggered, this, [this, index]() { openParentFolder(index); });
|
||||
|
||||
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->addAction(UIThemeManager::instance()->getIcon("folder-documents"), tr("Open")
|
||||
, this, [this, index]() { openItem(index); });
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("inode-directory"), tr("Open Containing Folder")
|
||||
, this, [this, index]() { openParentFolder(index); });
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("edit-rename"), tr("Rename...")
|
||||
, this, [this]() { m_ui->filesList->renameSelectedFile(*m_torrent); });
|
||||
menu->addSeparator();
|
||||
}
|
||||
|
||||
if (!m_torrent->isSeed())
|
||||
{
|
||||
QMenu *subMenu = menu->addMenu(tr("Priority"));
|
||||
|
||||
const auto applyPriorities = [this, selectedRows](const BitTorrent::DownloadPriority prio)
|
||||
const auto applyPriorities = [this](const BitTorrent::DownloadPriority prio)
|
||||
{
|
||||
const QModelIndexList selectedRows = m_ui->filesList->selectionModel()->selectedRows(0);
|
||||
for (const QModelIndex &index : selectedRows)
|
||||
{
|
||||
m_propListModel->setData(
|
||||
m_propListModel->index(index.row(), PRIORITY, index.parent()), static_cast<int>(prio));
|
||||
m_propListModel->setData(index.sibling(index.row(), PRIORITY)
|
||||
, static_cast<int>(prio));
|
||||
}
|
||||
|
||||
// Save changes
|
||||
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);
|
||||
});
|
||||
subMenu->addAction(m_ui->actionNotDownloaded);
|
||||
|
||||
connect(m_ui->actionNormal, &QAction::triggered, subMenu, [applyPriorities]()
|
||||
subMenu->addAction(tr("Normal"), subMenu, [applyPriorities]()
|
||||
{
|
||||
applyPriorities(BitTorrent::DownloadPriority::Normal);
|
||||
});
|
||||
subMenu->addAction(m_ui->actionNormal);
|
||||
|
||||
connect(m_ui->actionHigh, &QAction::triggered, subMenu, [applyPriorities]()
|
||||
subMenu->addAction(tr("High"), subMenu, [applyPriorities]()
|
||||
{
|
||||
applyPriorities(BitTorrent::DownloadPriority::High);
|
||||
});
|
||||
subMenu->addAction(m_ui->actionHigh);
|
||||
|
||||
connect(m_ui->actionMaximum, &QAction::triggered, subMenu, [applyPriorities]()
|
||||
subMenu->addAction(tr("Maximum"), subMenu, [applyPriorities]()
|
||||
{
|
||||
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()
|
||||
|
@ -660,21 +684,17 @@ void PropertiesWidget::displayWebSeedListMenu(const QPoint &)
|
|||
QMenu *menu = new QMenu(this);
|
||||
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
const QAction *actAdd = menu->addAction(UIThemeManager::instance()->getIcon("list-add"), tr("New Web seed"));
|
||||
connect(actAdd, &QAction::triggered, this, &PropertiesWidget::askWebSeed);
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("list-add"), tr("New Web seed"), this, &PropertiesWidget::askWebSeed);
|
||||
|
||||
if (!rows.isEmpty())
|
||||
{
|
||||
const QAction *actDel = menu->addAction(UIThemeManager::instance()->getIcon("list-remove"), tr("Remove Web seed"));
|
||||
connect(actDel, &QAction::triggered, this, &PropertiesWidget::deleteSelectedUrlSeeds);
|
||||
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("list-remove"), tr("Remove Web seed")
|
||||
, this, &PropertiesWidget::deleteSelectedUrlSeeds);
|
||||
menu->addSeparator();
|
||||
|
||||
const QAction *actCpy = menu->addAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Copy Web seed URL"));
|
||||
connect(actCpy, &QAction::triggered, this, &PropertiesWidget::copySelectedWebSeedsToClipboard);
|
||||
|
||||
const QAction *actEdit = menu->addAction(UIThemeManager::instance()->getIcon("edit-rename"), tr("Edit Web seed URL"));
|
||||
connect(actEdit, &QAction::triggered, this, &PropertiesWidget::editWebSeed);
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Copy Web seed URL")
|
||||
, this, &PropertiesWidget::copySelectedWebSeedsToClipboard);
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("edit-rename"), tr("Edit Web seed URL")
|
||||
, this, &PropertiesWidget::editWebSeed);
|
||||
}
|
||||
|
||||
menu->popup(QCursor::pos());
|
||||
|
|
|
@ -1086,29 +1086,6 @@
|
|||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
<action name="actionNotDownloaded">
|
||||
<property name="text">
|
||||
<string>Do not download</string>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Do not download</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionMaximum">
|
||||
<property name="text">
|
||||
<string>Maximum</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionHigh">
|
||||
<property name="text">
|
||||
<string>High</string>
|
||||
</property>
|
||||
</action>
|
||||
<action name="actionNormal">
|
||||
<property name="text">
|
||||
<string>Normal</string>
|
||||
</property>
|
||||
</action>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
|
|
|
@ -592,30 +592,26 @@ void TrackerListWidget::showTrackerListMenu(const QPoint &)
|
|||
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
// Add actions
|
||||
const QAction *addAct = menu->addAction(UIThemeManager::instance()->getIcon("list-add"), tr("Add a new tracker..."));
|
||||
connect(addAct, &QAction::triggered, this, &TrackerListWidget::askForTrackers);
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("list-add"), tr("Add a new tracker...")
|
||||
, this, &TrackerListWidget::askForTrackers);
|
||||
|
||||
if (!getSelectedTrackerItems().isEmpty())
|
||||
{
|
||||
const QAction *editAct = menu->addAction(UIThemeManager::instance()->getIcon("edit-rename"),tr("Edit tracker URL..."));
|
||||
connect(editAct, &QAction::triggered, this, &TrackerListWidget::editSelectedTracker);
|
||||
|
||||
const QAction *delAct = menu->addAction(UIThemeManager::instance()->getIcon("list-remove"), tr("Remove tracker"));
|
||||
connect(delAct, &QAction::triggered, this, &TrackerListWidget::deleteSelectedTrackers);
|
||||
|
||||
const QAction *copyAct = menu->addAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Copy tracker URL"));
|
||||
connect(copyAct, &QAction::triggered, this, &TrackerListWidget::copyTrackerUrl);
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("edit-rename"),tr("Edit tracker URL...")
|
||||
, this, &TrackerListWidget::editSelectedTracker);
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("list-remove"), tr("Remove tracker")
|
||||
, this, &TrackerListWidget::deleteSelectedTrackers);
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Copy tracker URL")
|
||||
, this, &TrackerListWidget::copyTrackerUrl);
|
||||
}
|
||||
|
||||
if (!torrent->isPaused())
|
||||
{
|
||||
const QAction *reannounceSelAct = menu->addAction(UIThemeManager::instance()->getIcon("view-refresh"), tr("Force reannounce to selected trackers"));
|
||||
connect(reannounceSelAct, &QAction::triggered, this, &TrackerListWidget::reannounceSelected);
|
||||
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("view-refresh"), tr("Force reannounce to selected trackers")
|
||||
, this, &TrackerListWidget::reannounceSelected);
|
||||
menu->addSeparator();
|
||||
|
||||
const QAction *reannounceAllAct = menu->addAction(UIThemeManager::instance()->getIcon("view-refresh"), tr("Force reannounce to all trackers"));
|
||||
connect(reannounceAllAct, &QAction::triggered, this, [this]()
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("view-refresh"), tr("Force reannounce to all trackers")
|
||||
, this, [this]()
|
||||
{
|
||||
BitTorrent::Torrent *h = m_properties->getCurrentTorrent();
|
||||
h->forceReannounce();
|
||||
|
|
|
@ -490,8 +490,8 @@ void AutomatedRssDownloader::displayRulesListMenu()
|
|||
QMenu *menu = new QMenu(this);
|
||||
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
const QAction *addAct = menu->addAction(UIThemeManager::instance()->getIcon("list-add"), tr("Add new rule..."));
|
||||
connect(addAct, &QAction::triggered, this, &AutomatedRssDownloader::on_addRuleBtn_clicked);
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("list-add"), tr("Add new rule...")
|
||||
, this, &AutomatedRssDownloader::on_addRuleBtn_clicked);
|
||||
|
||||
const QList<QListWidgetItem *> selection = m_ui->listRules->selectedItems();
|
||||
|
||||
|
@ -499,24 +499,21 @@ void AutomatedRssDownloader::displayRulesListMenu()
|
|||
{
|
||||
if (selection.count() == 1)
|
||||
{
|
||||
const QAction *delAct = menu->addAction(UIThemeManager::instance()->getIcon("list-remove"), tr("Delete rule"));
|
||||
connect(delAct, &QAction::triggered, this, &AutomatedRssDownloader::on_removeRuleBtn_clicked);
|
||||
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("list-remove"), tr("Delete rule")
|
||||
, this, &AutomatedRssDownloader::on_removeRuleBtn_clicked);
|
||||
menu->addSeparator();
|
||||
|
||||
const QAction *renameAct = menu->addAction(UIThemeManager::instance()->getIcon("edit-rename"), tr("Rename rule..."));
|
||||
connect(renameAct, &QAction::triggered, this, &AutomatedRssDownloader::renameSelectedRule);
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("edit-rename"), tr("Rename rule...")
|
||||
, this, &AutomatedRssDownloader::renameSelectedRule);
|
||||
}
|
||||
else
|
||||
{
|
||||
const QAction *delAct = menu->addAction(UIThemeManager::instance()->getIcon("list-remove"), tr("Delete selected rules"));
|
||||
connect(delAct, &QAction::triggered, this, &AutomatedRssDownloader::on_removeRuleBtn_clicked);
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("list-remove"), tr("Delete selected rules")
|
||||
, this, &AutomatedRssDownloader::on_removeRuleBtn_clicked);
|
||||
}
|
||||
|
||||
menu->addSeparator();
|
||||
|
||||
const QAction *clearAct = menu->addAction(UIThemeManager::instance()->getIcon("edit-clear"), tr("Clear downloaded episodes..."));
|
||||
connect(clearAct, &QAction::triggered, this, &AutomatedRssDownloader::clearSelectedRuleDownloadedEpisodeList);
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("edit-clear"), tr("Clear downloaded episodes...")
|
||||
, this, &AutomatedRssDownloader::clearSelectedRuleDownloadedEpisodeList);
|
||||
}
|
||||
|
||||
menu->popup(QCursor::pos());
|
||||
|
|
|
@ -393,31 +393,21 @@ void SearchJobWidget::contextMenuEvent(QContextMenuEvent *event)
|
|||
auto *menu = new QMenu(this);
|
||||
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
const QAction *downloadAction = menu->addAction(
|
||||
UIThemeManager::instance()->getIcon("download"), tr("Download"));
|
||||
connect(downloadAction, &QAction::triggered, this, &SearchJobWidget::downloadTorrents);
|
||||
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("download"), tr("Download")
|
||||
, this, &SearchJobWidget::downloadTorrents);
|
||||
menu->addSeparator();
|
||||
|
||||
const QAction *openDescriptionAction = menu->addAction(
|
||||
UIThemeManager::instance()->getIcon("application-x-mswinurl"), tr("Open description page"));
|
||||
connect(openDescriptionAction, &QAction::triggered, this, &SearchJobWidget::openTorrentPages);
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("application-x-mswinurl"), tr("Open description page")
|
||||
, this, &SearchJobWidget::openTorrentPages);
|
||||
|
||||
QMenu *copySubMenu = menu->addMenu(
|
||||
UIThemeManager::instance()->getIcon("edit-copy"), tr("Copy"));
|
||||
|
||||
const QAction *copyNamesAction = copySubMenu->addAction(
|
||||
UIThemeManager::instance()->getIcon("edit-copy"), tr("Name"));
|
||||
connect(copyNamesAction, &QAction::triggered, this, &SearchJobWidget::copyTorrentNames);
|
||||
|
||||
const QAction *copyDownloadLinkAction = copySubMenu->addAction(
|
||||
UIThemeManager::instance()->getIcon("edit-copy"), tr("Download link"));
|
||||
connect(copyDownloadLinkAction, &QAction::triggered
|
||||
copySubMenu->addAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Name")
|
||||
, this, &SearchJobWidget::copyTorrentNames);
|
||||
copySubMenu->addAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Download link")
|
||||
, this, &SearchJobWidget::copyTorrentDownloadLinks);
|
||||
|
||||
const QAction *copyDescriptionAction = copySubMenu->addAction(
|
||||
UIThemeManager::instance()->getIcon("edit-copy"), tr("Description page URL"));
|
||||
connect(copyDescriptionAction, &QAction::triggered, this, &SearchJobWidget::copyTorrentURLs);
|
||||
copySubMenu->addAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Description page URL")
|
||||
, this, &SearchJobWidget::copyTorrentURLs);
|
||||
|
||||
menu->popup(event->globalPos());
|
||||
}
|
||||
|
|
|
@ -28,7 +28,6 @@
|
|||
|
||||
#include "tagfilterwidget.h"
|
||||
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
#include <QMessageBox>
|
||||
|
||||
|
@ -108,44 +107,25 @@ void TagFilterWidget::showMenu(QPoint)
|
|||
QMenu *menu = new QMenu(this);
|
||||
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
const QAction *addAct = menu->addAction(
|
||||
UIThemeManager::instance()->getIcon("list-add")
|
||||
, tr("Add tag..."));
|
||||
connect(addAct, &QAction::triggered, this, &TagFilterWidget::addTag);
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("list-add"), tr("Add tag...")
|
||||
, this, &TagFilterWidget::addTag);
|
||||
|
||||
const auto selectedRows = selectionModel()->selectedRows();
|
||||
if (!selectedRows.empty() && !TagFilterModel::isSpecialItem(selectedRows.first()))
|
||||
{
|
||||
const QAction *removeAct = menu->addAction(
|
||||
UIThemeManager::instance()->getIcon("list-remove")
|
||||
, tr("Remove tag"));
|
||||
connect(removeAct, &QAction::triggered, this, &TagFilterWidget::removeTag);
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("list-remove"), tr("Remove tag")
|
||||
, this, &TagFilterWidget::removeTag);
|
||||
}
|
||||
|
||||
const QAction *removeUnusedAct = menu->addAction(
|
||||
UIThemeManager::instance()->getIcon("list-remove")
|
||||
, tr("Remove unused tags"));
|
||||
connect(removeUnusedAct, &QAction::triggered, this, &TagFilterWidget::removeUnusedTags);
|
||||
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("list-remove"), tr("Remove unused tags")
|
||||
, this, &TagFilterWidget::removeUnusedTags);
|
||||
menu->addSeparator();
|
||||
|
||||
const QAction *startAct = menu->addAction(
|
||||
UIThemeManager::instance()->getIcon("media-playback-start")
|
||||
, tr("Resume torrents"));
|
||||
connect(startAct, &QAction::triggered
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("media-playback-start"), tr("Resume torrents")
|
||||
, this, &TagFilterWidget::actionResumeTorrentsTriggered);
|
||||
|
||||
const QAction *pauseAct = menu->addAction(
|
||||
UIThemeManager::instance()->getIcon("media-playback-pause")
|
||||
, tr("Pause torrents"));
|
||||
connect(pauseAct, &QAction::triggered, this
|
||||
, &TagFilterWidget::actionPauseTorrentsTriggered);
|
||||
|
||||
const QAction *deleteTorrentsAct = menu->addAction(
|
||||
UIThemeManager::instance()->getIcon("edit-delete")
|
||||
, tr("Delete torrents"));
|
||||
connect(deleteTorrentsAct, &QAction::triggered, this
|
||||
, &TagFilterWidget::actionDeleteTorrentsTriggered);
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("media-playback-pause"), tr("Pause torrents")
|
||||
, this, &TagFilterWidget::actionPauseTorrentsTriggered);
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("edit-delete"), tr("Delete torrents")
|
||||
, this, &TagFilterWidget::actionDeleteTorrentsTriggered);
|
||||
|
||||
menu->popup(QCursor::pos());
|
||||
}
|
||||
|
|
|
@ -557,14 +557,12 @@ void TrackerFiltersList::showMenu(const QPoint &)
|
|||
QMenu *menu = new QMenu(this);
|
||||
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||
|
||||
const QAction *startAct = menu->addAction(UIThemeManager::instance()->getIcon("media-playback-start"), tr("Resume torrents"));
|
||||
connect(startAct, &QAction::triggered, transferList, &TransferListWidget::startVisibleTorrents);
|
||||
|
||||
const QAction *pauseAct = menu->addAction(UIThemeManager::instance()->getIcon("media-playback-pause"), tr("Pause torrents"));
|
||||
connect(pauseAct, &QAction::triggered, transferList, &TransferListWidget::pauseVisibleTorrents);
|
||||
|
||||
const QAction *deleteTorrentsAct = menu->addAction(UIThemeManager::instance()->getIcon("edit-delete"), tr("Delete torrents"));
|
||||
connect(deleteTorrentsAct, &QAction::triggered, transferList, &TransferListWidget::deleteVisibleTorrents);
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("media-playback-start"), tr("Resume torrents")
|
||||
, transferList, &TransferListWidget::startVisibleTorrents);
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("media-playback-pause"), tr("Pause torrents")
|
||||
, transferList, &TransferListWidget::pauseVisibleTorrents);
|
||||
menu->addAction(UIThemeManager::instance()->getIcon("edit-delete"), tr("Delete torrents")
|
||||
, transferList, &TransferListWidget::deleteVisibleTorrents);
|
||||
|
||||
menu->popup(QCursor::pos());
|
||||
}
|
||||
|
|
|
@ -843,7 +843,7 @@ void TransferListWidget::displayListMenu(const QPoint &)
|
|||
auto *actionAutoTMM = new TriStateAction(tr("Automatic Torrent Management"), listMenu);
|
||||
actionAutoTMM->setToolTip(tr("Automatic mode means that various torrent properties(eg save path) will be decided by the associated category"));
|
||||
connect(actionAutoTMM, &QAction::triggered, this, &TransferListWidget::setSelectedAutoTMMEnabled);
|
||||
QAction *actionEditTracker = new QAction(UIThemeManager::instance()->getIcon("edit-rename"), tr("Edit trackers..."), listMenu);
|
||||
auto *actionEditTracker = new QAction(UIThemeManager::instance()->getIcon("edit-rename"), tr("Edit trackers..."), listMenu);
|
||||
connect(actionEditTracker, &QAction::triggered, this, &TransferListWidget::editTorrentTrackers);
|
||||
// End of actions
|
||||
|
||||
|
@ -969,27 +969,23 @@ void TransferListWidget::displayListMenu(const QPoint &)
|
|||
|
||||
QMenu *categoryMenu = listMenu->addMenu(UIThemeManager::instance()->getIcon("view-categories"), tr("Category"));
|
||||
|
||||
const QAction *newCategoryAction = categoryMenu->addAction(UIThemeManager::instance()->getIcon("list-add"), tr("New...", "New category..."));
|
||||
connect(newCategoryAction, &QAction::triggered, this, &TransferListWidget::askNewCategoryForSelection);
|
||||
|
||||
const QAction *resetCategoryAction = categoryMenu->addAction(UIThemeManager::instance()->getIcon("edit-clear"), tr("Reset", "Reset category"));
|
||||
connect(resetCategoryAction, &QAction::triggered, this, [this]() { setSelectionCategory(""); });
|
||||
|
||||
categoryMenu->addAction(UIThemeManager::instance()->getIcon("list-add"), tr("New...", "New category...")
|
||||
, this, &TransferListWidget::askNewCategoryForSelection);
|
||||
categoryMenu->addAction(UIThemeManager::instance()->getIcon("edit-clear"), tr("Reset", "Reset category")
|
||||
, this, [this]() { setSelectionCategory(""); });
|
||||
categoryMenu->addSeparator();
|
||||
|
||||
for (const QString &category : asConst(categories))
|
||||
{
|
||||
const QString escapedCategory = QString(category).replace('&', "&&"); // avoid '&' becomes accelerator key
|
||||
QAction *cat = categoryMenu->addAction(UIThemeManager::instance()->getIcon("inode-directory"), escapedCategory
|
||||
, this, [this, category]() { setSelectionCategory(category); });
|
||||
|
||||
QAction *cat = new QAction(UIThemeManager::instance()->getIcon("inode-directory"), escapedCategory, categoryMenu);
|
||||
if (allSameCategory && (category == firstCategory))
|
||||
{
|
||||
cat->setCheckable(true);
|
||||
cat->setChecked(true);
|
||||
}
|
||||
|
||||
connect(cat, &QAction::triggered, this, [this, category]() { setSelectionCategory(category); });
|
||||
categoryMenu->addAction(cat);
|
||||
}
|
||||
|
||||
// Tag Menu
|
||||
|
@ -998,18 +994,16 @@ void TransferListWidget::displayListMenu(const QPoint &)
|
|||
|
||||
QMenu *tagsMenu = listMenu->addMenu(UIThemeManager::instance()->getIcon("view-categories"), tr("Tags"));
|
||||
|
||||
const QAction *addTagAction = tagsMenu->addAction(UIThemeManager::instance()->getIcon("list-add"), tr("Add...", "Add / assign multiple tags..."));
|
||||
connect(addTagAction, &QAction::triggered, this, &TransferListWidget::askAddTagsForSelection);
|
||||
|
||||
const QAction *removeTagsAction = tagsMenu->addAction(UIThemeManager::instance()->getIcon("edit-clear"), tr("Remove All", "Remove all tags"));
|
||||
connect(removeTagsAction, &QAction::triggered, this, [this]()
|
||||
tagsMenu->addAction(UIThemeManager::instance()->getIcon("list-add"), tr("Add...", "Add / assign multiple tags...")
|
||||
, this, &TransferListWidget::askAddTagsForSelection);
|
||||
tagsMenu->addAction(UIThemeManager::instance()->getIcon("edit-clear"), tr("Remove All", "Remove all tags")
|
||||
, this, [this]()
|
||||
{
|
||||
if (Preferences::instance()->confirmRemoveAllTags())
|
||||
confirmRemoveAllTagsForSelection();
|
||||
else
|
||||
clearSelectionTags();
|
||||
});
|
||||
|
||||
tagsMenu->addSeparator();
|
||||
|
||||
for (const QString &tag : asConst(tags))
|
||||
|
|
Loading…
Reference in a new issue