Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ find_package(Qt${QT_MAJOR_VERSION} REQUIRED COMPONENTS Widgets Svg Qml Quick Qui
find_package(KF6Archive REQUIRED)
find_package(KF6GuiAddons)

#NMC customization: needed to find the ui file in a different location than the header file
set(CMAKE_AUTOUIC_SEARCH_PATHS "${CMAKE_SOURCE_DIR}/src/gui")

if(CMAKE_BUILD_TYPE MATCHES Debug)
add_definitions(-DQT_QML_DEBUG)
endif()
Expand All @@ -23,6 +26,9 @@ endif()
configure_file(${CMAKE_SOURCE_DIR}/theme.qrc.in ${CMAKE_SOURCE_DIR}/theme.qrc)
set(theme_dir ${CMAKE_SOURCE_DIR}/theme)

#NMC customization: needed to find the ui file in a different location than the header file
set(CMAKE_AUTOUIC_SEARCH_PATHS "${CMAKE_SOURCE_DIR}/src/gui")

set(client_UI_SRCS
accountsettings.ui
conflictdialog.ui
Expand Down Expand Up @@ -261,6 +267,10 @@ set(client_SRCS
integration/fileactionsmodel.cpp
)

file(GLOB NMC_FILES "nmcgui/*")
set(NMC_SRCS ${NMC_FILES})
list(APPEND client_SRCS ${NMC_SRCS})

if (NOT DISABLE_ACCOUNT_MIGRATION)
list(APPEND client_SRCS
legacyaccountselectiondialog.h
Expand Down
27 changes: 27 additions & 0 deletions src/gui/networksettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#include <QNetworkProxy>
#include <QString>
#include <QList>
#include <QPainter>
#include <QPainterPath>
#include <QPalette>
#include <type_traits>

Expand All @@ -38,6 +40,11 @@ NetworkSettings::NetworkSettings(const AccountPtr &account, QWidget *parent)
_ui->uploadBox->setAutoFillBackground(true);
_ui->uploadBox->setBackgroundRole(QPalette::AlternateBase);

_ui->gridLayout_3->setContentsMargins(8, 8, 8, 0);

setAttribute(Qt::WA_OpaquePaintEvent, true);
setAutoFillBackground(false);

_ui->manualSettings->setVisible(_ui->manualProxyRadioButton->isChecked());

_ui->proxyGroupBox->setVisible(!Theme::instance()->doNotUseProxy());
Expand Down Expand Up @@ -278,5 +285,25 @@ void NetworkSettings::checkAccountLocalhost()
_ui->labelLocalhost->setVisible(visible);
}

void NetworkSettings::paintEvent(QPaintEvent *event)
{
QPainter painter(this);
painter.setRenderHint(QPainter::Antialiasing);

const int radius = 4;
QRect rect(0, 0, width(), height());

QPainterPath path;
path.addRoundedRect(rect, radius, radius);

QPalette palette = this->palette();
QColor backgroundColor = palette.color(QPalette::Window);
QColor baseColor = palette.color(QPalette::Base);

painter.fillRect(rect, backgroundColor);
painter.fillPath(path, baseColor);

QWidget::paintEvent(event);
}

} // namespace OCC
6 changes: 6 additions & 0 deletions src/gui/networksettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,11 @@ class NetworkSettings : public QWidget
~NetworkSettings() override;
[[nodiscard]] QSize sizeHint() const override;

Ui::NetworkSettings *getUi() const
{
return _ui;
}

private slots:
void saveProxySettings();
void saveBWLimitSettings();
Expand All @@ -42,6 +47,7 @@ private slots:

protected:
void showEvent(QShowEvent *event) override;
void paintEvent(QPaintEvent *event) override;

private:
void loadProxySettings();
Expand Down
42 changes: 34 additions & 8 deletions src/gui/networksettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,12 @@
<property name="title">
<string>Proxy Settings</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="bottomMargin">
<number>0</number>
<property name="verticalSpacing">
<number>8</number>
</property>
<item row="0" column="0">
<widget class="QRadioButton" name="noProxyRadioButton">
Expand Down Expand Up @@ -294,15 +297,18 @@
<property name="alignment">
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_2">
<property name="topMargin">
<number>9</number>
<number>8</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<property name="verticalSpacing">
<number>6</number>
<number>8</number>
</property>
<item row="1" column="0">
<widget class="QRadioButton" name="downloadLimitRadioButton">
Expand All @@ -321,7 +327,17 @@
</property>
</widget>
</item>
<item row="2" column="0">
<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 to 3/4 of estimated bandwidth</string>
</property>
</widget>
</item>
<item row="4" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
<widget class="QSpinBox" name="downloadSpinBox">
Expand Down Expand Up @@ -369,17 +385,17 @@
<set>Qt::AlignmentFlag::AlignLeading|Qt::AlignmentFlag::AlignLeft|Qt::AlignmentFlag::AlignTop</set>
</property>
<property name="flat">
<bool>false</bool>
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout_4">
<property name="topMargin">
<number>9</number>
<number>8</number>
</property>
<property name="bottomMargin">
<number>9</number>
</property>
<property name="verticalSpacing">
<number>6</number>
<number>8</number>
</property>
<item row="2" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_4" stretch="0,0">
Expand Down Expand Up @@ -421,6 +437,16 @@
</property>
</widget>
</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>
<property name="text">
<string>Limit to 3/4 of estimated bandwidth</string>
</property>
</widget>
</item>
<item row="0" column="0" colspan="2">
<widget class="QRadioButton" name="noUploadLimitRadioButton">
<property name="text">
Expand Down
125 changes: 125 additions & 0 deletions src/gui/nmcgui/nmcnetworksettings.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/*
* Copyright (C) by Eugen Fischer
*
* 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; either version 2 of the License, or
* (at your option) any later version.
*
* 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 "nmcgui/nmcnetworksettings.h"
#include "networksettings.h"
#include "ui_networksettings.h"

#include <QLabel>
#include <QSpacerItem>
#include <QGridLayout>
#include <QSizePolicy>
#include <QCoreApplication>

namespace OCC {

NMCNetworkSettings::NMCNetworkSettings(const AccountPtr &account, QWidget *parent)
: NetworkSettings(account, parent)
{
setLayout();
}

void NMCNetworkSettings::setLayout()
{
auto *ui = getUi();

//
// Proxy Settings
//
ui->proxyGroupBox->setTitle({});
ui->proxyGroupBox->layout()->removeWidget(ui->manualProxyRadioButton);
ui->proxyGroupBox->layout()->removeWidget(ui->noProxyRadioButton);
ui->proxyGroupBox->layout()->removeWidget(ui->systemProxyRadioButton);

delete ui->horizontalLayout_7;

Check failure on line 45 in src/gui/nmcgui/nmcnetworksettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rewrite the code so that you no longer need this "delete".

See more on https://sonarcloud.io/project/issues?id=nextmcloud_desktop&issues=AZ0KvcIYMkOQCVvjls42&open=AZ0KvcIYMkOQCVvjls42&pullRequest=389
delete ui->horizontalSpacer_2;

Check failure on line 46 in src/gui/nmcgui/nmcnetworksettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rewrite the code so that you no longer need this "delete".

See more on https://sonarcloud.io/project/issues?id=nextmcloud_desktop&issues=AZ0KvcIYMkOQCVvjls43&open=AZ0KvcIYMkOQCVvjls43&pullRequest=389

ui->proxyGroupBox->layout()->setContentsMargins(16, 16, 16, 16);
ui->proxyGroupBox->setStyleSheet("border-radius: 4px;");

auto *proxyLayout = qobject_cast<QGridLayout *>(ui->proxyGroupBox->layout());
auto *proxyLabel = new QLabel(QCoreApplication::translate("", "PROXY_SETTINGS"));

Check failure on line 52 in src/gui/nmcgui/nmcnetworksettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace the use of "new" with an operation that automatically manages the memory.

See more on https://sonarcloud.io/project/issues?id=nextmcloud_desktop&issues=AZ0KvcIYMkOQCVvjls46&open=AZ0KvcIYMkOQCVvjls46&pullRequest=389
proxyLabel->setStyleSheet("font-size: 12px; font-weight: bold;");

proxyLayout->addWidget(proxyLabel, 0, 0);
proxyLayout->addItem(new QSpacerItem(1, 8, QSizePolicy::Fixed, QSizePolicy::Fixed), 1, 0);
proxyLayout->addWidget(ui->noProxyRadioButton, 2, 0);
proxyLayout->addWidget(ui->systemProxyRadioButton, 3, 0);
proxyLayout->addWidget(ui->manualProxyRadioButton, 4, 0);

ui->horizontalSpacer->changeSize(0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
ui->proxyGroupBox->setStyleSheet(ui->proxyGroupBox->styleSheet());

//
// Download Bandwidth
//
ui->verticalSpacer_2->changeSize(0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
ui->downloadBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
ui->horizontalLayout_3->setSpacing(8);
ui->downloadBox->setTitle({});

ui->downloadBox->layout()->removeWidget(ui->noDownloadLimitRadioButton);
ui->downloadBox->layout()->removeWidget(ui->autoDownloadLimitRadioButton);
ui->downloadBox->layout()->removeWidget(ui->downloadLimitRadioButton);

delete ui->horizontalLayout_3;

Check failure on line 76 in src/gui/nmcgui/nmcnetworksettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rewrite the code so that you no longer need this "delete".

See more on https://sonarcloud.io/project/issues?id=nextmcloud_desktop&issues=AZ0KvcIYMkOQCVvjls44&open=AZ0KvcIYMkOQCVvjls44&pullRequest=389

ui->downloadBox->layout()->setContentsMargins(16, 16, 16, 16);
ui->downloadBox->setStyleSheet("border-radius: 4px;");

auto *downLayout = qobject_cast<QGridLayout *>(ui->downloadBox->layout());
auto *downLabel = new QLabel(QCoreApplication::translate("", "DOWNLOAD_BANDWIDTH"));

Check failure on line 82 in src/gui/nmcgui/nmcnetworksettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace the use of "new" with an operation that automatically manages the memory.

See more on https://sonarcloud.io/project/issues?id=nextmcloud_desktop&issues=AZ0KvcIYMkOQCVvjls47&open=AZ0KvcIYMkOQCVvjls47&pullRequest=389
downLabel->setStyleSheet("font-size: 12px; font-weight: bold;");

downLayout->addWidget(downLabel, 0, 0);
downLayout->addItem(new QSpacerItem(1, 8, QSizePolicy::Fixed, QSizePolicy::Fixed), 1, 0);
downLayout->addWidget(ui->noDownloadLimitRadioButton, 2, 0);
downLayout->addWidget(ui->autoDownloadLimitRadioButton, 3, 0);
downLayout->addWidget(ui->downloadLimitRadioButton, 4, 0);

ui->downloadLimitRadioButton->setFixedHeight(ui->downloadSpinBox->height());
ui->downloadBox->setStyleSheet(ui->downloadBox->styleSheet());

//
// Upload Bandwidth
//
ui->verticalSpacer_3->changeSize(0, 0, QSizePolicy::Fixed, QSizePolicy::Fixed);
ui->uploadBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
ui->horizontalLayout_4->setSpacing(8);
ui->uploadBox->setTitle({});

ui->uploadBox->layout()->removeWidget(ui->noUploadLimitRadioButton);
ui->uploadBox->layout()->removeWidget(ui->autoUploadLimitRadioButton);
ui->uploadBox->layout()->removeWidget(ui->uploadLimitRadioButton);

delete ui->horizontalLayout_4;

Check failure on line 106 in src/gui/nmcgui/nmcnetworksettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Rewrite the code so that you no longer need this "delete".

See more on https://sonarcloud.io/project/issues?id=nextmcloud_desktop&issues=AZ0KvcIYMkOQCVvjls45&open=AZ0KvcIYMkOQCVvjls45&pullRequest=389

ui->uploadBox->layout()->setContentsMargins(16, 16, 16, 16);
ui->uploadBox->setStyleSheet("border-radius: 4px;");

auto *upLayout = qobject_cast<QGridLayout *>(ui->uploadBox->layout());
auto *upLabel = new QLabel(QCoreApplication::translate("", "UPLOAD_BANDWIDTH"));

Check failure on line 112 in src/gui/nmcgui/nmcnetworksettings.cpp

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Replace the use of "new" with an operation that automatically manages the memory.

See more on https://sonarcloud.io/project/issues?id=nextmcloud_desktop&issues=AZ0KvcIYMkOQCVvjls48&open=AZ0KvcIYMkOQCVvjls48&pullRequest=389
upLabel->setStyleSheet("font-size: 12px; font-weight: bold;");

upLayout->addWidget(upLabel, 0, 0);
upLayout->addItem(new QSpacerItem(1, 8, QSizePolicy::Fixed, QSizePolicy::Fixed), 1, 0);
upLayout->addWidget(ui->noUploadLimitRadioButton, 2, 0);
upLayout->addWidget(ui->autoUploadLimitRadioButton, 3, 0);
upLayout->addWidget(ui->uploadLimitRadioButton, 4, 0);

ui->uploadLimitRadioButton->setFixedHeight(ui->uploadSpinBox->height());
ui->uploadBox->setStyleSheet(ui->uploadBox->styleSheet());
}

} // namespace OCC
57 changes: 57 additions & 0 deletions src/gui/nmcgui/nmcnetworksettings.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* Copyright (C) by Daniel Molkentin <danimo@owncloud.com>
*
* 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; either version 2 of the License, or
* (at your option) any later version.
*
* 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_NETWORKSETTINGSMAGENTA_H
#define MIRALL_NETWORKSETTINGSMAGENTA_H

#include "networksettings.h"

QT_BEGIN_NAMESPACE
class QWidget;
QT_END_NAMESPACE

namespace OCC {

/**
* @class NMCNetworkSettings
* @ingroup gui
* @brief Derived class for network settings specific to NMC (Magenta) in the ownCloud client.
*/
class NMCNetworkSettings : public NetworkSettings
{
Q_OBJECT

public:
/**
* @brief Constructor
* @param account Account pointer used to configure settings
* @param parent Parent widget
*/
explicit NMCNetworkSettings(const AccountPtr &account = {}, QWidget *parent = nullptr);

/**
* @brief Destructor
*/
~NMCNetworkSettings() override = default;

private:
/**
* @brief Initializes and sets the custom layout
*/
void setLayout();
};

} // namespace OCC

#endif // MIRALL_NETWORKSETTINGSMAGENTA_H
Loading