Skip to content

Commit e8140b2

Browse files
committed
Merge #412 [stable-4.0] [master] 2003-General_Settings_Dialog
2 parents 85fe073 + e9a9a38 commit e8140b2

File tree

8 files changed

+388
-3
lines changed

8 files changed

+388
-3
lines changed

src/gui/generalsettings.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ class GeneralSettings : public QWidget
3434
~GeneralSettings() override;
3535
[[nodiscard]] QSize sizeHint() const override;
3636

37+
protected:
38+
Ui::GeneralSettings *getUi() const
39+
{
40+
return _ui;
41+
}
42+
3743
public slots:
3844
void slotStyleChanged();
3945
#if defined(BUILD_UPDATER)
Lines changed: 197 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,197 @@
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 "nmcgeneralsettings.h"
16+
#include "generalsettings.h"
17+
#include "nmclibsync/nmcconfigfile.h"
18+
#include "ui_generalsettings.h"
19+
#include "theme.h"
20+
21+
22+
namespace OCC {
23+
24+
NMCGeneralSettings::NMCGeneralSettings(QWidget *parent)
25+
: GeneralSettings(parent)
26+
{
27+
setDefaultSettings();
28+
setNMCLayout();
29+
}
30+
31+
void NMCGeneralSettings::setDefaultSettings()
32+
{
33+
//Set default settings
34+
//General settings
35+
getUi()->autostartCheckBox->setCheckState(Qt::Checked);
36+
getUi()->monoIconsCheckBox->setCheckState(Qt::Unchecked);
37+
getUi()->serverNotificationsCheckBox->setCheckState(Qt::Unchecked);
38+
getUi()->callNotificationsCheckBox->setCheckState(Qt::Unchecked);
39+
getUi()->quotaWarningNotificationsCheckBox->setCheckState(Qt::Unchecked);
40+
//Advanced settings
41+
getUi()->newFolderLimitCheckBox->setCheckState(Qt::Unchecked);
42+
//Info settings
43+
getUi()->aboutAndUpdatesGroupBox->setTitle(tr("Update"));
44+
//Hide unsupported settings
45+
//General settings
46+
getUi()->monoIconsCheckBox->setVisible(false);
47+
getUi()->callNotificationsCheckBox->setVisible(false);
48+
getUi()->quotaWarningNotificationsCheckBox->setVisible(false);
49+
//Advanced settings
50+
getUi()->groupBox->setVisible(false);
51+
//Info settings
52+
getUi()->aboutAndUpdatesGroupBox->setVisible(false);
53+
}
54+
55+
void NMCGeneralSettings::setNMCLayout()
56+
{
57+
// General settings
58+
auto generalSettingsLabel = new QLabel(QCoreApplication::translate("", "GENERAL_SETTINGS"));
59+
generalSettingsLabel->setStyleSheet("font-size: 12px; font-weight: bold;");
60+
getUi()->chatNotificationsCheckBox->hide();
61+
getUi()->generalGroupBox->layout()->removeWidget(getUi()->chatNotificationsCheckBox);
62+
getUi()->generalGroupBox->layout()->removeWidget(getUi()->serverNotificationsCheckBox);
63+
getUi()->generalGroupBox->layout()->removeWidget(getUi()->autostartCheckBox);
64+
getUi()->generalGroupBox->layout()->removeWidget(getUi()->quotaWarningNotificationsCheckBox);
65+
getUi()->generalGroupBox->setTitle({});
66+
static_cast<QGridLayout *>(getUi()->generalGroupBox->layout())->addWidget(generalSettingsLabel, 0, 0);
67+
static_cast<QGridLayout *>(getUi()->generalGroupBox->layout())->addWidget(getUi()->autostartCheckBox, 1, 0);
68+
static_cast<QGridLayout *>(getUi()->generalGroupBox->layout())->addWidget(getUi()->serverNotificationsCheckBox, 2, 0);
69+
getUi()->generalGroupBox->layout()->setContentsMargins(16, 16, 16, 16);
70+
getUi()->generalGroupBox->layout()->setSpacing(8);
71+
getUi()->generalGroupBox->setStyleSheet("border-radius: 4px;");
72+
getUi()->generalGroupBox->setStyleSheet(getUi()->generalGroupBox->styleSheet());
73+
74+
getUi()->autostartCheckBox->setFocusPolicy(Qt::FocusPolicy::NoFocus);
75+
getUi()->serverNotificationsCheckBox->setFocusPolicy(Qt::FocusPolicy::NoFocus);
76+
77+
// Advanced settings
78+
auto advancedSettingsLabel = new QLabel(QCoreApplication::translate("", "ADVANCED_SETTINGS"));
79+
advancedSettingsLabel->setStyleSheet("font-size: 12px; font-weight: bold;");
80+
QGroupBox *advancedSettingsBox = new QGroupBox(this);
81+
advancedSettingsBox->setTitle("");
82+
advancedSettingsBox->setLayout(new QVBoxLayout);
83+
advancedSettingsBox->layout()->setContentsMargins(16, 16, 16, 16);
84+
advancedSettingsBox->layout()->setSpacing(8);
85+
advancedSettingsBox->setStyleSheet("border-radius: 4px;");
86+
87+
getUi()->horizontalLayout_10->removeWidget(getUi()->showInExplorerNavigationPaneCheckBox);
88+
getUi()->horizontalLayout->removeWidget(getUi()->moveFilesToTrashCheckBox);
89+
getUi()->horizontalLayout_4->removeWidget(getUi()->ignoredFilesButton);
90+
91+
getUi()->ignoredFilesButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
92+
getUi()->ignoredFilesButton->setFocusPolicy(Qt::NoFocus);
93+
getUi()->ignoredFilesButton->setStyleSheet(R"(
94+
QPushButton {
95+
min-height: 32px;
96+
min-width: 200px;
97+
border: 1px solid black;
98+
color: black;
99+
background-color: #ededed;
100+
font-size: 13px;
101+
border-radius: 4px;
102+
}
103+
QPushButton:hover {
104+
background-color: white;
105+
}
106+
)");
107+
108+
advancedSettingsBox->layout()->addWidget(advancedSettingsLabel);
109+
advancedSettingsBox->layout()->addWidget(getUi()->showInExplorerNavigationPaneCheckBox);
110+
advancedSettingsBox->layout()->addWidget(getUi()->moveFilesToTrashCheckBox);
111+
advancedSettingsBox->layout()->addItem(new QSpacerItem(1, 8, QSizePolicy::Fixed, QSizePolicy::Fixed));
112+
advancedSettingsBox->layout()->addWidget(getUi()->ignoredFilesButton);
113+
getUi()->showInExplorerNavigationPaneCheckBox->setFocusPolicy(Qt::FocusPolicy::NoFocus);
114+
getUi()->moveFilesToTrashCheckBox->setFocusPolicy(Qt::FocusPolicy::NoFocus);
115+
116+
getUi()->gridLayout_3->addWidget(advancedSettingsBox, 2, 0);
117+
118+
//Datenschutz
119+
auto updatesLabel = new QLabel(QCoreApplication::translate("", "UPDATES_SETTINGS"));
120+
updatesLabel->setStyleSheet("font-size: 12px; font-weight: bold;");
121+
QGroupBox *dataProtectionBox = new QGroupBox(this);
122+
dataProtectionBox->setTitle("");
123+
dataProtectionBox->setLayout(new QVBoxLayout);
124+
dataProtectionBox->layout()->setContentsMargins(16, 16, 16, 16);
125+
dataProtectionBox->layout()->setSpacing(8);
126+
dataProtectionBox->setStyleSheet("border-radius: 4px;");
127+
dataProtectionBox->setStyleSheet(dataProtectionBox->styleSheet());
128+
129+
auto *dataAnalysisCheckBox = new QCheckBox(this);
130+
dataAnalysisCheckBox->setText(QCoreApplication::translate("", "DATA_ANALYSIS"));
131+
dataAnalysisCheckBox->setFocusPolicy(Qt::FocusPolicy::NoFocus);
132+
getUi()->autoCheckForUpdatesCheckBox->setFocusPolicy(Qt::FocusPolicy::NoFocus);
133+
134+
dataProtectionBox->layout()->addWidget(updatesLabel);
135+
dataProtectionBox->layout()->addWidget(getUi()->autoCheckForUpdatesCheckBox);
136+
dataProtectionBox->layout()->addWidget(dataAnalysisCheckBox);
137+
138+
connect(dataAnalysisCheckBox, &QAbstractButton::toggled, this, [](bool toggle){
139+
NMCConfigFile cfgFile;
140+
cfgFile.setTransferUsageData(toggle, QString());
141+
});
142+
NMCConfigFile cfgFile;
143+
dataAnalysisCheckBox->setChecked(cfgFile.transferUsageData());
144+
145+
dataProtectionBox->layout()->addItem(new QSpacerItem(1,8,QSizePolicy::Fixed,QSizePolicy::Fixed));
146+
147+
auto *dataAnalysisImpressum = new QLabel(this);
148+
dataAnalysisImpressum->setText(QString("<a href=\"https://www.telekom.de/impressum/\"><span style=\"color:#2238df\">%1</span></a>").arg(QCoreApplication::translate("", "IMPRESSUM")));
149+
dataAnalysisImpressum->setTextFormat(Qt::RichText);
150+
dataAnalysisImpressum->setTextInteractionFlags(Qt::TextBrowserInteraction);
151+
dataAnalysisImpressum->setOpenExternalLinks(true);
152+
dataAnalysisImpressum->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
153+
dataAnalysisImpressum->setStyleSheet("font-size: 13px");
154+
dataProtectionBox->layout()->addWidget(dataAnalysisImpressum);
155+
156+
auto *dataAnalysisData = new QLabel(this);
157+
dataAnalysisData->setText(QString("<a href=\"https://static.magentacloud.de/privacy/datenschutzhinweise_software.pdf\"><span style=\"color:#2238df\">%1</span></a>").arg(QCoreApplication::translate("", "DATA_PROTECTION")));
158+
dataAnalysisData->setTextFormat(Qt::RichText);
159+
dataAnalysisData->setTextInteractionFlags(Qt::TextBrowserInteraction);
160+
dataAnalysisData->setOpenExternalLinks(true);
161+
dataAnalysisData->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
162+
dataAnalysisData->setStyleSheet("font-size: 13px");
163+
dataProtectionBox->layout()->addWidget(dataAnalysisData);
164+
165+
auto *dataAnalysisOpenSource = new QLabel(this);
166+
dataAnalysisOpenSource->setText(QString("<a href=\"https://static.magentacloud.de/licences/windowsdesktop.html\"><span style=\"color:#2238df\">%1</span></a>").arg(QCoreApplication::translate("", "LICENCE")));
167+
dataAnalysisOpenSource->setTextFormat(Qt::RichText);
168+
dataAnalysisOpenSource->setTextInteractionFlags(Qt::TextBrowserInteraction);
169+
dataAnalysisOpenSource->setOpenExternalLinks(true);
170+
dataAnalysisOpenSource->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
171+
dataAnalysisOpenSource->setStyleSheet("font-size: 13px");
172+
dataProtectionBox->layout()->addWidget(dataAnalysisOpenSource);
173+
174+
auto *dataAnalysisFurtherInfo = new QLabel(this);
175+
dataAnalysisFurtherInfo->setText(QString("<a href=\"https://cloud.telekom-dienste.de/hilfe\"><span style=\"color:#2238df\">%1</span></a>").arg(QCoreApplication::translate("", "FURTHER_INFO")));
176+
dataAnalysisFurtherInfo->setTextFormat(Qt::RichText);
177+
dataAnalysisFurtherInfo->setTextInteractionFlags(Qt::TextBrowserInteraction);
178+
dataAnalysisFurtherInfo->setOpenExternalLinks(true);
179+
dataAnalysisFurtherInfo->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
180+
dataAnalysisFurtherInfo->setStyleSheet("font-size: 13px");
181+
dataProtectionBox->layout()->addWidget(dataAnalysisFurtherInfo);
182+
183+
dataProtectionBox->layout()->addItem(new QSpacerItem(1,8,QSizePolicy::Fixed,QSizePolicy::Fixed));
184+
185+
auto *currentVersion = new QLabel(this);
186+
currentVersion->setText(Theme::instance()->about());
187+
currentVersion->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
188+
//Todo, set current version
189+
dataProtectionBox->layout()->addWidget(currentVersion);
190+
191+
getUi()->gridLayout_3->addWidget(dataProtectionBox, 3, 0);
192+
193+
auto *vExpandSpacer = new QSpacerItem(1,1,QSizePolicy::Fixed,QSizePolicy::Expanding);
194+
getUi()->gridLayout_3->layout()->addItem(vExpandSpacer);
195+
}
196+
197+
} // namespace OCC
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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+
#ifndef MIRALL_GENERALSETTINGSMAGENTA_H
16+
#define MIRALL_GENERALSETTINGSMAGENTA_H
17+
18+
#include "generalsettings.h"
19+
20+
namespace OCC {
21+
22+
/**
23+
* @brief The NMCGeneralSettings class
24+
*
25+
* This class represents the Magenta-specific implementation of general settings
26+
* for a graphical user interface. It inherits from the base class GeneralSettings.
27+
*
28+
* @ingroup gui
29+
*/
30+
class NMCGeneralSettings : public GeneralSettings
31+
{
32+
Q_OBJECT
33+
34+
public:
35+
/**
36+
* @brief Constructor for NMCGeneralSettings
37+
*
38+
* Creates an instance of NMCGeneralSettings with the specified parent widget.
39+
*
40+
* @param parent The parent widget (default is nullptr).
41+
*/
42+
explicit NMCGeneralSettings(QWidget *parent = nullptr);
43+
44+
/**
45+
* @brief Destructor for NMCGeneralSettings
46+
*/
47+
~NMCGeneralSettings() = default;
48+
49+
protected:
50+
/**
51+
* @brief Set default settings
52+
*
53+
* Sets the default values for Magenta-specific general settings.
54+
*/
55+
void setDefaultSettings();
56+
57+
/**
58+
* @brief Set layout
59+
*
60+
* Sets the layout for the Magenta-specific general settings user interface.
61+
*/
62+
void setNMCLayout();
63+
};
64+
65+
} // namespace OCC
66+
#endif // MIRALL_GENERALSETTINGSMAGENTA_H

src/gui/settingsdialog.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "folderman.h"
1111
#include "theme.h"
1212
#include "generalsettings.h"
13+
#include "nmcgui/nmcgeneralsettings.h"
1314
#include "networksettings.h"
1415
#include "accountsettings.h"
1516
#include "configfile.h"
@@ -114,7 +115,7 @@ SettingsDialog::SettingsDialog(ownCloudGui *gui, QWidget *parent)
114115
QAction *generalAction = createColorAwareAction(QLatin1String(":/client/theme/settings.svg"), tr("General"));
115116
_actionGroup->addAction(generalAction);
116117
_toolBar->addAction(generalAction);
117-
auto *generalSettings = new GeneralSettings;
118+
auto *generalSettings = new NMCGeneralSettings;
118119
_ui->stack->addWidget(generalSettings);
119120

120121
// Connect styleChanged events to our widgets, so they can adapt (Dark-/Light-Mode switching)

src/libsync/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,10 @@ set(libsync_SRCS
164164
caseclashconflictsolver.cpp
165165
)
166166

167+
file(GLOB NMC_FILES "nmclibsync/*")
168+
set(NMC_SRCS ${NMC_FILES})
169+
list(APPEND libsync_SRCS ${NMC_SRCS})
170+
167171
if (WIN32)
168172
# to fix warnings from ntstatus.h
169173
add_definitions(-DUMDF_USING_NTSTATUS)

src/libsync/configfile.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,10 +276,10 @@ class OWNCLOUDSYNC_EXPORT ConfigFile
276276
[[nodiscard]] QVariant retrieveData(const QString &group, const QString &key) const;
277277
void removeData(const QString &group, const QString &key);
278278
[[nodiscard]] bool dataExists(const QString &group, const QString &key) const;
279-
280-
private:
281279
[[nodiscard]] QVariant getValue(const QString &param, const QString &group = QString(),
282280
const QVariant &defaultValue = QVariant()) const;
281+
282+
private:
283283
void setValue(const QString &key, const QVariant &value);
284284

285285
[[nodiscard]] QString keychainProxyPasswordKey() const;
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
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 "nmcconfigfile.h"
16+
17+
namespace OCC {
18+
19+
bool NMCConfigFile::transferUsageData(const QString &connection) const
20+
{
21+
QString con(connection);
22+
if (connection.isEmpty())
23+
{
24+
con = defaultConnection();
25+
}
26+
QVariant fallback = getValue(m_transferUsageData, con, false);
27+
fallback = getValue(m_transferUsageData, QString(), fallback);
28+
29+
QVariant value = getPolicySetting(m_transferUsageData, fallback);
30+
return value.toBool();
31+
}
32+
33+
void NMCConfigFile::setTransferUsageData(bool usageData, const QString &connection)
34+
{
35+
QString con(connection);
36+
if (connection.isEmpty())
37+
{
38+
con = defaultConnection();
39+
}
40+
QSettings settings(configFile(), QSettings::IniFormat);
41+
settings.beginGroup(con);
42+
43+
settings.setValue(m_transferUsageData, QVariant(usageData));
44+
settings.sync();
45+
}
46+
47+
} // namespace OCC

0 commit comments

Comments
 (0)