From bca295183b3a4e4a1e9ac90081c8ba8610c13c47 Mon Sep 17 00:00:00 2001 From: Daniel Molkentin Date: Wed, 24 Jul 2013 19:53:05 +0200 Subject: [PATCH] Make use of bandwidth limiting, split general/network settings. Fixes #14 --- mirall.qrc | 1 + resources/network.png | Bin 0 -> 1129 bytes src/CMakeLists.txt | 5 +- src/mirall/accountsettings.ui | 2 +- src/mirall/csyncthread.cpp | 18 ++ src/mirall/generalsettings.cpp | 82 +------ src/mirall/generalsettings.h | 2 - src/mirall/generalsettings.ui | 164 +------------ src/mirall/mirallconfigfile.cpp | 58 ++++- src/mirall/mirallconfigfile.h | 18 +- src/mirall/networksettings.cpp | 161 +++++++++++++ src/mirall/networksettings.h | 50 ++++ src/mirall/networksettings.ui | 399 ++++++++++++++++++++++++++++++++ src/mirall/settingsdialog.cpp | 12 +- src/mirall/settingsdialog.ui | 2 +- 15 files changed, 717 insertions(+), 257 deletions(-) create mode 100644 resources/network.png create mode 100644 src/mirall/networksettings.cpp create mode 100644 src/mirall/networksettings.h create mode 100644 src/mirall/networksettings.ui diff --git a/mirall.qrc b/mirall.qrc index 166f2d228..8fa43ed64 100644 --- a/mirall.qrc +++ b/mirall.qrc @@ -11,6 +11,7 @@ resources/view-refresh.png resources/warning-16.png resources/settings.png + resources/network.png resources/owncloud_logo_blue.png diff --git a/resources/network.png b/resources/network.png new file mode 100644 index 0000000000000000000000000000000000000000..9fe126e178cddb4aa611fca9e9ec8d253f683060 GIT binary patch literal 1129 zcmW-f2{7Du6vzLv(S)JXjMTK+q^fBdQ_GMT)gdAb8pn=ngIT2!V$ro2>yBMvMN(&7 zwXS8|_jX;o?t58xU8!^Jy4EdNgue96{Qv(q?|t9#`Tc*dF_tE>(hAZDg2Y2Z=-ifxEkVO-)U0 zZ7rng>grNbQo_Q*+S}X7WHO7zf|BUyXsAt0Ok}g!kZo;k9UB{?P$*trUZbO<{{H?D z$;iln^=4*fKmb{9Z*TBDJw0Ix9*>WVj0ExQ?5vxc+r-2KC@U)~v$C>aBG83~hQdVH z7Gy9KI#a3C*x1;FgoLD|q~zq}%*;#>(`dAuoE*Red^i?5onBB-Pzc5-VlWs*MMco9 zq@)DU%F4>%Y+*!IRaJF$HP8VUlgR{}hK7d5#>S?mrsn2mz~OK>uzXuv8}N2?baZxh zc6D`icX#*n^z`=j_VxAk_xBGB3~;&J!NI|yp&=fRH!?B;)WA4CJ`OCClao_ZQ`6Ja zKsPrx_YUmek2XI)zqq)#w6wImyu7lq!sqi>S62lBflw%1Ti;w?U*Fi+*xcOQ+S(F{ zMBCfjySuyl`}+q62Zx7;$H&JfCnu+;r(&`A?Ck9P{QTnLLQBHz4O}2xfVHI!A|ZkL zL|W#v&%ado`rh}-Xbr9VKkMn~85le=d~9rDj(Pg4>u)bSy$A%Ne*lRT5*AL5PRpdx z>5Phss_NQ0Cab=oX=Gt}RVZAC6+}C`docU(@aVnx!{wz}O~xXENQ9ahJ+cj&3m<)M z(}^IxL^j(U?hDwB&e4H(8b$Xy3MD6rnsg<{s;EXhXd&MvEr>Z6EuojXS0iX8eP#7; zxyJ9_CUaAFb5#XQQLXO$kx91dHv(((BI|HYi>lin3kv9;_&(B-7f%M>7^2y1ymtFP z$G%=pujchl3k|1k1#;KKE26nL(az4Dy;Dj`L3nHj;|AYbHVJdQt5SfG86Gaw*Q7F= zc!C{o;-}QJn`9k!5?iWe$X}jfp6ybO`p|7kyVHNqar#e6{LrwPsiKmOd_41+Q{SFW zUAz+W$yY3y5#_N@OH7r<@z5V=0Rcxq<;=}jZalgM%a7!R7-ZI)q(Nk;2*Q?y! zc71K{BE9{Tqm3b4$r(SaufbWGxC@1ZU-&Yt@BRw9o;pU?<6ZqQ^76suvk?7DNxA$> zZO7ZmS*dB_fS1ax92M@csnmoo{nYVq6Na_x7xFGxx~;6!wMaJB?lI27$3_!D>=%zD X18k_G09%|G{x@P~Y-v 0 0 - 639 + 607 385 diff --git a/src/mirall/csyncthread.cpp b/src/mirall/csyncthread.cpp index 990aed361..a8864a948 100644 --- a/src/mirall/csyncthread.cpp +++ b/src/mirall/csyncthread.cpp @@ -315,6 +315,24 @@ void CSyncThread::startSync() // cleans up behind us and emits finished() to ease error handling CSyncRunScopeHelper helper(_csync_ctx, this); + // maybe move this somewhere else where it can influence a running sync? + MirallConfigFile cfg; + + int downloadLimit = 0; + if (cfg.useDownloadLimit()) { + downloadLimit = cfg.downloadLimit(); + } + csync_set_module_property(_csync_ctx, "bandwidth_limit_download", &downloadLimit); + + int uploadLimit = -75; // 75% + int useDlLimit = cfg.useDownloadLimit(); + if ( useDlLimit > 1) { + uploadLimit = cfg.downloadLimit(); + } else if (useDlLimit == 0) { + uploadLimit = 0; + } + csync_set_module_property(_csync_ctx, "bandwidth_limit_upload", &uploadLimit); + csync_set_file_progress_callback( _csync_ctx, cb_file_progress ); csync_set_overall_progress_callback( _csync_ctx, cb_overall_progress ); diff --git a/src/mirall/generalsettings.cpp b/src/mirall/generalsettings.cpp index 85c1980b7..aedab297e 100644 --- a/src/mirall/generalsettings.cpp +++ b/src/mirall/generalsettings.cpp @@ -30,15 +30,6 @@ GeneralSettings::GeneralSettings(QWidget *parent) : { _ui->setupUi(this); - _ui->hostLineEdit->setPlaceholderText(tr("Hostname of proxy server")); - _ui->userLineEdit->setPlaceholderText(tr("Username for proxy server")); - _ui->passwordLineEdit->setPlaceholderText(tr("Password for proxy server")); - - _ui->typeComboBox->addItem(tr("HTTP(S) proxy"), QNetworkProxy::HttpProxy); - _ui->typeComboBox->addItem(tr("SOCKS5 proxy"), QNetworkProxy::Socks5Proxy); - - MirallConfigFile cfgFile; - _ui->desktopNotificationsCheckBox->setChecked(cfgFile.optionalDesktopNotifications()); connect(_ui->desktopNotificationsCheckBox, SIGNAL(toggled(bool)), SLOT(slotToggleOptionalDesktopNotifications(bool))); @@ -54,28 +45,10 @@ GeneralSettings::GeneralSettings(QWidget *parent) : _ui->aboutLabel->setOpenExternalLinks(true); } - _ui->authRequiredcheckBox->setEnabled(true); - - connect(_ui->manualProxyRadioButton, SIGNAL(toggled(bool)), - _ui->manualSettings, SLOT(setEnabled(bool))); - connect(_ui->manualProxyRadioButton, SIGNAL(toggled(bool)), - _ui->typeComboBox, SLOT(setEnabled(bool))); - connect(_ui->authRequiredcheckBox, SIGNAL(toggled(bool)), - _ui->authWidgets, SLOT(setEnabled(bool))); - - loadProxySettings(); loadMiscSettings(); // misc connect(_ui->monoIconsCheckBox, SIGNAL(toggled(bool)), SLOT(saveMiscSettings())); - - // proxy - connect(_ui->typeComboBox, SIGNAL(currentIndexChanged(int)), SLOT(saveProxySettings())); - connect(_ui->proxyButtonGroup, SIGNAL(buttonClicked(int)), SLOT(saveProxySettings())); - connect(_ui->hostLineEdit, SIGNAL(editingFinished()), SLOT(saveProxySettings())); - connect(_ui->userLineEdit, SIGNAL(editingFinished()), SLOT(saveProxySettings())); - connect(_ui->passwordLineEdit, SIGNAL(editingFinished()), SLOT(saveProxySettings())); - connect(_ui->portSpinBox, SIGNAL(editingFinished()), SLOT(saveProxySettings())); } GeneralSettings::~GeneralSettings() @@ -83,44 +56,11 @@ GeneralSettings::~GeneralSettings() delete _ui; } -void GeneralSettings::loadProxySettings() -{ - // load current proxy settings - Mirall::MirallConfigFile cfgFile; - int type = cfgFile.proxyType(); - switch (type) { - case QNetworkProxy::NoProxy: - _ui->noProxyRadioButton->setChecked(true); - break; - case QNetworkProxy::DefaultProxy: - _ui->systemProxyRadioButton->setChecked(true); - break; - case QNetworkProxy::Socks5Proxy: - case QNetworkProxy::HttpProxy: - _ui->typeComboBox->setCurrentIndex(_ui->typeComboBox->findData(type)); - _ui->manualProxyRadioButton->setChecked(true); - break; - default: - break; - } - - _ui->hostLineEdit->setText(cfgFile.proxyHostName()); - int port = cfgFile.proxyPort(); - if (port == 0) - port = 8080; - _ui->portSpinBox->setValue(port); - if (!cfgFile.proxyUser().isEmpty()) - { - _ui->authRequiredcheckBox->setChecked(true); - _ui->userLineEdit->setText(cfgFile.proxyUser()); - _ui->passwordLineEdit->setText(cfgFile.proxyPassword()); - } -} - void GeneralSettings::loadMiscSettings() { MirallConfigFile cfgFile; _ui->monoIconsCheckBox->setChecked(cfgFile.monoIcons()); + _ui->desktopNotificationsCheckBox->setChecked(cfgFile.optionalDesktopNotifications()); } void GeneralSettings::saveMiscSettings() @@ -143,24 +83,4 @@ void GeneralSettings::slotToggleOptionalDesktopNotifications(bool enable) cfgFile.setOptionalDesktopNotifications(enable); } -void GeneralSettings::saveProxySettings() -{ - MirallConfigFile cfgFile; - - if (_ui->noProxyRadioButton->isChecked()){ - cfgFile.setProxyType(QNetworkProxy::NoProxy); - } else if (_ui->systemProxyRadioButton->isChecked()){ - cfgFile.setProxyType(QNetworkProxy::DefaultProxy); - } else if (_ui->manualProxyRadioButton->isChecked()) { - int type = _ui->typeComboBox->itemData(_ui->typeComboBox->currentIndex()).toInt(); - bool needsAuth = _ui->authRequiredcheckBox->isChecked(); - QString user = _ui->userLineEdit->text(); - QString pass = _ui->passwordLineEdit->text(); - cfgFile.setProxyType(type, _ui->hostLineEdit->text(), - _ui->portSpinBox->value(), needsAuth, user, pass); - } - - emit proxySettingsChanged(); -} - } // namespace Mirall diff --git a/src/mirall/generalsettings.h b/src/mirall/generalsettings.h index a81c9d4c2..f0c9ca671 100644 --- a/src/mirall/generalsettings.h +++ b/src/mirall/generalsettings.h @@ -35,13 +35,11 @@ signals: void proxySettingsChanged(); private slots: - void saveProxySettings(); void saveMiscSettings(); void slotToggleLaunchOnStartup(bool); void slotToggleOptionalDesktopNotifications(bool); private: - void loadProxySettings(); void loadMiscSettings(); Ui::GeneralSettings *_ui; diff --git a/src/mirall/generalsettings.ui b/src/mirall/generalsettings.ui index 6a9851d3e..5c67c13dd 100644 --- a/src/mirall/generalsettings.ui +++ b/src/mirall/generalsettings.ui @@ -7,7 +7,7 @@ 0 0 468 - 408 + 169 @@ -44,168 +44,6 @@ - - - - true - - - Proxy Settings - - - - - - No Proxy - - - true - - - proxyButtonGroup - - - - - - - Use system proxy - - - proxyButtonGroup - - - - - - - Specify proxy manually as - - - proxyButtonGroup - - - - - - - false - - - - - - - false - - - - 0 - - - - - - - Host - - - - - - - - 0 - 0 - - - - - - - - - - - : - - - - - - - true - - - - 0 - 0 - - - - 1 - - - 65535 - - - 8080 - - - - - - - - - false - - - Proxy server requires authentication - - - - - - - false - - - - 0 - - - - - true - - - - - - - - - - true - - - - - - QLineEdit::Password - - - - - - - - - - - - diff --git a/src/mirall/mirallconfigfile.cpp b/src/mirall/mirallconfigfile.cpp index 687f194f2..21817c944 100644 --- a/src/mirall/mirallconfigfile.cpp +++ b/src/mirall/mirallconfigfile.cpp @@ -46,6 +46,11 @@ static const char proxyUserC[] = "Proxy/user"; static const char proxyPassC[] = "Proxy/pass"; static const char proxyNeedsAuthC[] = "Proxy/needsAuth"; +static const char useUploadLimitC[] = "BWLimit/useUploadLimit"; +static const char useDownloadLimitC[] = "BWLimit/useDownloadLimit"; +static const char uploadLimitC[] = "BWLimit/uploadLimit"; +static const char downloadLimitC[] = "BWLimit/downloadLimit"; + static const char seenVersionC[] = "Updater/seenVersion"; static const char maxLogLinesC[] = "Logging/maxLogLines"; @@ -556,14 +561,23 @@ void MirallConfigFile::setProxyType(int proxyType, settings.sync(); } -QVariant MirallConfigFile::getValue(const QString& param, const QString& group) const +QVariant MirallConfigFile::getValue(const QString& param, const QString& group, + const QVariant& defaultValue) const { QSettings settings( configFile(), QSettings::IniFormat ); settings.setIniCodec( "UTF-8" ); if (!group.isEmpty()) settings.beginGroup(group); - return settings.value(param); + return settings.value(param, defaultValue); +} + +void MirallConfigFile::setValue(const QString& key, const QVariant &value) +{ + QSettings settings( configFile(), QSettings::IniFormat ); + settings.setIniCodec( "UTF-8" ); + + settings.setValue(key, value); } int MirallConfigFile::proxyType() const @@ -597,6 +611,46 @@ QString MirallConfigFile::proxyPassword() const return QString::fromUtf8(QByteArray::fromBase64(pass)); } +int MirallConfigFile::useUploadLimit() const +{ + return getValue(useUploadLimitC, QString::null, -1).toInt(); +} + +bool MirallConfigFile::useDownloadLimit() const +{ + return getValue(useDownloadLimitC, QString::null, false).toBool(); +} + +void MirallConfigFile::setUseUploadLimit(int val) +{ + setValue(useUploadLimitC, val); +} + +void MirallConfigFile::setUseDownloadLimit(bool enable) +{ + setValue(useDownloadLimitC, enable); +} + +int MirallConfigFile::uploadLimit() const +{ + return getValue(uploadLimitC, QString::null, 10).toInt(); +} + +int MirallConfigFile::downloadLimit() const +{ + return getValue(downloadLimitC, QString::null, 80).toInt(); +} + +void MirallConfigFile::setUploadLimit(int kbytes) +{ + setValue(uploadLimitC, kbytes); +} + +void MirallConfigFile::setDownloadLimit(int kbytes) +{ + setValue(downloadLimitC, kbytes); +} + bool MirallConfigFile::monoIcons() const { QSettings settings( configFile(), QSettings::IniFormat ); diff --git a/src/mirall/mirallconfigfile.h b/src/mirall/mirallconfigfile.h index 7965affbb..e2707fd3d 100644 --- a/src/mirall/mirallconfigfile.h +++ b/src/mirall/mirallconfigfile.h @@ -16,8 +16,8 @@ #define MIRALLCONFIGFILE_H #include +#include -class QVariant; class QWidget; namespace Mirall { @@ -95,6 +95,16 @@ public: QString proxyUser() const; QString proxyPassword() const; + /** 0: no limit, 1: manual, >0: automatic */ + int useUploadLimit() const; + bool useDownloadLimit() const; + void setUseUploadLimit(int); + void setUseDownloadLimit(bool); + int uploadLimit() const; + int downloadLimit() const; + void setUploadLimit(int kbytes); + void setDownloadLimit(int kbytes); + static void setConfDir(const QString &value); bool optionalDesktopNotifications() const; @@ -114,15 +124,15 @@ protected: bool writePassword( const QString& passwd, const QString& connection = QString() ); private: - QVariant getValue(const QString& param, const QString& group = QString::null) const; - + QVariant getValue(const QString& param, const QString& group = QString::null, + const QVariant& defaultValue = QVariant()) const; + void setValue(const QString& key, const QVariant &value); private: static bool _askedUser; static QString _oCVersion; static QString _confDir; QString _customHandle; - }; } diff --git a/src/mirall/networksettings.cpp b/src/mirall/networksettings.cpp new file mode 100644 index 000000000..2d184999c --- /dev/null +++ b/src/mirall/networksettings.cpp @@ -0,0 +1,161 @@ +/* + * Copyright (C) by Daniel Molkentin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#include "networksettings.h" +#include "ui_networksettings.h" + +#include "mirall/theme.h" +#include "mirall/mirallconfigfile.h" +#include "mirall/application.h" +#include "mirall/utility.h" +#include "mirall/mirallconfigfile.h" + +#include + +namespace Mirall { + +NetworkSettings::NetworkSettings(QWidget *parent) : + QWidget(parent), + _ui(new Ui::NetworkSettings) +{ + _ui->setupUi(this); + + _ui->hostLineEdit->setPlaceholderText(tr("Hostname of proxy server")); + _ui->userLineEdit->setPlaceholderText(tr("Username for proxy server")); + _ui->passwordLineEdit->setPlaceholderText(tr("Password for proxy server")); + + _ui->typeComboBox->addItem(tr("HTTP(S) proxy"), QNetworkProxy::HttpProxy); + _ui->typeComboBox->addItem(tr("SOCKS5 proxy"), QNetworkProxy::Socks5Proxy); + + _ui->authRequiredcheckBox->setEnabled(true); + + connect(_ui->manualProxyRadioButton, SIGNAL(toggled(bool)), + _ui->manualSettings, SLOT(setEnabled(bool))); + connect(_ui->manualProxyRadioButton, SIGNAL(toggled(bool)), + _ui->typeComboBox, SLOT(setEnabled(bool))); + connect(_ui->authRequiredcheckBox, SIGNAL(toggled(bool)), + _ui->authWidgets, SLOT(setEnabled(bool))); + + loadProxySettings(); + loadBWLimitSettings(); + + // proxy + connect(_ui->typeComboBox, SIGNAL(currentIndexChanged(int)), SLOT(saveProxySettings())); + connect(_ui->proxyButtonGroup, SIGNAL(buttonClicked(int)), SLOT(saveProxySettings())); + connect(_ui->hostLineEdit, SIGNAL(editingFinished()), SLOT(saveProxySettings())); + connect(_ui->userLineEdit, SIGNAL(editingFinished()), SLOT(saveProxySettings())); + connect(_ui->passwordLineEdit, SIGNAL(editingFinished()), SLOT(saveProxySettings())); + connect(_ui->portSpinBox, SIGNAL(editingFinished()), SLOT(saveProxySettings())); + + connect(_ui->uploadLimitRadioButton, SIGNAL(clicked()), SLOT(saveBWLimitSettings())); + connect(_ui->noUploadLimitRadioButton, SIGNAL(clicked()), SLOT(saveBWLimitSettings())); + connect(_ui->autoUploadLimitRadioButton, SIGNAL(clicked()), SLOT(saveBWLimitSettings())); + connect(_ui->downloadLimitRadioButton, SIGNAL(clicked()), SLOT(saveBWLimitSettings())); + connect(_ui->noDownloadLimitRadioButton, SIGNAL(clicked()), SLOT(saveBWLimitSettings())); + connect(_ui->downloadSpinBox, SIGNAL(valueChanged(int)), SLOT(saveBWLimitSettings())); + connect(_ui->uploadSpinBox, SIGNAL(valueChanged(int)), SLOT(saveBWLimitSettings())); +} + +NetworkSettings::~NetworkSettings() +{ + delete _ui; +} + +void NetworkSettings::loadProxySettings() +{ + // load current proxy settings + Mirall::MirallConfigFile cfgFile; + int type = cfgFile.proxyType(); + switch (type) { + case QNetworkProxy::NoProxy: + _ui->noProxyRadioButton->setChecked(true); + break; + case QNetworkProxy::DefaultProxy: + _ui->systemProxyRadioButton->setChecked(true); + break; + case QNetworkProxy::Socks5Proxy: + case QNetworkProxy::HttpProxy: + _ui->typeComboBox->setCurrentIndex(_ui->typeComboBox->findData(type)); + _ui->manualProxyRadioButton->setChecked(true); + break; + default: + break; + } + + _ui->hostLineEdit->setText(cfgFile.proxyHostName()); + int port = cfgFile.proxyPort(); + if (port == 0) + port = 8080; + _ui->portSpinBox->setValue(port); + if (!cfgFile.proxyUser().isEmpty()) + { + _ui->authRequiredcheckBox->setChecked(true); + _ui->userLineEdit->setText(cfgFile.proxyUser()); + _ui->passwordLineEdit->setText(cfgFile.proxyPassword()); + } +} + +void NetworkSettings::loadBWLimitSettings() +{ + MirallConfigFile cfgFile; + _ui->downloadLimitRadioButton->setChecked(cfgFile.useDownloadLimit()); + int uploadLimit = cfgFile.useUploadLimit(); + if ( uploadLimit >= 1 ) { + _ui->downloadLimitRadioButton->setChecked(true); + } else if (uploadLimit == 0){ + _ui->noDownloadLimitRadioButton->setChecked(true); + } else { + _ui->autoUploadLimitRadioButton->setChecked(true); + } + _ui->downloadSpinBox->setValue(cfgFile.downloadLimit()); + _ui->uploadSpinBox->setValue(cfgFile.uploadLimit()); +} + +void NetworkSettings::saveProxySettings() +{ + MirallConfigFile cfgFile; + + if (_ui->noProxyRadioButton->isChecked()){ + cfgFile.setProxyType(QNetworkProxy::NoProxy); + } else if (_ui->systemProxyRadioButton->isChecked()){ + cfgFile.setProxyType(QNetworkProxy::DefaultProxy); + } else if (_ui->manualProxyRadioButton->isChecked()) { + int type = _ui->typeComboBox->itemData(_ui->typeComboBox->currentIndex()).toInt(); + bool needsAuth = _ui->authRequiredcheckBox->isChecked(); + QString user = _ui->userLineEdit->text(); + QString pass = _ui->passwordLineEdit->text(); + cfgFile.setProxyType(type, _ui->hostLineEdit->text(), + _ui->portSpinBox->value(), needsAuth, user, pass); + } + + emit proxySettingsChanged(); +} + +void NetworkSettings::saveBWLimitSettings() +{ + MirallConfigFile cfgFile; + cfgFile.setUseDownloadLimit(_ui->downloadLimitRadioButton->isChecked()); + + if (_ui->uploadLimitRadioButton->isChecked()) { + cfgFile.setUseUploadLimit(1); + } else if (_ui->noUploadLimitRadioButton->isChecked()) { + cfgFile.setUseUploadLimit(0); + } else if (_ui->autoUploadLimitRadioButton->isChecked()) { + cfgFile.setUseUploadLimit(-1); + } + + cfgFile.setDownloadLimit(_ui->downloadSpinBox->value()); + cfgFile.setUploadLimit(_ui->uploadSpinBox->value()); +} + +} // namespace Mirall diff --git a/src/mirall/networksettings.h b/src/mirall/networksettings.h new file mode 100644 index 000000000..9788ba554 --- /dev/null +++ b/src/mirall/networksettings.h @@ -0,0 +1,50 @@ +/* + * Copyright (C) by Daniel Molkentin + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * for more details. + */ + +#ifndef MIRALL_NETWORKSETTINGS_H +#define MIRALL_NETWORKSETTINGS_H + +#include + + +namespace Mirall { + +namespace Ui { +class NetworkSettings; +} + +class NetworkSettings : public QWidget +{ + Q_OBJECT + +public: + explicit NetworkSettings(QWidget *parent = 0); + ~NetworkSettings(); + +signals: + void proxySettingsChanged(); + +private slots: + void saveProxySettings(); + void saveBWLimitSettings(); + +private: + void loadProxySettings(); + void loadBWLimitSettings(); + + Ui::NetworkSettings *_ui; +}; + + +} // namespace Mirall +#endif // MIRALL_NETWORKSETTINGS_H diff --git a/src/mirall/networksettings.ui b/src/mirall/networksettings.ui new file mode 100644 index 000000000..0c5fb8ce4 --- /dev/null +++ b/src/mirall/networksettings.ui @@ -0,0 +1,399 @@ + + + Mirall::NetworkSettings + + + + 0 + 0 + 558 + 390 + + + + Form + + + + + + true + + + Proxy Settings + + + + + + No Proxy + + + true + + + proxyButtonGroup + + + + + + + Use system proxy + + + proxyButtonGroup + + + + + + + Specify proxy manually as + + + proxyButtonGroup + + + + + + + false + + + + + + + false + + + + 0 + + + + + + + Host + + + + + + + + 0 + 0 + + + + + + + + + + + : + + + + + + + false + + + + 0 + 0 + + + + 1 + + + 65535 + + + 8080 + + + + + + + + + false + + + Proxy server requires authentication + + + + + + + false + + + + 0 + + + + + false + + + + + + + + + + false + + + + + + QLineEdit::Password + + + + + + + + + + + + + + + + Download Bandwidth + + + + + + Limit to + + + + + + + + + false + + + 9999 + + + 80 + + + + + + + KBytes/s + + + + + + + + + Qt::Vertical + + + + 147 + 25 + + + + + + + + Do not Limit + + + true + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + + + + Upload Bandwidth + + + + + + Do Not Limit + + + + + + + Automatically Limit + + + true + + + + + + + Limit to + + + + + + + + + false + + + 1 + + + 9999 + + + 10 + + + + + + + KBytes/s + + + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Qt::Vertical + + + + 147 + 6 + + + + + + autoUploadLimitRadioButton + uploadLimitRadioButton + verticalSpacer_3 + horizontalSpacer_2 + noUploadLimitRadioButton + + + + + + Qt::Vertical + + + + 20 + 0 + + + + + + + + + + downloadLimitRadioButton + toggled(bool) + downloadSpinBox + setEnabled(bool) + + + 73 + 69 + + + 131 + 78 + + + + + uploadLimitRadioButton + toggled(bool) + uploadSpinBox + setEnabled(bool) + + + 322 + 101 + + + 411 + 106 + + + + + + + + diff --git a/src/mirall/settingsdialog.cpp b/src/mirall/settingsdialog.cpp index e588b265f..d27ea6f1b 100644 --- a/src/mirall/settingsdialog.cpp +++ b/src/mirall/settingsdialog.cpp @@ -17,6 +17,7 @@ #include "mirall/folderman.h" #include "mirall/theme.h" #include "mirall/generalsettings.h" +#include "mirall/networksettings.h" #include "mirall/accountsettings.h" #include "mirall/application.h" #include "mirall/mirallconfigfile.h" @@ -52,10 +53,17 @@ SettingsDialog::SettingsDialog(Application *app, QWidget *parent) : general->setSizeHint(QSize(0, 32)); _ui->labelWidget->addItem(general); GeneralSettings *generalSettings = new GeneralSettings; - connect(generalSettings, SIGNAL(proxySettingsChanged()), app, SLOT(slotSetupProxy())); - connect(generalSettings, SIGNAL(proxySettingsChanged()), FolderMan::instance(), SLOT(slotScheduleAllFolders())); _ui->stack->addWidget(generalSettings); + QIcon networkIcon(QLatin1String(":/mirall/resources/network.png")); + QListWidgetItem *network = new QListWidgetItem(networkIcon, tr("Network"), _ui->labelWidget); + network->setSizeHint(QSize(0, 32)); + _ui->labelWidget->addItem(network); + NetworkSettings *networkSettings = new NetworkSettings; + _ui->stack->addWidget(networkSettings); + connect(networkSettings, SIGNAL(proxySettingsChanged()), app, SLOT(slotSetupProxy())); + connect(networkSettings, SIGNAL(proxySettingsChanged()), FolderMan::instance(), SLOT(slotScheduleAllFolders())); + //connect(generalSettings, SIGNAL(resizeToSizeHint()), SLOT(resizeToSizeHint())); _accountSettings = new AccountSettings(this); diff --git a/src/mirall/settingsdialog.ui b/src/mirall/settingsdialog.ui index fbbbce77b..6fdf6e422 100644 --- a/src/mirall/settingsdialog.ui +++ b/src/mirall/settingsdialog.ui @@ -7,7 +7,7 @@ 0 0 704 - 515 + 299