Skip to content

Commit 347436e

Browse files
committed
Merge #407 [stable-4.0] [master] 2003-Network_Settings_Dialog
2 parents 0f7ff2d + 8154d09 commit 347436e

File tree

5 files changed

+224
-10
lines changed

5 files changed

+224
-10
lines changed

src/gui/networksettings.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
#include <QNetworkProxy>
1818
#include <QString>
1919
#include <QList>
20+
#include <QPainter>
21+
#include <QPainterPath>
2022
#include <type_traits>
2123

2224
namespace OCC {
@@ -28,6 +30,9 @@ NetworkSettings::NetworkSettings(const AccountPtr &account, QWidget *parent)
2830
{
2931
_ui->setupUi(this);
3032

33+
setAttribute(Qt::WA_OpaquePaintEvent, false);
34+
setAutoFillBackground(false);
35+
3136
_ui->manualSettings->setVisible(_ui->manualProxyRadioButton->isChecked());
3237

3338
_ui->proxyGroupBox->setVisible(!Theme::instance()->doNotUseProxy());
@@ -276,5 +281,23 @@ void NetworkSettings::checkAccountLocalhost()
276281
_ui->labelLocalhost->setVisible(visible);
277282
}
278283

284+
void NetworkSettings::paintEvent(QPaintEvent *event)
285+
{
286+
287+
const int radius = 4;
288+
289+
QPainter painter(this);
290+
painter.setRenderHint(QPainter::Antialiasing);
291+
292+
QRect rect(0, 0, width(), height());
293+
QPainterPath path;
294+
path.addRoundedRect(rect, radius, radius);
295+
296+
QPalette palette = this->palette();
297+
painter.fillRect(rect, palette.color(QPalette::Base));
298+
painter.fillPath(path, palette.color(QPalette::Base));
299+
300+
QWidget::paintEvent(event);
301+
}
279302

280303
} // namespace OCC

src/gui/networksettings.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,11 @@ class NetworkSettings : public QWidget
3131
~NetworkSettings() override;
3232
[[nodiscard]] QSize sizeHint() const override;
3333

34+
Ui::NetworkSettings *getUi() const
35+
{
36+
return _ui;
37+
}
38+
3439
private slots:
3540
void saveProxySettings();
3641
void saveBWLimitSettings();
@@ -42,6 +47,7 @@ private slots:
4247

4348
protected:
4449
void showEvent(QShowEvent *event) override;
50+
void paintEvent(QPaintEvent *event) override;
4551

4652
private:
4753
void loadProxySettings();

src/gui/networksettings.ui

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@
1717
<bool>true</bool>
1818
</property>
1919
<layout class="QGridLayout" name="gridLayout_3">
20+
<property name="topMargin">
21+
<number>16</number>
22+
</property>
2023
<item row="2" column="0">
2124
<spacer name="verticalSpacer">
2225
<property name="orientation">
@@ -45,6 +48,9 @@
4548
<string>Proxy Settings</string>
4649
</property>
4750
<layout class="QGridLayout" name="gridLayout">
51+
<property name="verticalSpacing">
52+
<number>8</number>
53+
</property>
4854
<item row="0" column="0">
4955
<widget class="QRadioButton" name="noProxyRadioButton">
5056
<property name="text">
@@ -306,13 +312,13 @@
306312
</property>
307313
<layout class="QGridLayout" name="gridLayout_2">
308314
<property name="topMargin">
309-
<number>9</number>
315+
<number>8</number>
310316
</property>
311317
<property name="bottomMargin">
312-
<number>0</number>
318+
<number>0</number>
313319
</property>
314320
<property name="verticalSpacing">
315-
<number>6</number>
321+
<number>8</number>
316322
</property>
317323
<item row="3" column="0">
318324
<widget class="QRadioButton" name="downloadLimitRadioButton">
@@ -337,7 +343,7 @@
337343
<string>Limit to 3/4 of estimated bandwidth</string>
338344
</property>
339345
<property name="text">
340-
<string>Limit automatically</string>
346+
<string>Limit to 3/4 of estimated bandwidth</string>
341347
</property>
342348
</widget>
343349
</item>
@@ -401,18 +407,15 @@
401407
<property name="alignment">
402408
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set>
403409
</property>
404-
<property name="flat">
405-
<bool>false</bool>
406-
</property>
407410
<layout class="QGridLayout" name="gridLayout_4">
408411
<property name="topMargin">
409-
<number>9</number>
412+
<number>12</number>
410413
</property>
411414
<property name="bottomMargin">
412415
<number>0</number>
413416
</property>
414417
<property name="verticalSpacing">
415-
<number>6</number>
418+
<number>8</number>
416419
</property>
417420
<item row="3" column="0">
418421
<layout class="QHBoxLayout" name="horizontalLayout_4" stretch="0,0">
@@ -460,7 +463,7 @@
460463
<string>Limit to 3/4 of estimated bandwidth</string>
461464
</property>
462465
<property name="text">
463-
<string>Limit automatically</string>
466+
<string>Limit to 3/4 of estimated bandwidth</string>
464467
</property>
465468
</widget>
466469
</item>
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
/*
2+
* Copyright (C) by Eugen Fischer
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 2 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful, but
10+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* for more details.
13+
*/
14+
15+
#include "nmcgui/nmcnetworksettings.h"
16+
#include "networksettings.h"
17+
#include "ui_networksettings.h"
18+
19+
#include <QLabel>
20+
#include <QSpacerItem>
21+
#include <QGridLayout>
22+
#include <QSizePolicy>
23+
#include <QCoreApplication>
24+
25+
namespace OCC {
26+
27+
NMCNetworkSettings::NMCNetworkSettings(const AccountPtr &account, QWidget *parent)
28+
: NetworkSettings(account, parent)
29+
{
30+
setLayout();
31+
}
32+
33+
void NMCNetworkSettings::setLayout()
34+
{
35+
auto *ui = getUi();
36+
37+
//
38+
// Proxy Settings
39+
//
40+
ui->proxyGroupBox->setTitle({});
41+
ui->proxyGroupBox->layout()->removeWidget(ui->manualProxyRadioButton);
42+
ui->proxyGroupBox->layout()->removeWidget(ui->noProxyRadioButton);
43+
ui->proxyGroupBox->layout()->removeWidget(ui->systemProxyRadioButton);
44+
45+
delete ui->horizontalLayout_7;
46+
delete ui->horizontalSpacer_2;
47+
48+
ui->proxyGroupBox->layout()->setContentsMargins(16, 16, 16, 16);
49+
ui->proxyGroupBox->setStyleSheet("border-radius: 4px;");
50+
51+
auto *proxyLayout = qobject_cast<QGridLayout *>(ui->proxyGroupBox->layout());
52+
auto *proxyLabel = new QLabel(QCoreApplication::translate("", "PROXY_SETTINGS"));
53+
proxyLabel->setStyleSheet("font-size: 12px; font-weight: bold;");
54+
55+
proxyLayout->addWidget(proxyLabel, 0, 0);
56+
proxyLayout->addItem(new QSpacerItem(1, 8, QSizePolicy::Fixed, QSizePolicy::Fixed), 1, 0);
57+
proxyLayout->addWidget(ui->noProxyRadioButton, 2, 0);
58+
proxyLayout->addWidget(ui->systemProxyRadioButton, 3, 0);
59+
proxyLayout->addWidget(ui->manualProxyRadioButton, 4, 0);
60+
61+
ui->horizontalSpacer->changeSize(0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
62+
ui->proxyGroupBox->setStyleSheet(ui->proxyGroupBox->styleSheet());
63+
64+
//
65+
// Download Bandwidth
66+
//
67+
ui->verticalSpacer_2->changeSize(0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
68+
ui->downloadBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
69+
ui->horizontalLayout_3->setSpacing(8);
70+
ui->downloadBox->setTitle({});
71+
72+
ui->downloadBox->layout()->removeWidget(ui->noDownloadLimitRadioButton);
73+
ui->downloadBox->layout()->removeWidget(ui->autoDownloadLimitRadioButton);
74+
ui->downloadBox->layout()->removeWidget(ui->downloadLimitRadioButton);
75+
76+
delete ui->horizontalLayout_3;
77+
78+
ui->downloadBox->layout()->setContentsMargins(16, 16, 16, 16);
79+
ui->downloadBox->setStyleSheet("border-radius: 4px;");
80+
81+
auto *downLayout = qobject_cast<QGridLayout *>(ui->downloadBox->layout());
82+
auto *downLabel = new QLabel(QCoreApplication::translate("", "DOWNLOAD_BANDWIDTH"));
83+
downLabel->setStyleSheet("font-size: 12px; font-weight: bold;");
84+
85+
downLayout->addWidget(downLabel, 0, 0);
86+
downLayout->addItem(new QSpacerItem(1, 8, QSizePolicy::Fixed, QSizePolicy::Fixed), 1, 0);
87+
downLayout->addWidget(ui->noDownloadLimitRadioButton, 2, 0);
88+
downLayout->addWidget(ui->autoDownloadLimitRadioButton, 3, 0);
89+
downLayout->addWidget(ui->downloadLimitRadioButton, 4, 0);
90+
91+
ui->downloadLimitRadioButton->setFixedHeight(ui->downloadSpinBox->height());
92+
ui->downloadBox->setStyleSheet(ui->downloadBox->styleSheet());
93+
94+
//
95+
// Upload Bandwidth
96+
//
97+
ui->verticalSpacer_3->changeSize(0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
98+
ui->uploadBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
99+
ui->horizontalLayout_4->setSpacing(8);
100+
ui->uploadBox->setTitle({});
101+
102+
ui->uploadBox->layout()->removeWidget(ui->noUploadLimitRadioButton);
103+
ui->uploadBox->layout()->removeWidget(ui->autoUploadLimitRadioButton);
104+
ui->uploadBox->layout()->removeWidget(ui->uploadLimitRadioButton);
105+
106+
delete ui->horizontalLayout_4;
107+
108+
ui->uploadBox->layout()->setContentsMargins(16, 16, 16, 16);
109+
ui->uploadBox->setStyleSheet("border-radius: 4px;");
110+
111+
auto *upLayout = qobject_cast<QGridLayout *>(ui->uploadBox->layout());
112+
auto *upLabel = new QLabel(QCoreApplication::translate("", "UPLOAD_BANDWIDTH"));
113+
upLabel->setStyleSheet("font-size: 12px; font-weight: bold;");
114+
115+
upLayout->addWidget(upLabel, 0, 0);
116+
upLayout->addItem(new QSpacerItem(1, 8, QSizePolicy::Fixed, QSizePolicy::Fixed), 1, 0);
117+
upLayout->addWidget(ui->noUploadLimitRadioButton, 2, 0);
118+
upLayout->addWidget(ui->autoUploadLimitRadioButton, 3, 0);
119+
upLayout->addWidget(ui->uploadLimitRadioButton, 4, 0);
120+
121+
ui->uploadLimitRadioButton->setFixedHeight(ui->uploadSpinBox->height());
122+
ui->uploadBox->setStyleSheet(ui->uploadBox->styleSheet());
123+
}
124+
125+
} // namespace OCC
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/*
2+
* Copyright (C) by Daniel Molkentin <danimo@owncloud.com>
3+
*
4+
* This program is free software; you can redistribute it and/or modify
5+
* it under the terms of the GNU General Public License as published by
6+
* the Free Software Foundation; either version 2 of the License, or
7+
* (at your option) any later version.
8+
*
9+
* This program is distributed in the hope that it will be useful, but
10+
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
11+
* or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* for more details.
13+
*/
14+
15+
#ifndef MIRALL_NETWORKSETTINGSMAGENTA_H
16+
#define MIRALL_NETWORKSETTINGSMAGENTA_H
17+
18+
#include "networksettings.h"
19+
20+
QT_BEGIN_NAMESPACE
21+
class QWidget;
22+
QT_END_NAMESPACE
23+
24+
namespace OCC {
25+
26+
/**
27+
* @class NMCNetworkSettings
28+
* @ingroup gui
29+
* @brief Derived class for network settings specific to NMC (Magenta) in the ownCloud client.
30+
*/
31+
class NMCNetworkSettings : public NetworkSettings
32+
{
33+
Q_OBJECT
34+
35+
public:
36+
/**
37+
* @brief Constructor
38+
* @param account Account pointer used to configure settings
39+
* @param parent Parent widget
40+
*/
41+
explicit NMCNetworkSettings(const AccountPtr &account = {}, QWidget *parent = nullptr);
42+
43+
/**
44+
* @brief Destructor
45+
*/
46+
~NMCNetworkSettings() override = default;
47+
48+
private:
49+
/**
50+
* @brief Initializes and sets the custom layout
51+
*/
52+
void setLayout();
53+
};
54+
55+
} // namespace OCC
56+
57+
#endif // MIRALL_NETWORKSETTINGSMAGENTA_H

0 commit comments

Comments
 (0)