mirror of
https://github.com/qbittorrent/qBittorrent
synced 2025-07-14 09:13:08 -07:00
Fix inhibit system functionality. Closes #766.
This commit is contained in:
parent
ad69cbb318
commit
f09328c13c
3 changed files with 20 additions and 5 deletions
|
@ -1409,11 +1409,7 @@ void MainWindow::on_actionAutoShutdown_system_toggled(bool enabled)
|
||||||
|
|
||||||
void MainWindow::checkForActiveTorrents()
|
void MainWindow::checkForActiveTorrents()
|
||||||
{
|
{
|
||||||
const TorrentStatusReport report = transferList->getSourceModel()->getTorrentStatusReport();
|
m_pwr->setActivityState(transferList->getSourceModel()->inhibitSystem());
|
||||||
if (report.nb_active > 0) // Active torrents are present; prevent system from suspend
|
|
||||||
m_pwr->setActivityState(true);
|
|
||||||
else
|
|
||||||
m_pwr->setActivityState(false);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
QIcon MainWindow::getSystrayIcon() const
|
QIcon MainWindow::getSystrayIcon() const
|
||||||
|
|
|
@ -483,3 +483,21 @@ void TorrentModel::handleTorrentAboutToBeRemoved(const QTorrentHandle &h)
|
||||||
emit torrentAboutToBeRemoved(m_torrents.at(row));
|
emit torrentAboutToBeRemoved(m_torrents.at(row));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TorrentModel::inhibitSystem()
|
||||||
|
{
|
||||||
|
QList<TorrentModelItem*>::const_iterator it = m_torrents.constBegin();
|
||||||
|
QList<TorrentModelItem*>::const_iterator itend = m_torrents.constEnd();
|
||||||
|
for ( ; it != itend; ++it) {
|
||||||
|
switch((*it)->data(TorrentModelItem::TR_STATUS).toInt()) {
|
||||||
|
case TorrentModelItem::STATE_DOWNLOADING:
|
||||||
|
case TorrentModelItem::STATE_STALLED_DL:
|
||||||
|
case TorrentModelItem::STATE_SEEDING:
|
||||||
|
case TorrentModelItem::STATE_STALLED_UP:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
@ -94,6 +94,7 @@ public:
|
||||||
TorrentStatusReport getTorrentStatusReport() const;
|
TorrentStatusReport getTorrentStatusReport() const;
|
||||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
Qt::ItemFlags flags(const QModelIndex &index) const;
|
||||||
void populate();
|
void populate();
|
||||||
|
bool inhibitSystem();
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void torrentAdded(TorrentModelItem *torrentItem);
|
void torrentAdded(TorrentModelItem *torrentItem);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue