Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nmc/2003-general settings dialog #92

Open
wants to merge 16 commits into
base: master
Choose a base branch
from
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
.gitmodules
# Ignorierte Dateien und Ordner

*build*/
*flymake*
CMakeLists.txt.user*
Expand Down Expand Up @@ -190,3 +191,6 @@ convert.exe
*-w10startmenu.png
*state-*.png
theme.qrc

# Ignore specific folders
shell_integration/MacOSX/NextcloudIntegration/NextcloudIntegration.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/
4 changes: 4 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ set(CMAKE_XCODE_ATTRIBUTE_ENABLE_HARDENED_RUNTIME YES)

set(BIN_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")

set(NMC_RCC_FILE "nmctheme_v1.rcc")
configure_file(${CMAKE_SOURCE_DIR}/${NMC_RCC_FILE} "${BIN_OUTPUT_DIRECTORY}/${NMC_RCC_FILE}" COPYONLY)

include(${CMAKE_SOURCE_DIR}/NEXTCLOUD.cmake)

# CfAPI Shell Extensions
Expand Down Expand Up @@ -297,6 +300,7 @@ configure_file(version.h.in ${CMAKE_CURRENT_BINARY_DIR}/version.h)
if(BUILD_OWNCLOUD_OSX_BUNDLE)
install(FILES sync-exclude.lst DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/)
configure_file(sync-exclude.lst bin/${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/sync-exclude.lst COPYONLY)
install(FILES nmctheme_v1.rcc DESTINATION ${OWNCLOUD_OSX_BUNDLE}/Contents/Resources/)
elseif(BUILD_CLIENT)
install( FILES sync-exclude.lst DESTINATION ${SYSCONFDIR}/${APPLICATION_SHORTNAME} )
configure_file(sync-exclude.lst bin/sync-exclude.lst COPYONLY)
Expand Down
Binary file added nmctheme_v1.rcc
Binary file not shown.
8 changes: 8 additions & 0 deletions src/gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ project(gui)
find_package(Qt5 REQUIRED COMPONENTS Widgets Svg Qml Quick QuickControls2 Xml Network)
find_package(KF5Archive REQUIRED)

#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 Expand Up @@ -260,6 +263,10 @@ set(client_SRCS
wizard/linklabel.cpp
)

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

if (Qt5WebEngine_FOUND AND Qt5WebEngineWidgets_FOUND)
list(APPEND client_SRCS
wizard/webviewpage.h
Expand Down Expand Up @@ -586,6 +593,7 @@ if(NOT BUILD_OWNCLOUD_OSX_BUNDLE)
install(FILES ${VISUAL_ELEMENTS} DESTINATION bin/visualelements)
install(FILES "${theme_dir}/${APPLICATION_EXECUTABLE}.VisualElementsManifest.xml" DESTINATION bin)
install(FILES ${client_I18N} DESTINATION i18n)
install(FILES ${CMAKE_SOURCE_DIR}/nmctheme_v1.rcc DESTINATION bin)
endif()

# we may not add MACOSX_BUNDLE here, if not building one
Expand Down
2 changes: 2 additions & 0 deletions src/gui/generalsettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -537,4 +537,6 @@ void GeneralSettings::customizeStyle()
#endif
}



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

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

public slots:
void slotStyleChanged();

Expand Down
11 changes: 11 additions & 0 deletions src/gui/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,17 @@ int main(int argc, char **argv)
#ifdef Q_OS_WIN
SetDllDirectory(L"");
#endif
bool resourceLoaded = false;
const QString currentPath = QDir::currentPath();
if(Utility::isMac())
{
resourceLoaded = QResource::registerResource(QDir::toNativeSeparators("/Applications/MagentaCLOUD.app/Contents/Resources/nmctheme_v1.rcc"));
}
else if(Utility::isWindows() || !resourceLoaded)
{
resourceLoaded = QResource::registerResource(QDir::toNativeSeparators(currentPath + "/nmctheme_v1.rcc"));
}

Q_INIT_RESOURCE(resources);
Q_INIT_RESOURCE(theme);

Expand Down
173 changes: 173 additions & 0 deletions src/gui/nmcgui/nmcgeneralsettings.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
/*
* 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 "nmcgeneralsettings.h"
#include "generalsettings.h"
#include "nmclibsync/nmcconfigfile.h"
#include "ui_generalsettings.h"
#include "theme.h"


namespace OCC {

NMCGeneralSettings::NMCGeneralSettings(QWidget *parent)
: GeneralSettings(parent)
{
setDefaultSettings();
setNMCLayout();
}

void NMCGeneralSettings::setDefaultSettings()
{
//Set default settings
//General settings
getUi()->autostartCheckBox->setCheckState(Qt::Checked);
getUi()->monoIconsCheckBox->setCheckState(Qt::Unchecked);
getUi()->serverNotificationsCheckBox->setCheckState(Qt::Unchecked);
getUi()->callNotificationsCheckBox->setCheckState(Qt::Unchecked);
//Advanced settings
getUi()->newFolderLimitCheckBox->setCheckState(Qt::Unchecked);
//Info settings
getUi()->aboutAndUpdatesGroupBox->setTitle(tr("Update"));
//Hide unsupported settings
//General settings
getUi()->monoIconsCheckBox->setVisible(false);
getUi()->callNotificationsCheckBox->setVisible(false);
//Advanced settings
getUi()->groupBox->setVisible(false);
//Info settings
getUi()->aboutAndUpdatesGroupBox->setVisible(false);
}

void NMCGeneralSettings::setNMCLayout()
{
//General settings
auto generalSettingsLabel = new QLabel(QCoreApplication::translate("", "GENERAL_SETTINGS"));
generalSettingsLabel->setStyleSheet("QLabel{font-size: 12px; font-weight: bold;}");
getUi()->generalGroupBox->setTitle("");
getUi()->generalGroupBox->layout()->removeWidget(getUi()->serverNotificationsCheckBox);
getUi()->generalGroupBox->layout()->removeWidget(getUi()->autostartCheckBox);
static_cast<QGridLayout *>(getUi()->generalGroupBox->layout())->addWidget(generalSettingsLabel, 0, 0);
static_cast<QGridLayout *>(getUi()->generalGroupBox->layout())->addWidget(getUi()->autostartCheckBox, 1, 0);
static_cast<QGridLayout *>(getUi()->generalGroupBox->layout())->addWidget(getUi()->serverNotificationsCheckBox, 2, 0);
getUi()->generalGroupBox->setStyleSheet("QGroupBox { background-color: white; border-radius: 4px; }");
getUi()->autostartCheckBox->setFocusPolicy(Qt::FocusPolicy::NoFocus);
getUi()->serverNotificationsCheckBox->setFocusPolicy(Qt::FocusPolicy::NoFocus);

//Advanced settings
auto advancedSettingsLabel = new QLabel(QCoreApplication::translate("", "ADVANCED_SETTINGS"));
advancedSettingsLabel->setStyleSheet("QLabel{font-size: 12px; font-weight: bold;}");
QGroupBox *advancedSettingsBox = new QGroupBox(this);
advancedSettingsBox->setTitle("");
advancedSettingsBox->setLayout(new QVBoxLayout);
advancedSettingsBox->layout()->setContentsMargins(12,12,12,12); //Like in Nextcloud .ui file
advancedSettingsBox->layout()->setSpacing(8);
advancedSettingsBox->setStyleSheet("QGroupBox { background-color: white; border-radius: 4px; }");

getUi()->horizontalLayout_10->removeWidget(getUi()->showInExplorerNavigationPaneCheckBox);
getUi()->horizontalLayout->removeWidget(getUi()->moveFilesToTrashCheckBox);
getUi()->horizontalLayout_4->removeWidget(getUi()->ignoredFilesButton);

getUi()->ignoredFilesButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
getUi()->ignoredFilesButton->setFocusPolicy(Qt::NoFocus);

advancedSettingsBox->layout()->addWidget(advancedSettingsLabel);
advancedSettingsBox->layout()->addWidget(getUi()->showInExplorerNavigationPaneCheckBox);
advancedSettingsBox->layout()->addWidget(getUi()->moveFilesToTrashCheckBox);
advancedSettingsBox->layout()->addWidget(getUi()->ignoredFilesButton);
getUi()->showInExplorerNavigationPaneCheckBox->setFocusPolicy(Qt::FocusPolicy::NoFocus);
getUi()->moveFilesToTrashCheckBox->setFocusPolicy(Qt::FocusPolicy::NoFocus);

getUi()->gridLayout_3->addWidget(advancedSettingsBox, 2, 0);

//Datenschutz
auto updatesLabel = new QLabel(QCoreApplication::translate("", "UPDATES_SETTINGS"));
updatesLabel->setStyleSheet("QLabel{font-size: 12px; font-weight: bold;}");

QGroupBox *dataProtectionBox = new QGroupBox(this);
dataProtectionBox->setTitle("");
dataProtectionBox->setLayout(new QVBoxLayout);
dataProtectionBox->layout()->setContentsMargins(12,12,12,12); //Like in Nextcloud .ui file
dataProtectionBox->layout()->setSpacing(8);
dataProtectionBox->setStyleSheet("QGroupBox { background-color: white; border-radius: 4px; }");

auto *dataAnalysisCheckBox = new QCheckBox(this);
dataAnalysisCheckBox->setText(QCoreApplication::translate("", "DATA_ANALYSIS"));
dataAnalysisCheckBox->setFocusPolicy(Qt::FocusPolicy::NoFocus);
getUi()->autoCheckForUpdatesCheckBox->setFocusPolicy(Qt::FocusPolicy::NoFocus);

dataProtectionBox->layout()->addWidget(updatesLabel);
dataProtectionBox->layout()->addWidget(getUi()->autoCheckForUpdatesCheckBox);
dataProtectionBox->layout()->addWidget(dataAnalysisCheckBox);

connect(dataAnalysisCheckBox, &QAbstractButton::toggled, this, [](bool toggle){
NMCConfigFile cfgFile;
cfgFile.setTransferUsageData(toggle, QString());
});
NMCConfigFile cfgFile;
dataAnalysisCheckBox->setChecked(cfgFile.transferUsageData());

dataProtectionBox->layout()->addItem(new QSpacerItem(1,8,QSizePolicy::Fixed,QSizePolicy::Fixed));

auto *dataAnalysisImpressum = new QLabel(this);
dataAnalysisImpressum->setText(QString("<a href=\"https://www.telekom.de/impressum/\"><span style=\"color:#ea0a8e\">%1</span></a>").arg(QCoreApplication::translate("", "IMPRESSUM")));
dataAnalysisImpressum->setTextFormat(Qt::RichText);
dataAnalysisImpressum->setTextInteractionFlags(Qt::TextBrowserInteraction);
dataAnalysisImpressum->setOpenExternalLinks(true);
dataAnalysisImpressum->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
dataAnalysisImpressum->setStyleSheet("font-size: 13px");
dataProtectionBox->layout()->addWidget(dataAnalysisImpressum);

auto *dataAnalysisData = new QLabel(this);
dataAnalysisData->setText(QString("<a href=\"https://static.magentacloud.de/privacy/datenschutzhinweise_software.pdf\"><span style=\"color:#ea0a8e\">%1</span></a>").arg(QCoreApplication::translate("", "DATA_PROTECTION")));
dataAnalysisData->setTextFormat(Qt::RichText);
dataAnalysisData->setTextInteractionFlags(Qt::TextBrowserInteraction);
dataAnalysisData->setOpenExternalLinks(true);
dataAnalysisData->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
dataAnalysisData->setStyleSheet("font-size: 13px");
dataProtectionBox->layout()->addWidget(dataAnalysisData);

auto *dataAnalysisOpenSource = new QLabel(this);
dataAnalysisOpenSource->setText(QString("<a href=\"https://static.magentacloud.de/licences/windowsdesktop.html\"><span style=\"color:#ea0a8e\">%1</span></a>").arg(QCoreApplication::translate("", "LICENCE")));
dataAnalysisOpenSource->setTextFormat(Qt::RichText);
dataAnalysisOpenSource->setTextInteractionFlags(Qt::TextBrowserInteraction);
dataAnalysisOpenSource->setOpenExternalLinks(true);
dataAnalysisOpenSource->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
dataAnalysisOpenSource->setStyleSheet("font-size: 13px");
dataProtectionBox->layout()->addWidget(dataAnalysisOpenSource);

auto *dataAnalysisFurtherInfo = new QLabel(this);
dataAnalysisFurtherInfo->setText(QString("<a href=\"https://cloud.telekom-dienste.de/hilfe\"><span style=\"color:#ea0a8e\">%1</span></a>").arg(QCoreApplication::translate("", "FURTHER_INFO")));
dataAnalysisFurtherInfo->setTextFormat(Qt::RichText);
dataAnalysisFurtherInfo->setTextInteractionFlags(Qt::TextBrowserInteraction);
dataAnalysisFurtherInfo->setOpenExternalLinks(true);
dataAnalysisFurtherInfo->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
dataAnalysisFurtherInfo->setStyleSheet("font-size: 13px");
dataProtectionBox->layout()->addWidget(dataAnalysisFurtherInfo);

dataProtectionBox->layout()->addItem(new QSpacerItem(1,8,QSizePolicy::Fixed,QSizePolicy::Fixed));

auto *currentVersion = new QLabel(this);
currentVersion->setText(Theme::instance()->about());
currentVersion->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
//Todo, set current version
dataProtectionBox->layout()->addWidget(currentVersion);

getUi()->gridLayout_3->addWidget(dataProtectionBox, 3, 0);

auto *vExpandSpacer = new QSpacerItem(1,1,QSizePolicy::Fixed,QSizePolicy::Expanding);
getUi()->gridLayout_3->layout()->addItem(vExpandSpacer);
}

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

#ifndef MIRALL_GENERALSETTINGSMAGENTA_H
#define MIRALL_GENERALSETTINGSMAGENTA_H

#include "generalsettings.h"

namespace OCC {

/**
* @brief The NMCGeneralSettings class
*
* This class represents the Magenta-specific implementation of general settings
* for a graphical user interface. It inherits from the base class GeneralSettings.
*
* @ingroup gui
*/
class NMCGeneralSettings : public GeneralSettings
{
Q_OBJECT

public:
/**
* @brief Constructor for NMCGeneralSettings
*
* Creates an instance of NMCGeneralSettings with the specified parent widget.
*
* @param parent The parent widget (default is nullptr).
*/
explicit NMCGeneralSettings(QWidget *parent = nullptr);

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

protected:
/**
* @brief Set default settings
*
* Sets the default values for Magenta-specific general settings.
*/
void setDefaultSettings();

/**
* @brief Set layout
*
* Sets the layout for the Magenta-specific general settings user interface.
*/
void setNMCLayout();
};

} // namespace OCC
#endif // MIRALL_GENERALSETTINGSMAGENTA_H
4 changes: 2 additions & 2 deletions src/gui/settingsdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

#include "folderman.h"
#include "theme.h"
#include "generalsettings.h"
#include "nmcgui/nmcgeneralsettings.h"
#include "networksettings.h"
#include "accountsettings.h"
#include "configfile.h"
Expand Down Expand Up @@ -120,7 +120,7 @@ SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent)
QAction *generalAction = createColorAwareAction(QLatin1String(":/client/theme/settings.svg"), tr("General"));
_actionGroup->addAction(generalAction);
_toolBar->addAction(generalAction);
auto *generalSettings = new GeneralSettings;
auto *generalSettings = new NMCGeneralSettings;
_ui->stack->addWidget(generalSettings);

// Connect styleChanged events to our widgets, so they can adapt (Dark-/Light-Mode switching)
Expand Down
4 changes: 4 additions & 0 deletions src/libsync/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,10 @@ set(libsync_SRCS
caseclashconflictsolver.cpp
)

file(GLOB NMC_FILES "nmclibsync/*")
set(NMC_SRCS ${NMC_FILES})
list(APPEND libsync_SRCS ${NMC_SRCS})

if (WIN32)
# to fix warnings from ntstatus.h
add_definitions(-DUMDF_USING_NTSTATUS)
Expand Down
2 changes: 1 addition & 1 deletion src/libsync/configfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ bool ConfigFile::setConfDir(const QString &value)
bool ConfigFile::optionalServerNotifications() const
{
QSettings settings(configFile(), QSettings::IniFormat);
return settings.value(QLatin1String(optionalServerNotificationsC), true).toBool();
return settings.value(QLatin1String(optionalServerNotificationsC), false).toBool();
}

bool ConfigFile::showCallNotifications() const
Expand Down
4 changes: 2 additions & 2 deletions src/libsync/configfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,10 @@ class OWNCLOUDSYNC_EXPORT ConfigFile
[[nodiscard]] QVariant retrieveData(const QString &group, const QString &key) const;
void removeData(const QString &group, const QString &key);
[[nodiscard]] bool dataExists(const QString &group, const QString &key) const;
[[nodiscard]] QVariant getValue(const QString &param, const QString &group = QString(),
const QVariant &defaultValue = QVariant()) const;

private:
[[nodiscard]] QVariant getValue(const QString &param, const QString &group = QString(),
const QVariant &defaultValue = QVariant()) const;
void setValue(const QString &key, const QVariant &value);

[[nodiscard]] QString keychainProxyPasswordKey() const;
Expand Down
Loading