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

8
src/gui/mainwindow.cpp

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

6
src/gui/speedlimitdlg.cpp

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

4
src/gui/speedlimitdlg.h

@ -44,9 +44,9 @@ namespace Ui
class SpeedLimitDialog : public QDialog { class SpeedLimitDialog : public QDialog {
Q_OBJECT Q_OBJECT
public: public:
explicit SpeedLimitDialog(QWidget *parent=0); explicit SpeedLimitDialog(QWidget *parent);
~SpeedLimitDialog(); ~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: protected slots:
void updateSpinValue(int val) const; void updateSpinValue(int val) const;

6
src/gui/statusbar.cpp

@ -252,9 +252,10 @@ void StatusBar::toggleAlternativeSpeeds()
void StatusBar::capDownloadSpeed() void StatusBar::capDownloadSpeed()
{ {
BitTorrent::Session *const session = BitTorrent::Session::instance(); BitTorrent::Session *const session = BitTorrent::Session::instance();
bool ok = false; bool ok = false;
const long newLimit = SpeedLimitDialog::askSpeedLimit( 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) { if (ok) {
qDebug("Setting global download rate limit to %.1fKb/s", newLimit / 1024.); qDebug("Setting global download rate limit to %.1fKb/s", newLimit / 1024.);
session->setDownloadSpeedLimit(newLimit); session->setDownloadSpeedLimit(newLimit);
@ -265,9 +266,10 @@ void StatusBar::capDownloadSpeed()
void StatusBar::capUploadSpeed() void StatusBar::capUploadSpeed()
{ {
BitTorrent::Session *const session = BitTorrent::Session::instance(); BitTorrent::Session *const session = BitTorrent::Session::instance();
bool ok = false; bool ok = false;
const long newLimit = SpeedLimitDialog::askSpeedLimit( 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) { if (ok) {
qDebug("Setting global upload rate limit to %.1fKb/s", newLimit / 1024.); qDebug("Setting global upload rate limit to %.1fKb/s", newLimit / 1024.);
session->setUploadSpeedLimit(newLimit); session->setUploadSpeedLimit(newLimit);

4
src/gui/transferlistwidget.cpp

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

Loading…
Cancel
Save