mirror of
https://github.com/qbittorrent/qBittorrent.git
synced 2024-12-21 08:09:35 +08:00
Merge pull request #6157 from Chocobo1/speedLimit
Speedlimitdlg: raise slider default value to 10000
This commit is contained in:
commit
05def34697
@ -18,15 +18,6 @@
|
|||||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QSlider" name="bandwidthSlider">
|
<widget class="QSlider" name="bandwidthSlider">
|
||||||
<property name="minimum">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="maximum">
|
|
||||||
<number>1000</number>
|
|
||||||
</property>
|
|
||||||
<property name="sliderPosition">
|
|
||||||
<number>0</number>
|
|
||||||
</property>
|
|
||||||
<property name="orientation">
|
<property name="orientation">
|
||||||
<enum>Qt::Horizontal</enum>
|
<enum>Qt::Horizontal</enum>
|
||||||
</property>
|
</property>
|
||||||
|
@ -104,7 +104,7 @@ void SpeedLimitDialog::setupDialog(long max_slider, long val) const
|
|||||||
if (val < 0)
|
if (val < 0)
|
||||||
val = 0;
|
val = 0;
|
||||||
if (max_slider <= 0)
|
if (max_slider <= 0)
|
||||||
max_slider = 1000;
|
max_slider = 10000;
|
||||||
// This can happen for example if global rate limit is lower
|
// This can happen for example if global rate limit is lower
|
||||||
// than torrent rate limit.
|
// than torrent rate limit.
|
||||||
if (val > max_slider)
|
if (val > max_slider)
|
||||||
|
@ -427,65 +427,56 @@ void TransferListWidget::previewSelectedTorrents()
|
|||||||
|
|
||||||
void TransferListWidget::setDlLimitSelectedTorrents()
|
void TransferListWidget::setDlLimitSelectedTorrents()
|
||||||
{
|
{
|
||||||
QList<BitTorrent::TorrentHandle *> selected_torrents;
|
QList<BitTorrent::TorrentHandle *> TorrentsList;
|
||||||
bool first = true;
|
|
||||||
bool all_same_limit = true;
|
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, getSelectedTorrents()) {
|
foreach (BitTorrent::TorrentHandle *const torrent, getSelectedTorrents()) {
|
||||||
if (!torrent->isSeed()) {
|
if (torrent->isSeed())
|
||||||
selected_torrents << torrent;
|
continue;
|
||||||
// Determine current limit for selected torrents
|
TorrentsList += torrent;
|
||||||
if (first)
|
}
|
||||||
first = false;
|
if (TorrentsList.empty()) return;
|
||||||
else if (all_same_limit && (torrent->downloadLimit() != selected_torrents.first()->downloadLimit()))
|
|
||||||
all_same_limit = false;
|
int oldLimit = TorrentsList.first()->downloadLimit();
|
||||||
|
foreach (BitTorrent::TorrentHandle *const torrent, TorrentsList) {
|
||||||
|
if (torrent->downloadLimit() != oldLimit) {
|
||||||
|
oldLimit = -1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selected_torrents.empty()) return;
|
|
||||||
|
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
int default_limit = -1;
|
const long newLimit = SpeedLimitDialog::askSpeedLimit(
|
||||||
if (all_same_limit)
|
&ok, tr("Torrent Download Speed Limiting"), oldLimit
|
||||||
default_limit = selected_torrents.first()->downloadLimit();
|
|
||||||
const long new_limit = SpeedLimitDialog::askSpeedLimit(
|
|
||||||
&ok, tr("Torrent Download Speed Limiting"), default_limit
|
|
||||||
, BitTorrent::Session::instance()->globalDownloadSpeedLimit());
|
, BitTorrent::Session::instance()->globalDownloadSpeedLimit());
|
||||||
if (ok) {
|
if (!ok) return;
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, selected_torrents) {
|
|
||||||
qDebug("Applying download speed limit of %ld Kb/s to torrent %s", (long)(new_limit / 1024.), qPrintable(torrent->hash()));
|
foreach (BitTorrent::TorrentHandle *const torrent, TorrentsList) {
|
||||||
torrent->setDownloadLimit(new_limit);
|
qDebug("Applying download speed limit of %ld Kb/s to torrent %s", (long) (newLimit / 1024.), qPrintable(torrent->hash()));
|
||||||
}
|
torrent->setDownloadLimit(newLimit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TransferListWidget::setUpLimitSelectedTorrents()
|
void TransferListWidget::setUpLimitSelectedTorrents()
|
||||||
{
|
{
|
||||||
QList<BitTorrent::TorrentHandle *> selected_torrents;
|
QList<BitTorrent::TorrentHandle *> TorrentsList = getSelectedTorrents();
|
||||||
bool first = true;
|
if (TorrentsList.empty()) return;
|
||||||
bool all_same_limit = true;
|
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, getSelectedTorrents()) {
|
int oldLimit = TorrentsList.first()->uploadLimit();
|
||||||
selected_torrents << torrent;
|
foreach (BitTorrent::TorrentHandle *const torrent, TorrentsList) {
|
||||||
// Determine current limit for selected torrents
|
if (torrent->uploadLimit() != oldLimit) {
|
||||||
if (first)
|
oldLimit = -1;
|
||||||
first = false;
|
break;
|
||||||
else if (all_same_limit && (torrent->uploadLimit() != selected_torrents.first()->uploadLimit()))
|
}
|
||||||
all_same_limit = false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (selected_torrents.empty()) return;
|
|
||||||
|
|
||||||
bool ok = false;
|
bool ok = false;
|
||||||
int default_limit = -1;
|
const long newLimit = SpeedLimitDialog::askSpeedLimit(
|
||||||
if (all_same_limit)
|
&ok, tr("Torrent Upload Speed Limiting"), oldLimit
|
||||||
default_limit = selected_torrents.first()->uploadLimit();
|
|
||||||
const long new_limit = SpeedLimitDialog::askSpeedLimit(
|
|
||||||
&ok, tr("Torrent Upload Speed Limiting"), default_limit
|
|
||||||
, BitTorrent::Session::instance()->globalUploadSpeedLimit());
|
, BitTorrent::Session::instance()->globalUploadSpeedLimit());
|
||||||
if (ok) {
|
if (!ok) return;
|
||||||
foreach (BitTorrent::TorrentHandle *const torrent, selected_torrents) {
|
|
||||||
qDebug("Applying upload speed limit of %ld Kb/s to torrent %s", (long)(new_limit / 1024.), qPrintable(torrent->hash()));
|
foreach (BitTorrent::TorrentHandle *const torrent, TorrentsList) {
|
||||||
torrent->setUploadLimit(new_limit);
|
qDebug("Applying upload speed limit of %ld Kb/s to torrent %s", (long) (newLimit / 1024.), qPrintable(torrent->hash()));
|
||||||
}
|
torrent->setUploadLimit(newLimit);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user