From dd7143611a8ae7753d3621ac0b41891db6ae00fc Mon Sep 17 00:00:00 2001 From: Claudio Cambra Date: Fri, 28 Jun 2024 17:59:24 +0800 Subject: [PATCH] Add account member to network settings Signed-off-by: Claudio Cambra --- src/gui/accountsettings.cpp | 2 +- src/gui/networksettings.cpp | 23 ++-- src/gui/networksettings.h | 4 +- src/gui/networksettings.ui | 213 ++++++++++++++++++++---------------- 4 files changed, 138 insertions(+), 104 deletions(-) diff --git a/src/gui/accountsettings.cpp b/src/gui/accountsettings.cpp index d51601392..bebc5fa7c 100644 --- a/src/gui/accountsettings.cpp +++ b/src/gui/accountsettings.cpp @@ -214,7 +214,7 @@ AccountSettings::AccountSettings(AccountState *accountState, QWidget *parent) const auto connectionSettingsTab = _ui->connectionSettingsTab; const auto connectionSettingsLayout = new QVBoxLayout(connectionSettingsTab); - const auto networkSettings = new NetworkSettings(connectionSettingsTab); + const auto networkSettings = new NetworkSettings(_accountState->account().get(), connectionSettingsTab); connectionSettingsLayout->addWidget(networkSettings); connectionSettingsTab->setLayout(connectionSettingsLayout); diff --git a/src/gui/networksettings.cpp b/src/gui/networksettings.cpp index 66ddbbaa5..dd1be9af4 100644 --- a/src/gui/networksettings.cpp +++ b/src/gui/networksettings.cpp @@ -15,12 +15,12 @@ #include "networksettings.h" #include "ui_networksettings.h" -#include "theme.h" -#include "configfile.h" +#include "account.h" +#include "accountmanager.h" #include "application.h" #include "configfile.h" #include "folderman.h" -#include "accountmanager.h" +#include "theme.h" #include #include @@ -28,9 +28,10 @@ namespace OCC { -NetworkSettings::NetworkSettings(QWidget *parent) +NetworkSettings::NetworkSettings(Account *const account, QWidget *parent) : QWidget(parent) , _ui(new Ui::NetworkSettings) + , _account(account) { _ui->setupUi(this); @@ -38,6 +39,12 @@ NetworkSettings::NetworkSettings(QWidget *parent) _ui->proxyGroupBox->setVisible(!Theme::instance()->doNotUseProxy()); + if (account == nullptr) { + _ui->globalProxySettingsRadioButton->setVisible(false); + _ui->globalDownloadSettingsRadioButton->setVisible(false); + _ui->globalUploadSettingsRadioButton->setVisible(false); + } + if (!Theme::instance()->doNotUseProxy()) { _ui->hostLineEdit->setPlaceholderText(tr("Hostname of proxy server")); _ui->userLineEdit->setPlaceholderText(tr("Username for proxy server")); @@ -60,10 +67,8 @@ NetworkSettings::NetworkSettings(QWidget *parent) loadProxySettings(); - connect(_ui->typeComboBox, static_cast(&QComboBox::currentIndexChanged), this, - &NetworkSettings::saveProxySettings); - connect(_ui->proxyButtonGroup, &QButtonGroup::buttonClicked, this, - &NetworkSettings::saveProxySettings); + connect(_ui->typeComboBox, static_cast(&QComboBox::currentIndexChanged), this, &NetworkSettings::saveProxySettings); + connect(_ui->proxyButtonGroup, &QButtonGroup::buttonClicked, this, &NetworkSettings::saveProxySettings); connect(_ui->hostLineEdit, &QLineEdit::editingFinished, this, &NetworkSettings::saveProxySettings); connect(_ui->userLineEdit, &QLineEdit::editingFinished, this, &NetworkSettings::saveProxySettings); connect(_ui->passwordLineEdit, &QLineEdit::editingFinished, this, &NetworkSettings::saveProxySettings); @@ -85,9 +90,11 @@ NetworkSettings::NetworkSettings(QWidget *parent) _ui->uploadSpinBox->setVisible(_ui->uploadLimitRadioButton->isChecked()); _ui->uploadSpinBoxLabel->setVisible(_ui->uploadLimitRadioButton->isChecked()); + connect(_ui->globalUploadSettingsRadioButton, &QAbstractButton::clicked, this, &NetworkSettings::saveBWLimitSettings); connect(_ui->uploadLimitRadioButton, &QAbstractButton::clicked, this, &NetworkSettings::saveBWLimitSettings); connect(_ui->noUploadLimitRadioButton, &QAbstractButton::clicked, this, &NetworkSettings::saveBWLimitSettings); connect(_ui->autoUploadLimitRadioButton, &QAbstractButton::clicked, this, &NetworkSettings::saveBWLimitSettings); + connect(_ui->globalDownloadSettingsRadioButton, &QAbstractButton::clicked, this, &NetworkSettings::saveBWLimitSettings); connect(_ui->downloadLimitRadioButton, &QAbstractButton::clicked, this, &NetworkSettings::saveBWLimitSettings); connect(_ui->noDownloadLimitRadioButton, &QAbstractButton::clicked, this, &NetworkSettings::saveBWLimitSettings); connect(_ui->autoDownloadLimitRadioButton, &QAbstractButton::clicked, this, &NetworkSettings::saveBWLimitSettings); diff --git a/src/gui/networksettings.h b/src/gui/networksettings.h index 8e3a97c44..9ebfa3f51 100644 --- a/src/gui/networksettings.h +++ b/src/gui/networksettings.h @@ -19,6 +19,7 @@ namespace OCC { +class Account; namespace Ui { class NetworkSettings; @@ -33,7 +34,7 @@ class NetworkSettings : public QWidget Q_OBJECT public: - explicit NetworkSettings(QWidget *parent = nullptr); + explicit NetworkSettings(Account *const account = nullptr, QWidget *parent = nullptr); ~NetworkSettings() override; [[nodiscard]] QSize sizeHint() const override; @@ -54,6 +55,7 @@ private: void loadBWLimitSettings(); Ui::NetworkSettings *_ui; + Account *_account; }; diff --git a/src/gui/networksettings.ui b/src/gui/networksettings.ui index 3974a1f82..db6db42be 100644 --- a/src/gui/networksettings.ui +++ b/src/gui/networksettings.ui @@ -42,20 +42,7 @@ Proxy Settings - - - - No proxy - - - true - - - proxyButtonGroup - - - - + Use system proxy @@ -65,30 +52,7 @@ - - - - Qt::Horizontal - - - - 40 - 20 - - - - - - - - Manually specify proxy - - - proxyButtonGroup - - - - + @@ -276,6 +240,52 @@ + + + + Manually specify proxy + + + proxyButtonGroup + + + + + + + No proxy + + + true + + + proxyButtonGroup + + + + + + + Qt::Horizontal + + + + 40 + 20 + + + + + + + + Use global settings + + + proxyButtonGroup + + + @@ -311,7 +321,7 @@ 6 - + No limit @@ -321,24 +331,7 @@ - - - - Limit to 3/4 of estimated bandwidth - - - Limit automatically - - - - - - - Limit to - - - - + @@ -368,7 +361,7 @@ - + Qt::Vertical @@ -381,6 +374,30 @@ + + + + Limit to + + + + + + + Limit to 3/4 of estimated bandwidth + + + Limit automatically + + + + + + + Use global settings + + + @@ -411,7 +428,47 @@ 6 + + + + Limit to 3/4 of estimated bandwidth + + + Limit automatically + + + + + + + Qt::Vertical + + + + 20 + 40 + + + + + + + Limit to + + + + + + + No limit + + + true + + + + @@ -444,51 +501,19 @@ - - - - Limit to 3/4 of estimated bandwidth - + + - Limit automatically + Use global settings - - - - Limit to - - - - - - - No limit - - - true - - - - - - - Qt::Vertical - - - - 20 - 40 - - - - autoUploadLimitRadioButton uploadLimitRadioButton noUploadLimitRadioButton verticalSpacer_3 + globalUploadSettingsRadioButton