mirror of
https://github.com/d47081/qBittorrent.git
synced 2025-01-11 07:18:08 +00:00
Merge pull request #10835 from Chocobo1/exec
Avoid creating unnecessary event loops
This commit is contained in:
commit
17c601e8b8
@ -1754,14 +1754,16 @@ bool OptionsDialog::isAlternativeWebUIPathValid()
|
|||||||
|
|
||||||
void OptionsDialog::on_banListButton_clicked()
|
void OptionsDialog::on_banListButton_clicked()
|
||||||
{
|
{
|
||||||
// call dialog window
|
auto dialog = new BanListOptionsDialog(this);
|
||||||
if (BanListOptionsDialog(this).exec() == QDialog::Accepted)
|
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
enableApplyButton();
|
connect(dialog, &QDialog::accepted, this, &OptionsDialog::enableApplyButton);
|
||||||
|
dialog->open();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OptionsDialog::on_IPSubnetWhitelistButton_clicked()
|
void OptionsDialog::on_IPSubnetWhitelistButton_clicked()
|
||||||
{
|
{
|
||||||
// call dialog window
|
auto dialog = new IPSubnetWhitelistOptionsDialog(this);
|
||||||
if (IPSubnetWhitelistOptionsDialog(this).exec() == QDialog::Accepted)
|
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
enableApplyButton();
|
connect(dialog, &QDialog::accepted, this, &OptionsDialog::enableApplyButton);
|
||||||
|
dialog->open();
|
||||||
}
|
}
|
||||||
|
@ -405,39 +405,44 @@ void SearchJobWidget::saveSettings() const
|
|||||||
Preferences::instance()->setSearchTabHeaderState(header()->saveState());
|
Preferences::instance()->setSearchTabHeaderState(header()->saveState());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchJobWidget::displayToggleColumnsMenu(const QPoint&)
|
void SearchJobWidget::displayToggleColumnsMenu(const QPoint &)
|
||||||
{
|
{
|
||||||
QMenu hideshowColumn(this);
|
auto menu = new QMenu(this);
|
||||||
hideshowColumn.setTitle(tr("Column visibility"));
|
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
QList<QAction*> actions;
|
menu->setTitle(tr("Column visibility"));
|
||||||
|
|
||||||
for (int i = 0; i < SearchSortModel::DL_LINK; ++i) {
|
for (int i = 0; i < SearchSortModel::DL_LINK; ++i) {
|
||||||
QAction *myAct = hideshowColumn.addAction(m_searchListModel->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString());
|
QAction *myAct = menu->addAction(m_searchListModel->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString());
|
||||||
myAct->setCheckable(true);
|
myAct->setCheckable(true);
|
||||||
myAct->setChecked(!m_ui->resultsBrowser->isColumnHidden(i));
|
myAct->setChecked(!m_ui->resultsBrowser->isColumnHidden(i));
|
||||||
actions.append(myAct);
|
myAct->setData(i);
|
||||||
}
|
|
||||||
int visibleCols = 0;
|
|
||||||
for (int i = 0; i < SearchSortModel::DL_LINK; ++i) {
|
|
||||||
if (!m_ui->resultsBrowser->isColumnHidden(i))
|
|
||||||
++visibleCols;
|
|
||||||
|
|
||||||
if (visibleCols > 1)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call menu
|
connect(menu, &QMenu::triggered, this, [this](const QAction *action)
|
||||||
QAction *act = hideshowColumn.exec(QCursor::pos());
|
{
|
||||||
if (act) {
|
int visibleCols = 0;
|
||||||
int col = actions.indexOf(act);
|
for (int i = 0; i < SearchSortModel::DL_LINK; ++i) {
|
||||||
Q_ASSERT(col >= 0);
|
if (!m_ui->resultsBrowser->isColumnHidden(i))
|
||||||
Q_ASSERT(visibleCols > 0);
|
++visibleCols;
|
||||||
|
|
||||||
|
if (visibleCols > 1)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int col = action->data().toInt();
|
||||||
|
|
||||||
if ((!m_ui->resultsBrowser->isColumnHidden(col)) && (visibleCols == 1))
|
if ((!m_ui->resultsBrowser->isColumnHidden(col)) && (visibleCols == 1))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
m_ui->resultsBrowser->setColumnHidden(col, !m_ui->resultsBrowser->isColumnHidden(col));
|
m_ui->resultsBrowser->setColumnHidden(col, !m_ui->resultsBrowser->isColumnHidden(col));
|
||||||
|
|
||||||
if ((!m_ui->resultsBrowser->isColumnHidden(col)) && (m_ui->resultsBrowser->columnWidth(col) <= 5))
|
if ((!m_ui->resultsBrowser->isColumnHidden(col)) && (m_ui->resultsBrowser->columnWidth(col) <= 5))
|
||||||
m_ui->resultsBrowser->resizeColumnToContents(col);
|
m_ui->resultsBrowser->resizeColumnToContents(col);
|
||||||
|
|
||||||
saveSettings();
|
saveSettings();
|
||||||
}
|
});
|
||||||
|
|
||||||
|
menu->popup(QCursor::pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
void SearchJobWidget::searchFinished(bool cancelled)
|
void SearchJobWidget::searchFinished(bool cancelled)
|
||||||
|
@ -99,7 +99,7 @@ private:
|
|||||||
void updateFilter();
|
void updateFilter();
|
||||||
void filterSearchResults(const QString &name);
|
void filterSearchResults(const QString &name);
|
||||||
void showFilterContextMenu(const QPoint &);
|
void showFilterContextMenu(const QPoint &);
|
||||||
void displayToggleColumnsMenu(const QPoint&);
|
void displayToggleColumnsMenu(const QPoint &);
|
||||||
void onItemDoubleClicked(const QModelIndex &index);
|
void onItemDoubleClicked(const QModelIndex &index);
|
||||||
void searchFinished(bool cancelled);
|
void searchFinished(bool cancelled);
|
||||||
void searchFailed();
|
void searchFailed();
|
||||||
|
@ -89,13 +89,16 @@ void TorrentCategoryDialog::editCategory(QWidget *parent, const QString &categor
|
|||||||
|
|
||||||
Q_ASSERT(Session::instance()->categories().contains(categoryName));
|
Q_ASSERT(Session::instance()->categories().contains(categoryName));
|
||||||
|
|
||||||
TorrentCategoryDialog dialog(parent);
|
auto dialog = new TorrentCategoryDialog(parent);
|
||||||
dialog.setCategoryNameEditable(false);
|
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
dialog.setCategoryName(categoryName);
|
dialog->setCategoryNameEditable(false);
|
||||||
dialog.setSavePath(Session::instance()->categories()[categoryName]);
|
dialog->setCategoryName(categoryName);
|
||||||
if (dialog.exec() == TorrentCategoryDialog::Accepted) {
|
dialog->setSavePath(Session::instance()->categories()[categoryName]);
|
||||||
Session::instance()->editCategory(categoryName, dialog.savePath());
|
connect(dialog, &TorrentCategoryDialog::accepted, parent, [dialog, categoryName]()
|
||||||
}
|
{
|
||||||
|
Session::instance()->editCategory(categoryName, dialog->savePath());
|
||||||
|
});
|
||||||
|
dialog->open();
|
||||||
}
|
}
|
||||||
|
|
||||||
void TorrentCategoryDialog::setCategoryNameEditable(bool editable)
|
void TorrentCategoryDialog::setCategoryNameEditable(bool editable)
|
||||||
|
@ -688,17 +688,22 @@ void TransferListWidget::setMaxRatioSelectedTorrents()
|
|||||||
useGlobalValue = (torrents[0]->ratioLimit() == BitTorrent::TorrentHandle::USE_GLOBAL_RATIO)
|
useGlobalValue = (torrents[0]->ratioLimit() == BitTorrent::TorrentHandle::USE_GLOBAL_RATIO)
|
||||||
&& (torrents[0]->seedingTimeLimit() == BitTorrent::TorrentHandle::USE_GLOBAL_SEEDING_TIME);
|
&& (torrents[0]->seedingTimeLimit() == BitTorrent::TorrentHandle::USE_GLOBAL_SEEDING_TIME);
|
||||||
|
|
||||||
UpDownRatioDialog dlg(useGlobalValue, currentMaxRatio, BitTorrent::TorrentHandle::MAX_RATIO,
|
auto dialog = new UpDownRatioDialog(useGlobalValue, currentMaxRatio, BitTorrent::TorrentHandle::MAX_RATIO,
|
||||||
currentMaxSeedingTime, BitTorrent::TorrentHandle::MAX_SEEDING_TIME, this);
|
currentMaxSeedingTime, BitTorrent::TorrentHandle::MAX_SEEDING_TIME, this);
|
||||||
if (dlg.exec() != QDialog::Accepted) return;
|
dialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
|
connect(dialog, &QDialog::accepted, this, [this, dialog, torrents]()
|
||||||
|
{
|
||||||
|
for (BitTorrent::TorrentHandle *const torrent : torrents) {
|
||||||
|
const qreal ratio = (dialog->useDefault()
|
||||||
|
? BitTorrent::TorrentHandle::USE_GLOBAL_RATIO : dialog->ratio());
|
||||||
|
torrent->setRatioLimit(ratio);
|
||||||
|
|
||||||
for (BitTorrent::TorrentHandle *const torrent : torrents) {
|
const int seedingTime = (dialog->useDefault()
|
||||||
qreal ratio = (dlg.useDefault() ? BitTorrent::TorrentHandle::USE_GLOBAL_RATIO : dlg.ratio());
|
? BitTorrent::TorrentHandle::USE_GLOBAL_SEEDING_TIME : dialog->seedingTime());
|
||||||
torrent->setRatioLimit(ratio);
|
torrent->setSeedingTimeLimit(seedingTime);
|
||||||
|
}
|
||||||
int seedingTime = (dlg.useDefault() ? BitTorrent::TorrentHandle::USE_GLOBAL_SEEDING_TIME : dlg.seedingTime());
|
});
|
||||||
torrent->setSeedingTimeLimit(seedingTime);
|
dialog->open();
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListWidget::recheckSelectedTorrents()
|
void TransferListWidget::recheckSelectedTorrents()
|
||||||
@ -721,41 +726,45 @@ void TransferListWidget::reannounceSelectedTorrents()
|
|||||||
// hide/show columns menu
|
// hide/show columns menu
|
||||||
void TransferListWidget::displayDLHoSMenu(const QPoint&)
|
void TransferListWidget::displayDLHoSMenu(const QPoint&)
|
||||||
{
|
{
|
||||||
QMenu hideshowColumn(this);
|
auto menu = new QMenu(this);
|
||||||
hideshowColumn.setTitle(tr("Column visibility"));
|
menu->setAttribute(Qt::WA_DeleteOnClose);
|
||||||
QList<QAction*> actions;
|
menu->setTitle(tr("Column visibility"));
|
||||||
|
|
||||||
for (int i = 0; i < m_listModel->columnCount(); ++i) {
|
for (int i = 0; i < m_listModel->columnCount(); ++i) {
|
||||||
if (!BitTorrent::Session::instance()->isQueueingSystemEnabled() && (i == TransferListModel::TR_PRIORITY)) {
|
if (!BitTorrent::Session::instance()->isQueueingSystemEnabled() && (i == TransferListModel::TR_PRIORITY))
|
||||||
actions.append(nullptr);
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
QAction *myAct = hideshowColumn.addAction(m_listModel->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString());
|
QAction *myAct = menu->addAction(m_listModel->headerData(i, Qt::Horizontal, Qt::DisplayRole).toString());
|
||||||
myAct->setCheckable(true);
|
myAct->setCheckable(true);
|
||||||
myAct->setChecked(!isColumnHidden(i));
|
myAct->setChecked(!isColumnHidden(i));
|
||||||
actions.append(myAct);
|
myAct->setData(i);
|
||||||
}
|
|
||||||
int visibleCols = 0;
|
|
||||||
for (int i = 0; i < TransferListModel::NB_COLUMNS; ++i) {
|
|
||||||
if (!isColumnHidden(i))
|
|
||||||
++visibleCols;
|
|
||||||
|
|
||||||
if (visibleCols > 1)
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call menu
|
connect(menu, &QMenu::triggered, this, [this](const QAction *action)
|
||||||
QAction *act = hideshowColumn.exec(QCursor::pos());
|
{
|
||||||
if (act) {
|
int visibleCols = 0;
|
||||||
int col = actions.indexOf(act);
|
for (int i = 0; i < TransferListModel::NB_COLUMNS; ++i) {
|
||||||
Q_ASSERT(col >= 0);
|
if (!isColumnHidden(i))
|
||||||
Q_ASSERT(visibleCols > 0);
|
++visibleCols;
|
||||||
|
|
||||||
|
if (visibleCols > 1)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
const int col = action->data().toInt();
|
||||||
|
|
||||||
if (!isColumnHidden(col) && visibleCols == 1)
|
if (!isColumnHidden(col) && visibleCols == 1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
setColumnHidden(col, !isColumnHidden(col));
|
setColumnHidden(col, !isColumnHidden(col));
|
||||||
|
|
||||||
if (!isColumnHidden(col) && columnWidth(col) <= 5)
|
if (!isColumnHidden(col) && columnWidth(col) <= 5)
|
||||||
resizeColumnToContents(col);
|
resizeColumnToContents(col);
|
||||||
|
|
||||||
saveSettings();
|
saveSettings();
|
||||||
}
|
});
|
||||||
|
|
||||||
|
menu->popup(QCursor::pos());
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListWidget::toggleSelectedTorrentsSuperSeeding() const
|
void TransferListWidget::toggleSelectedTorrentsSuperSeeding() const
|
||||||
|
Loading…
Reference in New Issue
Block a user