Skip to content

Commit d6c16f0

Browse files
committed
Merge #407 [stable-4.0] [master] 2003-Network_Settings_Dialog
2 parents 6529ef1 + c2bece4 commit d6c16f0

File tree

5 files changed

+233
-8
lines changed

5 files changed

+233
-8
lines changed

src/gui/networksettings.cpp

Lines changed: 28 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,11 @@ NetworkSettings::NetworkSettings(const AccountPtr &account, QWidget *parent)
2830
{
2931
_ui->setupUi(this);
3032

33+
_ui->gridLayout_3->setContentsMargins(8, 8, 8, 0);
34+
35+
setAttribute(Qt::WA_OpaquePaintEvent, true);
36+
setAutoFillBackground(false);
37+
3138
_ui->manualSettings->setVisible(_ui->manualProxyRadioButton->isChecked());
3239

3340
_ui->proxyGroupBox->setVisible(!Theme::instance()->doNotUseProxy());
@@ -276,5 +283,26 @@ void NetworkSettings::checkAccountLocalhost()
276283
_ui->labelLocalhost->setVisible(visible);
277284
}
278285

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

280308
} // 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: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,13 @@
4444
<property name="title">
4545
<string>Proxy Settings</string>
4646
</property>
47+
<property name="flat">
48+
<bool>true</bool>
49+
</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">
@@ -304,15 +310,18 @@
304310
<property name="alignment">
305311
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set>
306312
</property>
313+
<property name="flat">
314+
<bool>true</bool>
315+
</property>
307316
<layout class="QGridLayout" name="gridLayout_2">
308317
<property name="topMargin">
309-
<number>9</number>
318+
<number>8</number>
310319
</property>
311320
<property name="bottomMargin">
312-
<number>0</number>
321+
<number>0</number>
313322
</property>
314323
<property name="verticalSpacing">
315-
<number>6</number>
324+
<number>8</number>
316325
</property>
317326
<item row="3" column="0">
318327
<widget class="QRadioButton" name="downloadLimitRadioButton">
@@ -337,7 +346,7 @@
337346
<string>Limit to 3/4 of estimated bandwidth</string>
338347
</property>
339348
<property name="text">
340-
<string>Limit automatically</string>
349+
<string>Limit to 3/4 of estimated bandwidth</string>
341350
</property>
342351
</widget>
343352
</item>
@@ -402,17 +411,17 @@
402411
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set>
403412
</property>
404413
<property name="flat">
405-
<bool>false</bool>
414+
<bool>true</bool>
406415
</property>
407416
<layout class="QGridLayout" name="gridLayout_4">
408417
<property name="topMargin">
409-
<number>9</number>
418+
<number>8</number>
410419
</property>
411420
<property name="bottomMargin">
412421
<number>0</number>
413422
</property>
414423
<property name="verticalSpacing">
415-
<number>6</number>
424+
<number>8</number>
416425
</property>
417426
<item row="3" column="0">
418427
<layout class="QHBoxLayout" name="horizontalLayout_4" stretch="0,0">
@@ -460,7 +469,7 @@
460469
<string>Limit to 3/4 of estimated bandwidth</string>
461470
</property>
462471
<property name="text">
463-
<string>Limit automatically</string>
472+
<string>Limit to 3/4 of estimated bandwidth</string>
464473
</property>
465474
</widget>
466475
</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)