From 9178bc53ef14c01ddb6063b25e6e103a764e8c31 Mon Sep 17 00:00:00 2001 From: Phenom Date: Sat, 15 Jan 2022 19:03:06 +0100 Subject: [PATCH] Add max data rate option for when idle. --- retroshare-gui/src/gui/MainWindow.cpp | 3 + retroshare-gui/src/gui/QuickStartWizard.cpp | 18 ++-- .../src/gui/settings/ServerPage.cpp | 24 +++++- retroshare-gui/src/gui/settings/ServerPage.ui | 85 ++++++++++++++++++- 4 files changed, 115 insertions(+), 15 deletions(-) diff --git a/retroshare-gui/src/gui/MainWindow.cpp b/retroshare-gui/src/gui/MainWindow.cpp index 31fa13467..0013112c8 100644 --- a/retroshare-gui/src/gui/MainWindow.cpp +++ b/retroshare-gui/src/gui/MainWindow.cpp @@ -1483,6 +1483,9 @@ void MainWindow::setStatus(QObject *pObject, int nStatus) setStatusObject(*it, nStatus); } } + + rsConfig->setIsIdle(isIdle); + rsConfig->setOperatingMode(rsConfig->getOperatingMode()); } /* new status from context menu */ diff --git a/retroshare-gui/src/gui/QuickStartWizard.cpp b/retroshare-gui/src/gui/QuickStartWizard.cpp index ce953a32e..ddb0bc118 100644 --- a/retroshare-gui/src/gui/QuickStartWizard.cpp +++ b/retroshare-gui/src/gui/QuickStartWizard.cpp @@ -159,10 +159,10 @@ void QuickStartWizard::on_pushButtonConnectionNext_clicked() { rsPeers->setVisState(rsPeers->getOwnId(), vs_disc, vs_dht); } - - rsConfig->SetMaxDataRates( ui.doubleSpinBoxDownloadSpeed->value(), ui.doubleSpinBoxUploadSpeed->value() ); - ui.pagesWizard->setCurrentIndex(2); + rsConfig->setMaxDataRates( ui.doubleSpinBoxDownloadSpeed->value(), ui.doubleSpinBoxUploadSpeed->value(), ui.doubleSpinBoxDownloadSpeed->value(), ui.doubleSpinBoxUploadSpeed->value() ); + + ui.pagesWizard->setCurrentIndex(2); } void QuickStartWizard::on_pushButtonConnectionExit_clicked() @@ -488,10 +488,12 @@ void QuickStartWizard::loadNetwork() ui.discoveryComboBox->setCurrentIndex(netIndex); int dlrate = 0; - int ulrate = 0; - rsConfig->GetMaxDataRates(dlrate, ulrate); - ui.doubleSpinBoxDownloadSpeed->setValue(dlrate); - ui.doubleSpinBoxUploadSpeed->setValue(ulrate); + int ulrate = 0; + int dlratewi = 0; + int ulratewi = 0; + rsConfig->getMaxDataRates(dlrate, ulrate, dlratewi, ulratewi); + ui.doubleSpinBoxDownloadSpeed->setValue(dlrate); + ui.doubleSpinBoxUploadSpeed->setValue(ulrate); } @@ -575,7 +577,7 @@ void QuickStartWizard::saveChanges() rsPeers->setExtAddress(rsPeers->getOwnId(), ui.extAddress->text().toStdString(), ui.extPort->value()); }*/ - rsConfig->SetMaxDataRates( ui.doubleSpinBoxDownloadSpeed->value(), ui.doubleSpinBoxUploadSpeed->value() ); + rsConfig->setMaxDataRates( ui.doubleSpinBoxDownloadSpeed->value(), ui.doubleSpinBoxUploadSpeed->value(), ui.doubleSpinBoxDownloadSpeed->value(), ui.doubleSpinBoxUploadSpeed->value() ); loadNetwork(); } diff --git a/retroshare-gui/src/gui/settings/ServerPage.cpp b/retroshare-gui/src/gui/settings/ServerPage.cpp index adb1d655c..ab75404cb 100755 --- a/retroshare-gui/src/gui/settings/ServerPage.cpp +++ b/retroshare-gui/src/gui/settings/ServerPage.cpp @@ -231,6 +231,8 @@ ServerPage::ServerPage(QWidget * parent, Qt::WindowFlags flags) connect(ui.totalDownloadRate,SIGNAL(valueChanged(int)),this,SLOT(saveRates())); connect(ui.totalUploadRate, SIGNAL(valueChanged(int)),this,SLOT(saveRates())); + connect(ui.totalDownloadRateWhenIdle,SIGNAL(valueChanged(int)),this,SLOT(saveRates())); + connect(ui.totalUploadRateWhenIdle, SIGNAL(valueChanged(int)),this,SLOT(saveRates())); //Relay Tab QObject::connect(ui.noFriendSpinBox,SIGNAL(valueChanged(int)),this,SLOT(updateRelayOptions())); @@ -455,9 +457,13 @@ void ServerPage::load() int dlrate = 0; int ulrate = 0; - rsConfig->GetMaxDataRates(dlrate, ulrate); + int dlratewi = 0; + int ulratewi = 0; + rsConfig->getMaxDataRates(dlrate, ulrate, dlratewi, ulratewi); whileBlocking(ui.totalDownloadRate)->setValue(dlrate); whileBlocking(ui.totalUploadRate)->setValue(ulrate); + whileBlocking(ui.totalDownloadRateWhenIdle)->setValue(dlratewi); + whileBlocking(ui.totalUploadRateWhenIdle)->setValue(ulratewi); toggleUPnP(); @@ -1083,7 +1089,10 @@ void ServerPage::saveAddresses() void ServerPage::saveRates() { - rsConfig->SetMaxDataRates( ui.totalDownloadRate->value(), ui.totalUploadRate->value() ); + rsConfig->setMaxDataRates( ui.totalDownloadRate->value() + , ui.totalUploadRate->value() + , ui.totalDownloadRateWhenIdle->value() + , ui.totalUploadRateWhenIdle->value()); } void ServerPage::tabChanged(int page) @@ -1169,9 +1178,13 @@ void ServerPage::loadHiddenNode() // Download Rates - Stay the same as before. int dlrate = 0; int ulrate = 0; - rsConfig->GetMaxDataRates(dlrate, ulrate); + int dlratewi = 0; + int ulratewi = 0; + rsConfig->getMaxDataRates(dlrate, ulrate, dlratewi, ulratewi); whileBlocking(ui.totalDownloadRate)->setValue(dlrate); whileBlocking(ui.totalUploadRate)->setValue(ulrate); + whileBlocking(ui.totalDownloadRateWhenIdle)->setValue(dlratewi); + whileBlocking(ui.totalUploadRateWhenIdle)->setValue(ulratewi); // Addresses. ui.localAddress->setEnabled(false); @@ -1363,7 +1376,10 @@ void ServerPage::saveAddressesHiddenNode() rsPeers->setHiddenNode(ownId, hiddenAddr, hiddenPort); } - rsConfig->SetMaxDataRates( ui.totalDownloadRate->value(), ui.totalUploadRate->value() ); + rsConfig->setMaxDataRates( ui.totalDownloadRate->value() + , ui.totalUploadRate->value() + , ui.totalDownloadRateWhenIdle->value() + , ui.totalUploadRateWhenIdle->value() ); load(); } diff --git a/retroshare-gui/src/gui/settings/ServerPage.ui b/retroshare-gui/src/gui/settings/ServerPage.ui index 93eb82637..83fd99a44 100755 --- a/retroshare-gui/src/gui/settings/ServerPage.ui +++ b/retroshare-gui/src/gui/settings/ServerPage.ui @@ -90,7 +90,7 @@ - Download limit (KB/s) + Download limit when active (KB/s) @@ -103,7 +103,33 @@ - Upload limit (KB/s) + Upload limit when active (KB/s) + + + + + + + + 50 + false + + + + Download limit when idle (KB/s) + + + + + + + + 50 + false + + + + Upload limit when idle (KB/s) @@ -139,6 +165,31 @@ + + + + + 0 + 0 + + + + <html><head/><body><p>This download limit covers the whole application. However, in some situations, such as when transfering many small files at once, the estimated bandwidth becomes unreliable and the total value reported by Retroshare might exceed that limit. </p></body></html> + + + kB/s + + + 1 + + + 100000 + + + 1 + + + @@ -361,6 +412,34 @@ + + + + + 0 + 0 + + + + <html><head/><body><p>The upload limit covers the entire software. Too small an upload limit might eventually block low priority services (forums, channels). A minimum recommended value is 50KB/s. </p></body></html> + + + kB/s + + + + + + 1 + + + 100000 + + + 1 + + + @@ -451,7 +530,7 @@ - +