Browse Source

Merge pull request #14233 from Chocobo1/menu

Add ability to prioritize selected items by shown file order
adaptive-webui-19844
Mike Tzou 4 years ago committed by GitHub
parent
commit
f0b78ffc04
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 60
      src/gui/addnewtorrentdialog.cpp
  2. 20
      src/gui/addnewtorrentdialog.ui
  3. 54
      src/gui/categoryfilterwidget.cpp
  4. 8
      src/gui/executionlogwidget.cpp
  5. 29
      src/gui/mainwindow.cpp
  6. 14
      src/gui/properties/peerlistwidget.cpp
  7. 94
      src/gui/properties/propertieswidget.cpp
  8. 23
      src/gui/properties/propertieswidget.ui
  9. 28
      src/gui/properties/trackerlistwidget.cpp
  10. 23
      src/gui/rss/automatedrssdownloader.cpp
  11. 28
      src/gui/search/searchjobwidget.cpp
  12. 42
      src/gui/tagfilterwidget.cpp
  13. 14
      src/gui/transferlistfilterswidget.cpp
  14. 28
      src/gui/transferlistwidget.cpp

60
src/gui/addnewtorrentdialog.cpp

@ -502,12 +502,12 @@ void AddNewTorrentDialog::displayContentTreeMenu(const QPoint &)
{ {
const QModelIndexList selectedRows = m_ui->contentTreeView->selectionModel()->selectedRows(0); 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) for (const QModelIndex &index : selectedRows)
{ {
m_contentModel->setData( m_contentModel->setData(index.sibling(index.row(), PRIORITY)
m_contentModel->index(index.row(), PRIORITY, index.parent())
, static_cast<int>(prio)); , static_cast<int>(prio));
} }
}; };
@ -517,37 +517,63 @@ void AddNewTorrentDialog::displayContentTreeMenu(const QPoint &)
if (selectedRows.size() == 1) if (selectedRows.size() == 1)
{ {
QAction *actRename = menu->addAction(UIThemeManager::instance()->getIcon("edit-rename"), tr("Rename...")); menu->addAction(UIThemeManager::instance()->getIcon("edit-rename"), tr("Rename...")
connect(actRename, &QAction::triggered, this, [this]() { m_ui->contentTreeView->renameSelectedFile(m_torrentInfo); }); , this, [this]() { m_ui->contentTreeView->renameSelectedFile(m_torrentInfo); });
menu->addSeparator(); menu->addSeparator();
} }
QMenu *subMenu = menu->addMenu(tr("Priority")); 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); 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->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()); menu->popup(QCursor::pos());
} }

20
src/gui/addnewtorrentdialog.ui

@ -449,26 +449,6 @@
</layout> </layout>
</item> </item>
</layout> </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> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>

54
src/gui/categoryfilterwidget.cpp

@ -28,7 +28,6 @@
#include "categoryfilterwidget.h" #include "categoryfilterwidget.h"
#include <QAction>
#include <QMenu> #include <QMenu>
#include "base/bittorrent/session.h" #include "base/bittorrent/session.h"
@ -110,54 +109,33 @@ void CategoryFilterWidget::showMenu(const QPoint &)
QMenu *menu = new QMenu(this); QMenu *menu = new QMenu(this);
menu->setAttribute(Qt::WA_DeleteOnClose); menu->setAttribute(Qt::WA_DeleteOnClose);
const QAction *addAct = menu->addAction( menu->addAction(UIThemeManager::instance()->getIcon("list-add"), tr("Add category...")
UIThemeManager::instance()->getIcon("list-add") , this, &CategoryFilterWidget::addCategory);
, tr("Add category..."));
connect(addAct, &QAction::triggered, this, &CategoryFilterWidget::addCategory);
const auto selectedRows = selectionModel()->selectedRows(); const auto selectedRows = selectionModel()->selectedRows();
if (!selectedRows.empty() && !CategoryFilterModel::isSpecialItem(selectedRows.first())) if (!selectedRows.empty() && !CategoryFilterModel::isSpecialItem(selectedRows.first()))
{ {
if (BitTorrent::Session::instance()->isSubcategoriesEnabled()) if (BitTorrent::Session::instance()->isSubcategoriesEnabled())
{ {
const QAction *addSubAct = menu->addAction( menu->addAction(UIThemeManager::instance()->getIcon("list-add"), tr("Add subcategory...")
UIThemeManager::instance()->getIcon("list-add") , this, &CategoryFilterWidget::addSubcategory);
, tr("Add subcategory..."));
connect(addSubAct, &QAction::triggered, this, &CategoryFilterWidget::addSubcategory);
} }
const QAction *editAct = menu->addAction( menu->addAction(UIThemeManager::instance()->getIcon("document-edit"), tr("Edit category...")
UIThemeManager::instance()->getIcon("document-edit") , this, &CategoryFilterWidget::editCategory);
, tr("Edit category...")); menu->addAction(UIThemeManager::instance()->getIcon("list-remove"), tr("Remove category")
connect(editAct, &QAction::triggered, this, &CategoryFilterWidget::editCategory); , this, &CategoryFilterWidget::removeCategory);
const QAction *removeAct = menu->addAction(
UIThemeManager::instance()->getIcon("list-remove")
, tr("Remove category"));
connect(removeAct, &QAction::triggered, this, &CategoryFilterWidget::removeCategory);
} }
const QAction *removeUnusedAct = menu->addAction( menu->addAction(UIThemeManager::instance()->getIcon("list-remove"), tr("Remove unused categories")
UIThemeManager::instance()->getIcon("list-remove") , this, &CategoryFilterWidget::removeUnusedCategories);
, tr("Remove unused categories"));
connect(removeUnusedAct, &QAction::triggered, this, &CategoryFilterWidget::removeUnusedCategories);
menu->addSeparator(); menu->addSeparator();
menu->addAction(UIThemeManager::instance()->getIcon("media-playback-start"), tr("Resume torrents")
const QAction *startAct = menu->addAction( , this, &CategoryFilterWidget::actionResumeTorrentsTriggered);
UIThemeManager::instance()->getIcon("media-playback-start") menu->addAction(UIThemeManager::instance()->getIcon("media-playback-pause"), tr("Pause torrents")
, tr("Resume torrents")); , this, &CategoryFilterWidget::actionPauseTorrentsTriggered);
connect(startAct, &QAction::triggered, this, &CategoryFilterWidget::actionResumeTorrentsTriggered); menu->addAction(UIThemeManager::instance()->getIcon("edit-delete"), tr("Delete torrents")
, this, &CategoryFilterWidget::actionDeleteTorrentsTriggered);
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->popup(QCursor::pos()); menu->popup(QCursor::pos());
} }

8
src/gui/executionlogwidget.cpp

@ -91,12 +91,12 @@ void ExecutionLogWidget::displayContextMenu(const QPoint &pos, const LogListView
// only show copy action if any of the row is selected // only show copy action if any of the row is selected
if (view->currentIndex().isValid()) if (view->currentIndex().isValid())
{ {
const QAction *copyAct = menu->addAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Copy")); menu->addAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Copy")
connect(copyAct, &QAction::triggered, view, &LogListView::copySelection); , view, &LogListView::copySelection);
} }
const QAction *clearAct = menu->addAction(UIThemeManager::instance()->getIcon("edit-clear"), tr("Clear")); menu->addAction(UIThemeManager::instance()->getIcon("edit-clear"), tr("Clear")
connect(clearAct, &QAction::triggered, model, &BaseLogModel::reset); , model, &BaseLogModel::reset);
menu->popup(view->mapToGlobal(pos)); menu->popup(view->mapToGlobal(pos));
} }

29
src/gui/mainwindow.cpp

@ -195,10 +195,8 @@ MainWindow::MainWindow(QWidget *parent)
m_ui->actionManageCookies->setIcon(UIThemeManager::instance()->getIcon("preferences-web-browser-cookies")); m_ui->actionManageCookies->setIcon(UIThemeManager::instance()->getIcon("preferences-web-browser-cookies"));
auto *lockMenu = new QMenu(this); auto *lockMenu = new QMenu(this);
QAction *defineUiLockPasswdAct = lockMenu->addAction(tr("&Set Password")); lockMenu->addAction(tr("&Set Password"), this, &MainWindow::defineUILockPassword);
connect(defineUiLockPasswdAct, &QAction::triggered, this, &MainWindow::defineUILockPassword); lockMenu->addAction(tr("&Clear Password"), this, &MainWindow::clearUILockPassword);
QAction *clearUiLockPasswdAct = lockMenu->addAction(tr("&Clear Password"));
connect(clearUiLockPasswdAct, &QAction::triggered, this, &MainWindow::clearUILockPassword);
m_ui->actionLock->setMenu(lockMenu); m_ui->actionLock->setMenu(lockMenu);
// Creating Bittorrent session // Creating Bittorrent session
@ -550,16 +548,11 @@ void MainWindow::addToolbarContextMenu()
m_ui->toolBar->setContextMenuPolicy(Qt::CustomContextMenu); m_ui->toolBar->setContextMenuPolicy(Qt::CustomContextMenu);
connect(m_ui->toolBar, &QWidget::customContextMenuRequested, this, &MainWindow::toolbarMenuRequested); connect(m_ui->toolBar, &QWidget::customContextMenuRequested, this, &MainWindow::toolbarMenuRequested);
QAction *iconsOnly = m_toolbarMenu->addAction(tr("Icons Only")); QAction *iconsOnly = m_toolbarMenu->addAction(tr("Icons Only"), this, &MainWindow::toolbarIconsOnly);
connect(iconsOnly, &QAction::triggered, this, &MainWindow::toolbarIconsOnly); QAction *textOnly = m_toolbarMenu->addAction(tr("Text Only"), this, &MainWindow::toolbarTextOnly);
QAction *textOnly = m_toolbarMenu->addAction(tr("Text Only")); QAction *textBesideIcons = m_toolbarMenu->addAction(tr("Text Alongside Icons"), this, &MainWindow::toolbarTextBeside);
connect(textOnly, &QAction::triggered, this, &MainWindow::toolbarTextOnly); QAction *textUnderIcons = m_toolbarMenu->addAction(tr("Text Under Icons"), this, &MainWindow::toolbarTextUnder);
QAction *textBesideIcons = m_toolbarMenu->addAction(tr("Text Alongside Icons")); QAction *followSystemStyle = m_toolbarMenu->addAction(tr("Follow System Style"), this, &MainWindow::toolbarFollowSystem);
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);
auto *textPositionGroup = new QActionGroup(m_toolbarMenu); auto *textPositionGroup = new QActionGroup(m_toolbarMenu);
textPositionGroup->addAction(iconsOnly); textPositionGroup->addAction(iconsOnly);
@ -1804,21 +1797,21 @@ void MainWindow::on_actionOptions_triggered()
void MainWindow::on_actionTopToolBar_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); m_ui->toolBar->setVisible(isVisible);
Preferences::instance()->setToolbarDisplayed(isVisible); Preferences::instance()->setToolbarDisplayed(isVisible);
} }
void MainWindow::on_actionShowStatusbar_triggered() 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); Preferences::instance()->setStatusbarDisplayed(isVisible);
showStatusBar(isVisible); showStatusBar(isVisible);
} }
void MainWindow::on_actionSpeedInTitleBar_triggered() void MainWindow::on_actionSpeedInTitleBar_triggered()
{ {
m_displaySpeedInTitle = static_cast<QAction * >(sender())->isChecked(); m_displaySpeedInTitle = static_cast<QAction *>(sender())->isChecked();
Preferences::instance()->showSpeedInTitleBar(m_displaySpeedInTitle); Preferences::instance()->showSpeedInTitleBar(m_displaySpeedInTitle);
if (m_displaySpeedInTitle) if (m_displaySpeedInTitle)
reloadSessionStats(); reloadSessionStats();
@ -2097,7 +2090,7 @@ void MainWindow::checkProgramUpdate()
m_ui->actionCheckForUpdates->setEnabled(false); m_ui->actionCheckForUpdates->setEnabled(false);
m_ui->actionCheckForUpdates->setText(tr("Checking for Updates...")); m_ui->actionCheckForUpdates->setText(tr("Checking for Updates..."));
m_ui->actionCheckForUpdates->setToolTip(tr("Already checking for program updates in the background")); 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); ProgramUpdater *updater = new ProgramUpdater(this, invokedByUser);
connect(updater, &ProgramUpdater::updateCheckFinished, this, &MainWindow::handleUpdateCheckFinished); connect(updater, &ProgramUpdater::updateCheckFinished, this, &MainWindow::handleUpdateCheckFinished);
updater->checkForUpdates(); updater->checkForUpdates();

14
src/gui/properties/peerlistwidget.cpp

@ -270,8 +270,8 @@ void PeerListWidget::showPeerListMenu(const QPoint &)
// Do not allow user to add peers in a private torrent // Do not allow user to add peers in a private torrent
if (!torrent->isQueued() && !torrent->isChecking() && !torrent->isPrivate()) if (!torrent->isQueued() && !torrent->isChecking() && !torrent->isPrivate())
{ {
const QAction *addPeerAct = menu->addAction(UIThemeManager::instance()->getIcon("user-group-new"), tr("Add a new peer...")); menu->addAction(UIThemeManager::instance()->getIcon("user-group-new"), tr("Add a new peer...")
connect(addPeerAct, &QAction::triggered, this, [this, torrent]() , this, [this, torrent]()
{ {
const QVector<BitTorrent::PeerAddress> peersList = PeersAdditionDialog::askForPeers(this); const QVector<BitTorrent::PeerAddress> peersList = PeersAdditionDialog::askForPeers(this);
const int peerCount = std::count_if(peersList.cbegin(), peersList.cend(), [torrent](const BitTorrent::PeerAddress &peer) 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()) if (!selectionModel()->selectedRows().isEmpty())
{ {
const QAction *copyPeerAct = menu->addAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Copy IP:port")); menu->addAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Copy IP:port")
connect(copyPeerAct, &QAction::triggered, this, &PeerListWidget::copySelectedPeers); , this, &PeerListWidget::copySelectedPeers);
menu->addSeparator(); menu->addSeparator();
menu->addAction(UIThemeManager::instance()->getIcon("user-group-delete"), tr("Ban peer permanently")
const QAction *banAct = menu->addAction(UIThemeManager::instance()->getIcon("user-group-delete"), tr("Ban peer permanently")); , this, &PeerListWidget::banSelectedPeers);
connect(banAct, &QAction::triggered, this, &PeerListWidget::banSelectedPeers);
} }
if (menu->isEmpty()) if (menu->isEmpty())

94
src/gui/properties/propertieswidget.cpp

@ -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());

23
src/gui/properties/propertieswidget.ui

@ -1086,29 +1086,6 @@
</widget> </widget>
</item> </item>
</layout> </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> </widget>
<customwidgets> <customwidgets>
<customwidget> <customwidget>

28
src/gui/properties/trackerlistwidget.cpp

@ -592,30 +592,26 @@ void TrackerListWidget::showTrackerListMenu(const QPoint &)
menu->setAttribute(Qt::WA_DeleteOnClose); menu->setAttribute(Qt::WA_DeleteOnClose);
// Add actions // Add actions
const QAction *addAct = menu->addAction(UIThemeManager::instance()->getIcon("list-add"), tr("Add a new tracker...")); menu->addAction(UIThemeManager::instance()->getIcon("list-add"), tr("Add a new tracker...")
connect(addAct, &QAction::triggered, this, &TrackerListWidget::askForTrackers); , this, &TrackerListWidget::askForTrackers);
if (!getSelectedTrackerItems().isEmpty()) if (!getSelectedTrackerItems().isEmpty())
{ {
const QAction *editAct = menu->addAction(UIThemeManager::instance()->getIcon("edit-rename"),tr("Edit tracker URL...")); menu->addAction(UIThemeManager::instance()->getIcon("edit-rename"),tr("Edit tracker URL...")
connect(editAct, &QAction::triggered, this, &TrackerListWidget::editSelectedTracker); , this, &TrackerListWidget::editSelectedTracker);
menu->addAction(UIThemeManager::instance()->getIcon("list-remove"), tr("Remove tracker")
const QAction *delAct = menu->addAction(UIThemeManager::instance()->getIcon("list-remove"), tr("Remove tracker")); , this, &TrackerListWidget::deleteSelectedTrackers);
connect(delAct, &QAction::triggered, this, &TrackerListWidget::deleteSelectedTrackers); menu->addAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Copy tracker URL")
, this, &TrackerListWidget::copyTrackerUrl);
const QAction *copyAct = menu->addAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Copy tracker URL"));
connect(copyAct, &QAction::triggered, this, &TrackerListWidget::copyTrackerUrl);
} }
if (!torrent->isPaused()) if (!torrent->isPaused())
{ {
const QAction *reannounceSelAct = menu->addAction(UIThemeManager::instance()->getIcon("view-refresh"), tr("Force reannounce to selected trackers")); menu->addAction(UIThemeManager::instance()->getIcon("view-refresh"), tr("Force reannounce to selected trackers")
connect(reannounceSelAct, &QAction::triggered, this, &TrackerListWidget::reannounceSelected); , this, &TrackerListWidget::reannounceSelected);
menu->addSeparator(); menu->addSeparator();
menu->addAction(UIThemeManager::instance()->getIcon("view-refresh"), tr("Force reannounce to all trackers")
const QAction *reannounceAllAct = menu->addAction(UIThemeManager::instance()->getIcon("view-refresh"), tr("Force reannounce to all trackers")); , this, [this]()
connect(reannounceAllAct, &QAction::triggered, this, [this]()
{ {
BitTorrent::Torrent *h = m_properties->getCurrentTorrent(); BitTorrent::Torrent *h = m_properties->getCurrentTorrent();
h->forceReannounce(); h->forceReannounce();

23
src/gui/rss/automatedrssdownloader.cpp

@ -490,8 +490,8 @@ void AutomatedRssDownloader::displayRulesListMenu()
QMenu *menu = new QMenu(this); QMenu *menu = new QMenu(this);
menu->setAttribute(Qt::WA_DeleteOnClose); menu->setAttribute(Qt::WA_DeleteOnClose);
const QAction *addAct = menu->addAction(UIThemeManager::instance()->getIcon("list-add"), tr("Add new rule...")); menu->addAction(UIThemeManager::instance()->getIcon("list-add"), tr("Add new rule...")
connect(addAct, &QAction::triggered, this, &AutomatedRssDownloader::on_addRuleBtn_clicked); , this, &AutomatedRssDownloader::on_addRuleBtn_clicked);
const QList<QListWidgetItem *> selection = m_ui->listRules->selectedItems(); const QList<QListWidgetItem *> selection = m_ui->listRules->selectedItems();
@ -499,24 +499,21 @@ void AutomatedRssDownloader::displayRulesListMenu()
{ {
if (selection.count() == 1) if (selection.count() == 1)
{ {
const QAction *delAct = menu->addAction(UIThemeManager::instance()->getIcon("list-remove"), tr("Delete rule")); menu->addAction(UIThemeManager::instance()->getIcon("list-remove"), tr("Delete rule")
connect(delAct, &QAction::triggered, this, &AutomatedRssDownloader::on_removeRuleBtn_clicked); , this, &AutomatedRssDownloader::on_removeRuleBtn_clicked);
menu->addSeparator(); menu->addSeparator();
menu->addAction(UIThemeManager::instance()->getIcon("edit-rename"), tr("Rename rule...")
const QAction *renameAct = menu->addAction(UIThemeManager::instance()->getIcon("edit-rename"), tr("Rename rule...")); , this, &AutomatedRssDownloader::renameSelectedRule);
connect(renameAct, &QAction::triggered, this, &AutomatedRssDownloader::renameSelectedRule);
} }
else else
{ {
const QAction *delAct = menu->addAction(UIThemeManager::instance()->getIcon("list-remove"), tr("Delete selected rules")); menu->addAction(UIThemeManager::instance()->getIcon("list-remove"), tr("Delete selected rules")
connect(delAct, &QAction::triggered, this, &AutomatedRssDownloader::on_removeRuleBtn_clicked); , this, &AutomatedRssDownloader::on_removeRuleBtn_clicked);
} }
menu->addSeparator(); menu->addSeparator();
menu->addAction(UIThemeManager::instance()->getIcon("edit-clear"), tr("Clear downloaded episodes...")
const QAction *clearAct = menu->addAction(UIThemeManager::instance()->getIcon("edit-clear"), tr("Clear downloaded episodes...")); , this, &AutomatedRssDownloader::clearSelectedRuleDownloadedEpisodeList);
connect(clearAct, &QAction::triggered, this, &AutomatedRssDownloader::clearSelectedRuleDownloadedEpisodeList);
} }
menu->popup(QCursor::pos()); menu->popup(QCursor::pos());

28
src/gui/search/searchjobwidget.cpp

@ -393,31 +393,21 @@ void SearchJobWidget::contextMenuEvent(QContextMenuEvent *event)
auto *menu = new QMenu(this); auto *menu = new QMenu(this);
menu->setAttribute(Qt::WA_DeleteOnClose); menu->setAttribute(Qt::WA_DeleteOnClose);
const QAction *downloadAction = menu->addAction( menu->addAction(UIThemeManager::instance()->getIcon("download"), tr("Download")
UIThemeManager::instance()->getIcon("download"), tr("Download")); , this, &SearchJobWidget::downloadTorrents);
connect(downloadAction, &QAction::triggered, this, &SearchJobWidget::downloadTorrents);
menu->addSeparator(); menu->addSeparator();
menu->addAction(UIThemeManager::instance()->getIcon("application-x-mswinurl"), tr("Open description page")
const QAction *openDescriptionAction = menu->addAction( , this, &SearchJobWidget::openTorrentPages);
UIThemeManager::instance()->getIcon("application-x-mswinurl"), tr("Open description page"));
connect(openDescriptionAction, &QAction::triggered, this, &SearchJobWidget::openTorrentPages);
QMenu *copySubMenu = menu->addMenu( QMenu *copySubMenu = menu->addMenu(
UIThemeManager::instance()->getIcon("edit-copy"), tr("Copy")); UIThemeManager::instance()->getIcon("edit-copy"), tr("Copy"));
const QAction *copyNamesAction = copySubMenu->addAction( copySubMenu->addAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Name")
UIThemeManager::instance()->getIcon("edit-copy"), tr("Name")); , this, &SearchJobWidget::copyTorrentNames);
connect(copyNamesAction, &QAction::triggered, this, &SearchJobWidget::copyTorrentNames); copySubMenu->addAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Download link")
const QAction *copyDownloadLinkAction = copySubMenu->addAction(
UIThemeManager::instance()->getIcon("edit-copy"), tr("Download link"));
connect(copyDownloadLinkAction, &QAction::triggered
, this, &SearchJobWidget::copyTorrentDownloadLinks); , this, &SearchJobWidget::copyTorrentDownloadLinks);
copySubMenu->addAction(UIThemeManager::instance()->getIcon("edit-copy"), tr("Description page URL")
const QAction *copyDescriptionAction = copySubMenu->addAction( , this, &SearchJobWidget::copyTorrentURLs);
UIThemeManager::instance()->getIcon("edit-copy"), tr("Description page URL"));
connect(copyDescriptionAction, &QAction::triggered, this, &SearchJobWidget::copyTorrentURLs);
menu->popup(event->globalPos()); menu->popup(event->globalPos());
} }

42
src/gui/tagfilterwidget.cpp

@ -28,7 +28,6 @@
#include "tagfilterwidget.h" #include "tagfilterwidget.h"
#include <QAction>
#include <QMenu> #include <QMenu>
#include <QMessageBox> #include <QMessageBox>
@ -108,44 +107,25 @@ void TagFilterWidget::showMenu(QPoint)
QMenu *menu = new QMenu(this); QMenu *menu = new QMenu(this);
menu->setAttribute(Qt::WA_DeleteOnClose); menu->setAttribute(Qt::WA_DeleteOnClose);
const QAction *addAct = menu->addAction( menu->addAction(UIThemeManager::instance()->getIcon("list-add"), tr("Add tag...")
UIThemeManager::instance()->getIcon("list-add") , this, &TagFilterWidget::addTag);
, tr("Add tag..."));
connect(addAct, &QAction::triggered, this, &TagFilterWidget::addTag);
const auto selectedRows = selectionModel()->selectedRows(); const auto selectedRows = selectionModel()->selectedRows();
if (!selectedRows.empty() && !TagFilterModel::isSpecialItem(selectedRows.first())) if (!selectedRows.empty() && !TagFilterModel::isSpecialItem(selectedRows.first()))
{ {
const QAction *removeAct = menu->addAction( menu->addAction(UIThemeManager::instance()->getIcon("list-remove"), tr("Remove tag")
UIThemeManager::instance()->getIcon("list-remove") , this, &TagFilterWidget::removeTag);
, tr("Remove tag"));
connect(removeAct, &QAction::triggered, this, &TagFilterWidget::removeTag);
} }
const QAction *removeUnusedAct = menu->addAction( menu->addAction(UIThemeManager::instance()->getIcon("list-remove"), tr("Remove unused tags")
UIThemeManager::instance()->getIcon("list-remove") , this, &TagFilterWidget::removeUnusedTags);
, tr("Remove unused tags"));
connect(removeUnusedAct, &QAction::triggered, this, &TagFilterWidget::removeUnusedTags);
menu->addSeparator(); menu->addSeparator();
menu->addAction(UIThemeManager::instance()->getIcon("media-playback-start"), tr("Resume torrents")
const QAction *startAct = menu->addAction(
UIThemeManager::instance()->getIcon("media-playback-start")
, tr("Resume torrents"));
connect(startAct, &QAction::triggered
, this, &TagFilterWidget::actionResumeTorrentsTriggered); , this, &TagFilterWidget::actionResumeTorrentsTriggered);
menu->addAction(UIThemeManager::instance()->getIcon("media-playback-pause"), tr("Pause torrents")
const QAction *pauseAct = menu->addAction( , this, &TagFilterWidget::actionPauseTorrentsTriggered);
UIThemeManager::instance()->getIcon("media-playback-pause") menu->addAction(UIThemeManager::instance()->getIcon("edit-delete"), tr("Delete torrents")
, tr("Pause torrents")); , this, &TagFilterWidget::actionDeleteTorrentsTriggered);
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->popup(QCursor::pos()); menu->popup(QCursor::pos());
} }

14
src/gui/transferlistfilterswidget.cpp

@ -557,14 +557,12 @@ void TrackerFiltersList::showMenu(const QPoint &)
QMenu *menu = new QMenu(this); QMenu *menu = new QMenu(this);
menu->setAttribute(Qt::WA_DeleteOnClose); menu->setAttribute(Qt::WA_DeleteOnClose);
const QAction *startAct = menu->addAction(UIThemeManager::instance()->getIcon("media-playback-start"), tr("Resume torrents")); menu->addAction(UIThemeManager::instance()->getIcon("media-playback-start"), tr("Resume torrents")
connect(startAct, &QAction::triggered, transferList, &TransferListWidget::startVisibleTorrents); , transferList, &TransferListWidget::startVisibleTorrents);
menu->addAction(UIThemeManager::instance()->getIcon("media-playback-pause"), tr("Pause torrents")
const QAction *pauseAct = menu->addAction(UIThemeManager::instance()->getIcon("media-playback-pause"), tr("Pause torrents")); , transferList, &TransferListWidget::pauseVisibleTorrents);
connect(pauseAct, &QAction::triggered, transferList, &TransferListWidget::pauseVisibleTorrents); menu->addAction(UIThemeManager::instance()->getIcon("edit-delete"), tr("Delete torrents")
, transferList, &TransferListWidget::deleteVisibleTorrents);
const QAction *deleteTorrentsAct = menu->addAction(UIThemeManager::instance()->getIcon("edit-delete"), tr("Delete torrents"));
connect(deleteTorrentsAct, &QAction::triggered, transferList, &TransferListWidget::deleteVisibleTorrents);
menu->popup(QCursor::pos()); menu->popup(QCursor::pos());
} }

28
src/gui/transferlistwidget.cpp

@ -843,7 +843,7 @@ void TransferListWidget::displayListMenu(const QPoint &)
auto *actionAutoTMM = new TriStateAction(tr("Automatic Torrent Management"), listMenu); 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")); 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); 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); connect(actionEditTracker, &QAction::triggered, this, &TransferListWidget::editTorrentTrackers);
// End of actions // End of actions
@ -969,27 +969,23 @@ void TransferListWidget::displayListMenu(const QPoint &)
QMenu *categoryMenu = listMenu->addMenu(UIThemeManager::instance()->getIcon("view-categories"), tr("Category")); 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...")); categoryMenu->addAction(UIThemeManager::instance()->getIcon("list-add"), tr("New...", "New category...")
connect(newCategoryAction, &QAction::triggered, this, &TransferListWidget::askNewCategoryForSelection); , this, &TransferListWidget::askNewCategoryForSelection);
categoryMenu->addAction(UIThemeManager::instance()->getIcon("edit-clear"), tr("Reset", "Reset category")
const QAction *resetCategoryAction = categoryMenu->addAction(UIThemeManager::instance()->getIcon("edit-clear"), tr("Reset", "Reset category")); , this, [this]() { setSelectionCategory(""); });
connect(resetCategoryAction, &QAction::triggered, this, [this]() { setSelectionCategory(""); });
categoryMenu->addSeparator(); categoryMenu->addSeparator();
for (const QString &category : asConst(categories)) for (const QString &category : asConst(categories))
{ {
const QString escapedCategory = QString(category).replace('&', "&&"); // avoid '&' becomes accelerator key 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)) if (allSameCategory && (category == firstCategory))
{ {
cat->setCheckable(true); cat->setCheckable(true);
cat->setChecked(true); cat->setChecked(true);
} }
connect(cat, &QAction::triggered, this, [this, category]() { setSelectionCategory(category); });
categoryMenu->addAction(cat);
} }
// Tag Menu // Tag Menu
@ -998,18 +994,16 @@ void TransferListWidget::displayListMenu(const QPoint &)
QMenu *tagsMenu = listMenu->addMenu(UIThemeManager::instance()->getIcon("view-categories"), tr("Tags")); 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...")); tagsMenu->addAction(UIThemeManager::instance()->getIcon("list-add"), tr("Add...", "Add / assign multiple tags...")
connect(addTagAction, &QAction::triggered, this, &TransferListWidget::askAddTagsForSelection); , this, &TransferListWidget::askAddTagsForSelection);
tagsMenu->addAction(UIThemeManager::instance()->getIcon("edit-clear"), tr("Remove All", "Remove all tags")
const QAction *removeTagsAction = tagsMenu->addAction(UIThemeManager::instance()->getIcon("edit-clear"), tr("Remove All", "Remove all tags")); , this, [this]()
connect(removeTagsAction, &QAction::triggered, this, [this]()
{ {
if (Preferences::instance()->confirmRemoveAllTags()) if (Preferences::instance()->confirmRemoveAllTags())
confirmRemoveAllTagsForSelection(); confirmRemoveAllTagsForSelection();
else else
clearSelectionTags(); clearSelectionTags();
}); });
tagsMenu->addSeparator(); tagsMenu->addSeparator();
for (const QString &tag : asConst(tags)) for (const QString &tag : asConst(tags))

Loading…
Cancel
Save