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
0 commit comments