Skip to content

Commit c22ef90

Browse files
committed
Merge #412 [stable-4.0] [master] 2003-General_Settings_Dialog
2 parents 271776a + 77ed5e8 commit c22ef90

File tree

8 files changed

+385
-3
lines changed

8 files changed

+385
-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: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
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+
//Advanced settings
40+
getUi()->newFolderLimitCheckBox->setCheckState(Qt::Unchecked);
41+
//Info settings
42+
getUi()->aboutAndUpdatesGroupBox->setTitle(tr("Update"));
43+
//Hide unsupported settings
44+
//General settings
45+
getUi()->monoIconsCheckBox->setVisible(false);
46+
getUi()->callNotificationsCheckBox->setVisible(false);
47+
//Advanced settings
48+
getUi()->groupBox->setVisible(false);
49+
//Info settings
50+
getUi()->aboutAndUpdatesGroupBox->setVisible(false);
51+
}
52+
53+
void NMCGeneralSettings::setNMCLayout()
54+
{
55+
// General settings
56+
auto generalSettingsLabel = new QLabel(QCoreApplication::translate("", "GENERAL_SETTINGS"));
57+
generalSettingsLabel->setStyleSheet("font-size: 12px; font-weight: bold;");
58+
getUi()->chatNotificationsCheckBox->hide();
59+
getUi()->generalGroupBox->layout()->removeWidget(getUi()->chatNotificationsCheckBox);
60+
getUi()->generalGroupBox->layout()->removeWidget(getUi()->serverNotificationsCheckBox);
61+
getUi()->generalGroupBox->layout()->removeWidget(getUi()->autostartCheckBox);
62+
getUi()->generalGroupBox->setTitle({});
63+
static_cast<QGridLayout *>(getUi()->generalGroupBox->layout())->addWidget(generalSettingsLabel, 0, 0);
64+
static_cast<QGridLayout *>(getUi()->generalGroupBox->layout())->addWidget(getUi()->autostartCheckBox, 1, 0);
65+
static_cast<QGridLayout *>(getUi()->generalGroupBox->layout())->addWidget(getUi()->serverNotificationsCheckBox, 2, 0);
66+
getUi()->generalGroupBox->layout()->setContentsMargins(16, 16, 16, 16);
67+
getUi()->generalGroupBox->layout()->setSpacing(8);
68+
getUi()->generalGroupBox->setStyleSheet("border-radius: 4px;");
69+
getUi()->generalGroupBox->setStyleSheet(getUi()->generalGroupBox->styleSheet());
70+
71+
getUi()->autostartCheckBox->setFocusPolicy(Qt::FocusPolicy::NoFocus);
72+
getUi()->serverNotificationsCheckBox->setFocusPolicy(Qt::FocusPolicy::NoFocus);
73+
74+
// Advanced settings
75+
auto advancedSettingsLabel = new QLabel(QCoreApplication::translate("", "ADVANCED_SETTINGS"));
76+
advancedSettingsLabel->setStyleSheet("font-size: 12px; font-weight: bold;");
77+
QGroupBox *advancedSettingsBox = new QGroupBox(this);
78+
advancedSettingsBox->setTitle("");
79+
advancedSettingsBox->setLayout(new QVBoxLayout);
80+
advancedSettingsBox->layout()->setContentsMargins(16, 16, 16, 16);
81+
advancedSettingsBox->layout()->setSpacing(8);
82+
advancedSettingsBox->setStyleSheet("border-radius: 4px;");
83+
84+
getUi()->horizontalLayout_10->removeWidget(getUi()->showInExplorerNavigationPaneCheckBox);
85+
getUi()->horizontalLayout->removeWidget(getUi()->moveFilesToTrashCheckBox);
86+
getUi()->horizontalLayout_4->removeWidget(getUi()->ignoredFilesButton);
87+
88+
getUi()->ignoredFilesButton->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
89+
getUi()->ignoredFilesButton->setFocusPolicy(Qt::NoFocus);
90+
getUi()->ignoredFilesButton->setStyleSheet(R"(
91+
QPushButton {
92+
min-height: 32px;
93+
min-width: 200px;
94+
border: 1px solid black;
95+
color: black;
96+
background-color: #ededed;
97+
font-size: 13px;
98+
border-radius: 4px;
99+
}
100+
QPushButton:hover {
101+
background-color: white;
102+
}
103+
)");
104+
105+
advancedSettingsBox->layout()->addWidget(advancedSettingsLabel);
106+
advancedSettingsBox->layout()->addWidget(getUi()->showInExplorerNavigationPaneCheckBox);
107+
advancedSettingsBox->layout()->addWidget(getUi()->moveFilesToTrashCheckBox);
108+
advancedSettingsBox->layout()->addItem(new QSpacerItem(1, 8, QSizePolicy::Fixed, QSizePolicy::Fixed));
109+
advancedSettingsBox->layout()->addWidget(getUi()->ignoredFilesButton);
110+
getUi()->showInExplorerNavigationPaneCheckBox->setFocusPolicy(Qt::FocusPolicy::NoFocus);
111+
getUi()->moveFilesToTrashCheckBox->setFocusPolicy(Qt::FocusPolicy::NoFocus);
112+
113+
getUi()->gridLayout_3->addWidget(advancedSettingsBox, 2, 0);
114+
115+
//Datenschutz
116+
auto updatesLabel = new QLabel(QCoreApplication::translate("", "UPDATES_SETTINGS"));
117+
updatesLabel->setStyleSheet("font-size: 12px; font-weight: bold;");
118+
QGroupBox *dataProtectionBox = new QGroupBox(this);
119+
dataProtectionBox->setTitle("");
120+
dataProtectionBox->setLayout(new QVBoxLayout);
121+
dataProtectionBox->layout()->setContentsMargins(16, 16, 16, 16);
122+
dataProtectionBox->layout()->setSpacing(8);
123+
dataProtectionBox->setStyleSheet("border-radius: 4px;");
124+
dataProtectionBox->setStyleSheet(dataProtectionBox->styleSheet());
125+
126+
auto *dataAnalysisCheckBox = new QCheckBox(this);
127+
dataAnalysisCheckBox->setText(QCoreApplication::translate("", "DATA_ANALYSIS"));
128+
dataAnalysisCheckBox->setFocusPolicy(Qt::FocusPolicy::NoFocus);
129+
getUi()->autoCheckForUpdatesCheckBox->setFocusPolicy(Qt::FocusPolicy::NoFocus);
130+
131+
dataProtectionBox->layout()->addWidget(updatesLabel);
132+
dataProtectionBox->layout()->addWidget(getUi()->autoCheckForUpdatesCheckBox);
133+
dataProtectionBox->layout()->addWidget(dataAnalysisCheckBox);
134+
135+
connect(dataAnalysisCheckBox, &QAbstractButton::toggled, this, [](bool toggle){
136+
NMCConfigFile cfgFile;
137+
cfgFile.setTransferUsageData(toggle, QString());
138+
});
139+
NMCConfigFile cfgFile;
140+
dataAnalysisCheckBox->setChecked(cfgFile.transferUsageData());
141+
142+
dataProtectionBox->layout()->addItem(new QSpacerItem(1,8,QSizePolicy::Fixed,QSizePolicy::Fixed));
143+
144+
auto *dataAnalysisImpressum = new QLabel(this);
145+
dataAnalysisImpressum->setText(QString("<a href=\"https://www.telekom.de/impressum/\"><span style=\"color:#2238df\">%1</span></a>").arg(QCoreApplication::translate("", "IMPRESSUM")));
146+
dataAnalysisImpressum->setTextFormat(Qt::RichText);
147+
dataAnalysisImpressum->setTextInteractionFlags(Qt::TextBrowserInteraction);
148+
dataAnalysisImpressum->setOpenExternalLinks(true);
149+
dataAnalysisImpressum->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
150+
dataAnalysisImpressum->setStyleSheet("font-size: 13px");
151+
dataProtectionBox->layout()->addWidget(dataAnalysisImpressum);
152+
153+
auto *dataAnalysisData = new QLabel(this);
154+
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")));
155+
dataAnalysisData->setTextFormat(Qt::RichText);
156+
dataAnalysisData->setTextInteractionFlags(Qt::TextBrowserInteraction);
157+
dataAnalysisData->setOpenExternalLinks(true);
158+
dataAnalysisData->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
159+
dataAnalysisData->setStyleSheet("font-size: 13px");
160+
dataProtectionBox->layout()->addWidget(dataAnalysisData);
161+
162+
auto *dataAnalysisOpenSource = new QLabel(this);
163+
dataAnalysisOpenSource->setText(QString("<a href=\"https://static.magentacloud.de/licences/windowsdesktop.html\"><span style=\"color:#2238df\">%1</span></a>").arg(QCoreApplication::translate("", "LICENCE")));
164+
dataAnalysisOpenSource->setTextFormat(Qt::RichText);
165+
dataAnalysisOpenSource->setTextInteractionFlags(Qt::TextBrowserInteraction);
166+
dataAnalysisOpenSource->setOpenExternalLinks(true);
167+
dataAnalysisOpenSource->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
168+
dataAnalysisOpenSource->setStyleSheet("font-size: 13px");
169+
dataProtectionBox->layout()->addWidget(dataAnalysisOpenSource);
170+
171+
auto *dataAnalysisFurtherInfo = new QLabel(this);
172+
dataAnalysisFurtherInfo->setText(QString("<a href=\"https://cloud.telekom-dienste.de/hilfe\"><span style=\"color:#2238df\">%1</span></a>").arg(QCoreApplication::translate("", "FURTHER_INFO")));
173+
dataAnalysisFurtherInfo->setTextFormat(Qt::RichText);
174+
dataAnalysisFurtherInfo->setTextInteractionFlags(Qt::TextBrowserInteraction);
175+
dataAnalysisFurtherInfo->setOpenExternalLinks(true);
176+
dataAnalysisFurtherInfo->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
177+
dataAnalysisFurtherInfo->setStyleSheet("font-size: 13px");
178+
dataProtectionBox->layout()->addWidget(dataAnalysisFurtherInfo);
179+
180+
dataProtectionBox->layout()->addItem(new QSpacerItem(1,8,QSizePolicy::Fixed,QSizePolicy::Fixed));
181+
182+
auto *currentVersion = new QLabel(this);
183+
currentVersion->setText(Theme::instance()->about());
184+
currentVersion->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
185+
//Todo, set current version
186+
dataProtectionBox->layout()->addWidget(currentVersion);
187+
188+
getUi()->gridLayout_3->addWidget(dataProtectionBox, 3, 0);
189+
190+
auto *vExpandSpacer = new QSpacerItem(1,1,QSizePolicy::Fixed,QSizePolicy::Expanding);
191+
getUi()->gridLayout_3->layout()->addItem(vExpandSpacer);
192+
}
193+
194+
} // 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)