Browse Source

Move menu actions out of .ui files

This is to move related code together.
adaptive-webui-19844
Chocobo1 4 years ago
parent
commit
3985d58d3c
No known key found for this signature in database
GPG Key ID: 210D9C873253A68C
  1. 15
      src/gui/addnewtorrentdialog.cpp
  2. 20
      src/gui/addnewtorrentdialog.ui
  3. 19
      src/gui/properties/propertieswidget.cpp
  4. 23
      src/gui/properties/propertieswidget.ui

15
src/gui/addnewtorrentdialog.cpp

@ -525,29 +525,22 @@ void AddNewTorrentDialog::displayContentTreeMenu(const QPoint &)
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);
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>

19
src/gui/properties/propertieswidget.cpp

@ -600,8 +600,6 @@ void PropertiesWidget::displayFilesListMenu(const QPoint &)
if (!m_torrent->isSeed()) if (!m_torrent->isSeed())
{ {
QMenu *subMenu = menu->addMenu(tr("Priority"));
const auto applyPriorities = [this, selectedRows](const BitTorrent::DownloadPriority prio) const auto applyPriorities = [this, selectedRows](const BitTorrent::DownloadPriority prio)
{ {
for (const QModelIndex &index : selectedRows) for (const QModelIndex &index : selectedRows)
@ -614,29 +612,24 @@ void PropertiesWidget::displayFilesListMenu(const QPoint &)
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);
} }
// The selected torrent might have disappeared during exec() // The selected torrent might have disappeared during exec()

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>

Loading…
Cancel
Save