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
7 changes: 7 additions & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,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 @@ -260,6 +263,10 @@ set(client_SRCS
wizard/wizardproxysettingsdialog.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 @@ -17,6 +17,8 @@
#include <QNetworkProxy>
#include <QString>
#include <QList>
#include <QPainter>
#include <QPainterPath>
#include <type_traits>

namespace OCC {
Expand All @@ -28,6 +30,11 @@ NetworkSettings::NetworkSettings(const AccountPtr &account, QWidget *parent)
{
_ui->setupUi(this);

_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 @@ -276,5 +283,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
23 changes: 16 additions & 7 deletions src/gui/networksettings.ui
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,13 @@
<property name="title">
<string>Proxy Settings</string>
</property>
<property name="flat">
<bool>true</bool>
</property>
<layout class="QGridLayout" name="gridLayout">
<property name="verticalSpacing">
<number>8</number>
</property>
<item row="0" column="0">
<widget class="QRadioButton" name="noProxyRadioButton">
<property name="text">
Expand Down Expand Up @@ -304,15 +310,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>0</number>
</property>
<property name="verticalSpacing">
<number>6</number>
<number>8</number>
</property>
<item row="3" column="0">
<widget class="QRadioButton" name="downloadLimitRadioButton">
Expand All @@ -337,7 +346,7 @@
<string>Limit to 3/4 of estimated bandwidth</string>
</property>
<property name="text">
<string>Limit automatically</string>
<string>Limit to 3/4 of estimated bandwidth</string>
</property>
</widget>
</item>
Expand Down Expand Up @@ -402,17 +411,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>0</number>
</property>
<property name="verticalSpacing">
<number>6</number>
<number>8</number>
</property>
<item row="3" column="0">
<layout class="QHBoxLayout" name="horizontalLayout_4" stretch="0,0">
Expand Down Expand Up @@ -460,7 +469,7 @@
<string>Limit to 3/4 of estimated bandwidth</string>
</property>
<property name="text">
<string>Limit automatically</string>
<string>Limit to 3/4 of estimated bandwidth</string>
</property>
</widget>
</item>
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;
delete ui->horizontalSpacer_2;

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

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

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"));
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 <[email protected]>
*
* 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