Browse Source

Fix speedlimitdlg position

adaptive-webui-19844
Chocobo1 9 years ago
parent
commit
a902eb6b2b
  1. 9
      src/gui/bandwidth_limit.ui
  2. 8
      src/gui/mainwindow.cpp
  3. 6
      src/gui/speedlimitdlg.cpp
  4. 4
      src/gui/speedlimitdlg.h
  5. 6
      src/gui/statusbar.cpp
  6. 4
      src/gui/transferlistwidget.cpp

9
src/gui/bandwidth_limit.ui

@ -10,9 +10,6 @@ @@ -10,9 +10,6 @@
<height>83</height>
</rect>
</property>
<property name="windowTitle">
<string notr="true">Bandwidth allocation</string>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
@ -25,9 +22,6 @@ @@ -25,9 +22,6 @@
</item>
<item>
<widget class="QSpinBox" name="spinBandwidth">
<property name="suffix">
<string/>
</property>
<property name="maximum">
<number>65535</number>
</property>
@ -40,9 +34,6 @@ @@ -40,9 +34,6 @@
</item>
<item>
<widget class="QDialogButtonBox" name="buttonBox">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="standardButtons">
<set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
</property>

8
src/gui/mainwindow.cpp

@ -862,10 +862,12 @@ void MainWindow::handleDownloadFromUrlFailure(QString url, QString reason) const @@ -862,10 +862,12 @@ void MainWindow::handleDownloadFromUrlFailure(QString url, QString reason) const
void MainWindow::on_actionSetGlobalUploadLimit_triggered()
{
qDebug() << Q_FUNC_INFO;
BitTorrent::Session *const session = BitTorrent::Session::instance();
bool ok = false;
const long newLimit = SpeedLimitDialog::askSpeedLimit(
&ok, tr("Global Upload Speed Limit"), session->uploadSpeedLimit());
this, &ok, tr("Global Upload Speed Limit"), session->uploadSpeedLimit());
if (ok) {
qDebug("Setting global upload rate limit to %.1fKb/s", newLimit / 1024.);
session->setUploadSpeedLimit(newLimit);
@ -875,10 +877,12 @@ void MainWindow::on_actionSetGlobalUploadLimit_triggered() @@ -875,10 +877,12 @@ void MainWindow::on_actionSetGlobalUploadLimit_triggered()
void MainWindow::on_actionSetGlobalDownloadLimit_triggered()
{
qDebug() << Q_FUNC_INFO;
BitTorrent::Session *const session = BitTorrent::Session::instance();
bool ok = false;
const long newLimit = SpeedLimitDialog::askSpeedLimit(
&ok, tr("Global Download Speed Limit"), session->downloadSpeedLimit());
this, &ok, tr("Global Download Speed Limit"), session->downloadSpeedLimit());
if (ok) {
qDebug("Setting global download rate limit to %.1fKb/s", newLimit / 1024.);
session->setDownloadSpeedLimit(newLimit);

6
src/gui/speedlimitdlg.cpp

@ -39,10 +39,10 @@ SpeedLimitDialog::SpeedLimitDialog(QWidget *parent) @@ -39,10 +39,10 @@ SpeedLimitDialog::SpeedLimitDialog(QWidget *parent)
{
m_ui->setupUi(this);
qDebug("Bandwidth allocation dialog creation");
// Connect to slots
connect(m_ui->bandwidthSlider, SIGNAL(valueChanged(int)), this, SLOT(updateSpinValue(int)));
connect(m_ui->spinBandwidth, SIGNAL(valueChanged(int)), this, SLOT(updateSliderValue(int)));
move(Utils::Misc::screenCenter(this));
}
SpeedLimitDialog::~SpeedLimitDialog()
@ -52,9 +52,9 @@ SpeedLimitDialog::~SpeedLimitDialog() @@ -52,9 +52,9 @@ SpeedLimitDialog::~SpeedLimitDialog()
}
// -2: if cancel
long SpeedLimitDialog::askSpeedLimit(bool *ok, QString title, long default_value, long max_value)
long SpeedLimitDialog::askSpeedLimit(QWidget *parent, bool *ok, QString title, long default_value, long max_value)
{
SpeedLimitDialog dlg;
SpeedLimitDialog dlg(parent);
dlg.setWindowTitle(title);
dlg.setupDialog(max_value / 1024., default_value / 1024.);
if (dlg.exec() == QDialog::Accepted) {

4
src/gui/speedlimitdlg.h

@ -44,9 +44,9 @@ namespace Ui @@ -44,9 +44,9 @@ namespace Ui
class SpeedLimitDialog : public QDialog {
Q_OBJECT
public:
explicit SpeedLimitDialog(QWidget *parent=0);
explicit SpeedLimitDialog(QWidget *parent);
~SpeedLimitDialog();
static long askSpeedLimit(bool *ok, QString title, long default_value, long max_value=10240000);
static long askSpeedLimit(QWidget *parent, bool *ok, QString title, long default_value, long max_value=10240000);
protected slots:
void updateSpinValue(int val) const;

6
src/gui/statusbar.cpp

@ -252,9 +252,10 @@ void StatusBar::toggleAlternativeSpeeds() @@ -252,9 +252,10 @@ void StatusBar::toggleAlternativeSpeeds()
void StatusBar::capDownloadSpeed()
{
BitTorrent::Session *const session = BitTorrent::Session::instance();
bool ok = false;
const long newLimit = SpeedLimitDialog::askSpeedLimit(
&ok, tr("Global Download Speed Limit"), session->downloadSpeedLimit());
m_bar->parentWidget(), &ok, tr("Global Download Speed Limit"), session->downloadSpeedLimit());
if (ok) {
qDebug("Setting global download rate limit to %.1fKb/s", newLimit / 1024.);
session->setDownloadSpeedLimit(newLimit);
@ -265,9 +266,10 @@ void StatusBar::capDownloadSpeed() @@ -265,9 +266,10 @@ void StatusBar::capDownloadSpeed()
void StatusBar::capUploadSpeed()
{
BitTorrent::Session *const session = BitTorrent::Session::instance();
bool ok = false;
const long newLimit = SpeedLimitDialog::askSpeedLimit(
&ok, tr("Global Upload Speed Limit"), session->uploadSpeedLimit());
m_bar->parentWidget(), &ok, tr("Global Upload Speed Limit"), session->uploadSpeedLimit());
if (ok) {
qDebug("Setting global upload rate limit to %.1fKb/s", newLimit / 1024.);
session->setUploadSpeedLimit(newLimit);

4
src/gui/transferlistwidget.cpp

@ -445,7 +445,7 @@ void TransferListWidget::setDlLimitSelectedTorrents() @@ -445,7 +445,7 @@ void TransferListWidget::setDlLimitSelectedTorrents()
bool ok = false;
const long newLimit = SpeedLimitDialog::askSpeedLimit(
&ok, tr("Torrent Download Speed Limiting"), oldLimit
this, &ok, tr("Torrent Download Speed Limiting"), oldLimit
, BitTorrent::Session::instance()->globalDownloadSpeedLimit());
if (!ok) return;
@ -470,7 +470,7 @@ void TransferListWidget::setUpLimitSelectedTorrents() @@ -470,7 +470,7 @@ void TransferListWidget::setUpLimitSelectedTorrents()
bool ok = false;
const long newLimit = SpeedLimitDialog::askSpeedLimit(
&ok, tr("Torrent Upload Speed Limiting"), oldLimit
this, &ok, tr("Torrent Upload Speed Limiting"), oldLimit
, BitTorrent::Session::instance()->globalUploadSpeedLimit());
if (!ok) return;

Loading…
Cancel
Save