Skip to content

Commit

Permalink
Merge #91 Nmc/2003-network settings dialog - Master
Browse files Browse the repository at this point in the history
  • Loading branch information
eugenMCloud committed Mar 8, 2024
2 parents b03c206 + 4ac834a commit fcfc1e4
Show file tree
Hide file tree
Showing 6 changed files with 172 additions and 1 deletion.
3 changes: 3 additions & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ set(CMAKE_AUTOUIC_SEARCH_PATHS "${CMAKE_SOURCE_DIR}/src/gui")
#NMC change, its needed to find the ui file in a different location than the header file
set(CMAKE_AUTOUIC_SEARCH_PATHS "${CMAKE_SOURCE_DIR}/src/gui")

#NMC change, its 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(QUICK_COMPILER)
find_package(Qt5QuickCompiler)
set_package_properties(Qt5QuickCompiler PROPERTIES
Expand Down
2 changes: 2 additions & 0 deletions src/gui/networksettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ void NetworkSettings::loadBWLimitSettings()
_ui->uploadSpinBox->setValue(cfgFile.uploadLimit());
}



void NetworkSettings::saveProxySettings()
{
ConfigFile cfgFile;
Expand Down
5 changes: 5 additions & 0 deletions src/gui/networksettings.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,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 Down
109 changes: 109 additions & 0 deletions src/gui/nmcgui/nmcnetworksettings.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
/*
* 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"


namespace OCC {

NMCNetworkSettings::NMCNetworkSettings(QWidget *parent)
: NetworkSettings(parent)
{
setLayout();
}

void NMCNetworkSettings::setLayout()
{
//Fix Layouts
//Proxy settings
getUi()->proxyGroupBox->setTitle("");
getUi()->proxyGroupBox->layout()->removeWidget(getUi()->manualProxyRadioButton);
getUi()->proxyGroupBox->layout()->removeWidget(getUi()->noProxyRadioButton);
getUi()->proxyGroupBox->layout()->removeWidget(getUi()->systemProxyRadioButton);
getUi()->proxyGroupBox->layout()->removeItem(getUi()->horizontalLayout_7);
getUi()->proxyGroupBox->layout()->removeItem(getUi()->horizontalSpacer_2);
getUi()->proxyGroupBox->layout()->setContentsMargins(16,16,16,16);
getUi()->proxyGroupBox->setStyleSheet("QGroupBox { background-color: white; border-radius: 4px; }");

QGridLayout *proxyLayout = static_cast<QGridLayout *>(getUi()->proxyGroupBox->layout());
auto proxyLabel = new QLabel(QCoreApplication::translate("", "PROXY_SETTINGS"));
proxyLabel->setStyleSheet("QLabel{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(getUi()->noProxyRadioButton, 2, 0 );
proxyLayout->addWidget(getUi()->systemProxyRadioButton, 3, 0 );
proxyLayout->addWidget(getUi()->manualProxyRadioButton, 4, 0 );
proxyLayout->addLayout(getUi()->horizontalLayout_7, 5, 0);

//Remove the spacer, so the elements can expand.
getUi()->horizontalSpacer->changeSize(0,0, QSizePolicy::Fixed, QSizePolicy::Fixed);

//DownloadBox
getUi()->verticalSpacer_2->changeSize(0,0, QSizePolicy::Fixed, QSizePolicy::Fixed);
getUi()->downloadBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
getUi()->horizontalLayout_3->setSpacing(8);
getUi()->downloadBox->setTitle("");
getUi()->downloadBox->layout()->removeWidget(getUi()->noDownloadLimitRadioButton);
getUi()->downloadBox->layout()->removeWidget(getUi()->autoDownloadLimitRadioButton);
getUi()->downloadBox->layout()->removeWidget(getUi()->downloadLimitRadioButton);
getUi()->downloadBox->layout()->removeItem(getUi()->horizontalLayout_3);
getUi()->downloadBox->layout()->setContentsMargins(16,16,16,16);
getUi()->downloadBox->setStyleSheet("QGroupBox { background-color: white; border-radius: 4px; }");

QGridLayout *downLayout = static_cast<QGridLayout *>(getUi()->downloadBox->layout());

auto downLabel = new QLabel(QCoreApplication::translate("", "DOWNLOAD_BANDWIDTH"));
downLabel->setStyleSheet("QLabel{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(getUi()->noDownloadLimitRadioButton, 2, 0 );
downLayout->addWidget(getUi()->autoDownloadLimitRadioButton, 3, 0 );
downLayout->addWidget(getUi()->downloadLimitRadioButton, 4, 0 );
downLayout->addItem(getUi()->horizontalLayout_3, 4, 1);

getUi()->downloadLimitRadioButton->setFixedHeight(getUi()->downloadSpinBox->height());

//UploadBox
getUi()->uploadBox->layout()->removeItem(getUi()->horizontalLayout_4);
static_cast<QGridLayout *>(getUi()->uploadBox->layout())->addItem(getUi()->horizontalLayout_4, 2, 1);

getUi()->verticalSpacer_3->changeSize(0,0, QSizePolicy::Fixed, QSizePolicy::Fixed);
getUi()->uploadBox->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
getUi()->horizontalLayout_4->setSpacing(8);
getUi()->uploadBox->setTitle("");
getUi()->uploadBox->layout()->removeWidget(getUi()->noUploadLimitRadioButton);
getUi()->uploadBox->layout()->removeWidget(getUi()->autoUploadLimitRadioButton);
getUi()->uploadBox->layout()->removeWidget(getUi()->uploadLimitRadioButton);
getUi()->uploadBox->layout()->removeItem(getUi()->horizontalLayout_4);
getUi()->uploadBox->layout()->setContentsMargins(16,16,16,16);
getUi()->uploadBox->setStyleSheet("QGroupBox { background-color: white; border-radius: 4px; }");

QGridLayout *upLayout = static_cast<QGridLayout *>(getUi()->uploadBox->layout());

auto uploadLabel = new QLabel(QCoreApplication::translate("", "UPLOAD_BANDWIDTH"));
uploadLabel->setStyleSheet("QLabel{font-size: 12px; font-weight: bold;}");
upLayout->addWidget(uploadLabel, 0, 0 );
upLayout->addItem(new QSpacerItem(1,8, QSizePolicy::Fixed, QSizePolicy::Fixed), 1, 0);
upLayout->addWidget(getUi()->noUploadLimitRadioButton, 2, 0 );
upLayout->addWidget(getUi()->autoUploadLimitRadioButton, 3, 0 );
upLayout->addWidget(getUi()->uploadLimitRadioButton, 4, 0 );
upLayout->addItem(getUi()->horizontalLayout_4, 4, 1);

getUi()->uploadLimitRadioButton->setFixedHeight(getUi()->uploadSpinBox->height());
}

} // namespace OCC
51 changes: 51 additions & 0 deletions src/gui/nmcgui/nmcnetworksettings.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* 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"

namespace OCC {

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

public:
/**
* @brief Constructs an NMCNetworkSettings object.
* @param parent Pointer to the parent QWidget.
*/
explicit NMCNetworkSettings(QWidget *parent = nullptr);

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

private:
/**
* @brief Sets the layout for the network settings specific to NMC (Magenta).
*/
void setLayout();
};

} // namespace OCC
#endif // MIRALL_NETWORKSETTINGSMAGENTA_H
3 changes: 2 additions & 1 deletion src/gui/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
#include "progressdispatcher.h"
#include "owncloudgui.h"
#include "accountmanager.h"
#include "nmcgui/nmcnetworksettings.h"

#include <QLabel>
#include <QStandardItemModel>
Expand Down Expand Up @@ -138,7 +139,7 @@ SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent)
QAction *networkAction = createColorAwareAction(QLatin1String(":/client/theme/network.svg"), tr("Network"));
_actionGroup->addAction(networkAction);
_toolBar->addAction(networkAction);
auto *networkSettings = new NetworkSettings;
auto *networkSettings = new NMCNetworkSettings;
_ui->stack->addWidget(networkSettings);

_actionGroupWidgets.insert(generalAction, generalSettings);
Expand Down

0 comments on commit fcfc1e4

Please sign in to comment.