Add account member to network settings

Signed-off-by: Claudio Cambra <claudio.cambra@nextcloud.com>
This commit is contained in:
Claudio Cambra 2024-06-28 17:59:24 +08:00
parent 03946a8678
commit dd7143611a
No known key found for this signature in database
GPG key ID: C839200C384636B0
4 changed files with 138 additions and 104 deletions

View file

@ -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);

View file

@ -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 <QNetworkProxy>
#include <QString>
@ -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<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged), this,
&NetworkSettings::saveProxySettings);
connect(_ui->proxyButtonGroup, &QButtonGroup::buttonClicked, this,
&NetworkSettings::saveProxySettings);
connect(_ui->typeComboBox, static_cast<void (QComboBox::*)(int)>(&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);

View file

@ -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;
};

View file

@ -42,20 +42,7 @@
<string>Proxy Settings</string>
</property>
<layout class="QGridLayout" name="gridLayout">
<item row="0" column="0">
<widget class="QRadioButton" name="noProxyRadioButton">
<property name="text">
<string>No proxy</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">proxyButtonGroup</string>
</attribute>
</widget>
</item>
<item row="1" column="0">
<item row="2" column="0">
<widget class="QRadioButton" name="systemProxyRadioButton">
<property name="text">
<string>Use system proxy</string>
@ -65,30 +52,7 @@
</attribute>
</widget>
</item>
<item row="2" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="manualProxyRadioButton">
<property name="text">
<string>Manually specify proxy</string>
</property>
<attribute name="buttonGroup">
<string notr="true">proxyButtonGroup</string>
</attribute>
</widget>
</item>
<item row="3" column="0" colspan="3">
<item row="4" column="0" colspan="3">
<layout class="QHBoxLayout" name="horizontalLayout_7">
<item>
<widget class="QWidget" name="manualSettings" native="true">
@ -276,6 +240,52 @@
</item>
</layout>
</item>
<item row="3" column="0">
<widget class="QRadioButton" name="manualProxyRadioButton">
<property name="text">
<string>Manually specify proxy</string>
</property>
<attribute name="buttonGroup">
<string notr="true">proxyButtonGroup</string>
</attribute>
</widget>
</item>
<item row="1" column="0">
<widget class="QRadioButton" name="noProxyRadioButton">
<property name="text">
<string>No proxy</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
<attribute name="buttonGroup">
<string notr="true">proxyButtonGroup</string>
</attribute>
</widget>
</item>
<item row="3" column="2">
<spacer name="horizontalSpacer_2">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
</property>
</spacer>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="globalProxySettingsRadioButton">
<property name="text">
<string>Use global settings</string>
</property>
<attribute name="buttonGroup">
<string notr="true">proxyButtonGroup</string>
</attribute>
</widget>
</item>
</layout>
</widget>
</item>
@ -311,7 +321,7 @@
<property name="verticalSpacing">
<number>6</number>
</property>
<item row="0" column="0" colspan="2">
<item row="1" column="0" colspan="2">
<widget class="QRadioButton" name="noDownloadLimitRadioButton">
<property name="text">
<string>No limit</string>
@ -321,24 +331,7 @@
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QRadioButton" name="autoDownloadLimitRadioButton">
<property name="toolTip">
<string>Limit to 3/4 of estimated bandwidth</string>
</property>
<property name="text">
<string>Limit automatically</string>
</property>
</widget>
</item>
<item row="3" column="0">
<widget class="QRadioButton" name="downloadLimitRadioButton">
<property name="text">
<string>Limit to</string>
</property>
</widget>
</item>
<item row="4" column="0">
<item row="5" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QSpinBox" name="downloadSpinBox">
@ -368,7 +361,7 @@
</item>
</layout>
</item>
<item row="5" column="0">
<item row="6" column="0">
<spacer name="verticalSpacer_2">
<property name="orientation">
<enum>Qt::Vertical</enum>
@ -381,6 +374,30 @@
</property>
</spacer>
</item>
<item row="4" column="0">
<widget class="QRadioButton" name="downloadLimitRadioButton">
<property name="text">
<string>Limit to</string>
</property>
</widget>
</item>
<item row="2" column="0" colspan="2">
<widget class="QRadioButton" name="autoDownloadLimitRadioButton">
<property name="toolTip">
<string>Limit to 3/4 of estimated bandwidth</string>
</property>
<property name="text">
<string>Limit automatically</string>
</property>
</widget>
</item>
<item row="0" column="0">
<widget class="QRadioButton" name="globalDownloadSettingsRadioButton">
<property name="text">
<string>Use global settings</string>
</property>
</widget>
</item>
</layout>
</widget>
</item>
@ -411,7 +428,47 @@
<property name="verticalSpacing">
<number>6</number>
</property>
<item row="2" column="0" colspan="2">
<widget class="QRadioButton" name="autoUploadLimitRadioButton">
<property name="toolTip">
<string>Limit to 3/4 of estimated bandwidth</string>
</property>
<property name="text">
<string>Limit automatically</string>
</property>
</widget>
</item>
<item row="5" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
<item row="3" column="0">
<widget class="QRadioButton" name="uploadLimitRadioButton">
<property name="text">
<string>Limit to</string>
</property>
</widget>
</item>
<item row="1" column="0" colspan="2">
<widget class="QRadioButton" name="noUploadLimitRadioButton">
<property name="text">
<string>No limit</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_4" stretch="0,0">
<item>
<widget class="QSpinBox" name="uploadSpinBox">
@ -444,51 +501,19 @@
</item>
</layout>
</item>
<item row="1" column="0" colspan="2">
<widget class="QRadioButton" name="autoUploadLimitRadioButton">
<property name="toolTip">
<string>Limit to 3/4 of estimated bandwidth</string>
</property>
<item row="0" column="0">
<widget class="QRadioButton" name="globalUploadSettingsRadioButton">
<property name="text">
<string>Limit automatically</string>
<string>Use global settings</string>
</property>
</widget>
</item>
<item row="2" column="0">
<widget class="QRadioButton" name="uploadLimitRadioButton">
<property name="text">
<string>Limit to</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QRadioButton" name="noUploadLimitRadioButton">
<property name="text">
<string>No limit</string>
</property>
<property name="checked">
<bool>true</bool>
</property>
</widget>
</item>
<item row="4" column="0">
<spacer name="verticalSpacer_3">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
<zorder>autoUploadLimitRadioButton</zorder>
<zorder>uploadLimitRadioButton</zorder>
<zorder>noUploadLimitRadioButton</zorder>
<zorder>verticalSpacer_3</zorder>
<zorder>globalUploadSettingsRadioButton</zorder>
</widget>
</item>
</layout>