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: 13px; 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+
72+ getUi ()->autostartCheckBox ->setFocusPolicy (Qt::FocusPolicy::NoFocus);
73+ getUi ()->serverNotificationsCheckBox ->setFocusPolicy (Qt::FocusPolicy::NoFocus);
74+
75+ // Advanced settings
76+ auto advancedSettingsLabel = new QLabel (QCoreApplication::translate (" " , " ADVANCED_SETTINGS" ));
77+ advancedSettingsLabel->setStyleSheet (" font-size: 13px; font-weight: bold;" );
78+ QGroupBox *advancedSettingsBox = new QGroupBox (this );
79+ advancedSettingsBox->setTitle (" " );
80+ advancedSettingsBox->setLayout (new QVBoxLayout);
81+ advancedSettingsBox->layout ()->setContentsMargins (16 , 16 , 16 , 16 );
82+ advancedSettingsBox->layout ()->setSpacing (8 );
83+
84+ // Entferne Widgets aus alten Layouts, falls notwendig
85+ getUi ()->horizontalLayout_10 ->removeWidget (getUi ()->showInExplorerNavigationPaneCheckBox );
86+ getUi ()->horizontalLayout ->removeWidget (getUi ()->moveFilesToTrashCheckBox );
87+ getUi ()->horizontalLayout_3 ->removeWidget (getUi ()->newFolderLimitCheckBox );
88+ getUi ()->horizontalLayout_3 ->removeWidget (getUi ()->newFolderLimitSpinBox );
89+ getUi ()->horizontalLayout_3 ->removeWidget (getUi ()->label );
90+ getUi ()->horizontalLayout_4 ->removeWidget (getUi ()->ignoredFilesButton );
91+
92+ getUi ()->ignoredFilesButton ->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
93+ getUi ()->ignoredFilesButton ->setFocusPolicy (Qt::NoFocus);
94+ getUi ()->ignoredFilesButton ->setStyleSheet (R"(
95+ QPushButton {
96+ min-height: 32px;
97+ min-width: 200px;
98+ border: 1px solid black;
99+ color: black;
100+ background-color: #ededed;
101+ font-size: 13px;
102+ border-radius: 4px;
103+ }
104+ QPushButton:hover {
105+ background-color: white;
106+ }
107+ )" );
108+
109+ advancedSettingsBox->layout ()->addWidget (advancedSettingsLabel);
110+ advancedSettingsBox->layout ()->addWidget (getUi ()->showInExplorerNavigationPaneCheckBox );
111+ advancedSettingsBox->layout ()->addWidget (getUi ()->moveFilesToTrashCheckBox );
112+
113+ QHBoxLayout *folderLimitLayout = new QHBoxLayout;
114+ folderLimitLayout->setContentsMargins (0 ,0 ,0 ,0 );
115+ folderLimitLayout->setSpacing (8 );
116+ folderLimitLayout->addWidget (getUi ()->newFolderLimitCheckBox );
117+ folderLimitLayout->addWidget (getUi ()->newFolderLimitSpinBox );
118+ getUi ()->newFolderLimitSpinBox ->setFixedWidth (80 );
119+ getUi ()->newFolderLimitSpinBox ->setFocusPolicy (Qt::NoFocus);
120+ folderLimitLayout->addWidget (getUi ()->label );
121+ getUi ()->label ->setSizePolicy (QSizePolicy::Fixed, QSizePolicy::Fixed);
122+ folderLimitLayout->addStretch ();
123+
124+ QWidget *folderLimitBox = new QWidget (this );
125+ folderLimitBox->setLayout (folderLimitLayout);
126+ folderLimitBox->setContentsMargins (0 , 0 , 0 , 0 );
127+ folderLimitBox->setSizePolicy (QSizePolicy::Preferred, QSizePolicy::Fixed);
128+
129+ advancedSettingsBox->layout ()->addWidget (folderLimitBox);
130+ advancedSettingsBox->layout ()->addItem (new QSpacerItem (1 , 8 , QSizePolicy::Fixed, QSizePolicy::Fixed));
131+ advancedSettingsBox->layout ()->addWidget (getUi ()->ignoredFilesButton );
132+
133+ getUi ()->showInExplorerNavigationPaneCheckBox ->setFocusPolicy (Qt::FocusPolicy::NoFocus);
134+ getUi ()->moveFilesToTrashCheckBox ->setFocusPolicy (Qt::FocusPolicy::NoFocus);
135+
136+ getUi ()->gridLayout_3 ->addWidget (advancedSettingsBox, 2 , 0 );
137+
138+ // Datenschutz
139+ auto updatesLabel = new QLabel (QCoreApplication::translate (" " , " UPDATES_SETTINGS" ));
140+ updatesLabel->setStyleSheet (" font-size: 13px; font-weight: bold;" );
141+ QGroupBox *dataProtectionBox = new QGroupBox (this );
142+ dataProtectionBox->setTitle (" " );
143+ dataProtectionBox->setLayout (new QVBoxLayout);
144+ dataProtectionBox->layout ()->setContentsMargins (16 , 16 , 16 , 16 );
145+ dataProtectionBox->layout ()->setSpacing (8 );
146+
147+ auto *dataAnalysisCheckBox = new QCheckBox (this );
148+ dataAnalysisCheckBox->setText (QCoreApplication::translate (" " , " DATA_ANALYSIS" ));
149+ dataAnalysisCheckBox->setFocusPolicy (Qt::FocusPolicy::NoFocus);
150+ getUi ()->autoCheckForUpdatesCheckBox ->setFocusPolicy (Qt::FocusPolicy::NoFocus);
151+
152+ dataProtectionBox->layout ()->addWidget (updatesLabel);
153+ dataProtectionBox->layout ()->addWidget (getUi ()->autoCheckForUpdatesCheckBox );
154+ dataProtectionBox->layout ()->addWidget (dataAnalysisCheckBox);
155+
156+ connect (dataAnalysisCheckBox, &QAbstractButton::toggled, this , [](bool toggle){
157+ NMCConfigFile cfgFile;
158+ cfgFile.setTransferUsageData (toggle, QString ());
159+ });
160+ NMCConfigFile cfgFile;
161+ dataAnalysisCheckBox->setChecked (cfgFile.transferUsageData ());
162+
163+ dataProtectionBox->layout ()->addItem (new QSpacerItem (1 ,8 ,QSizePolicy::Fixed,QSizePolicy::Fixed));
164+
165+ auto *dataAnalysisImpressum = new QLabel (this );
166+ dataAnalysisImpressum->setText (QString (" <a href=\" https://www.telekom.de/impressum/\" ><span style=\" color:#2238df\" >%1</span></a>" ).arg (QCoreApplication::translate (" " , " IMPRESSUM" )));
167+ dataAnalysisImpressum->setTextFormat (Qt::RichText);
168+ dataAnalysisImpressum->setTextInteractionFlags (Qt::TextBrowserInteraction);
169+ dataAnalysisImpressum->setOpenExternalLinks (true );
170+ dataAnalysisImpressum->setSizePolicy (QSizePolicy::Preferred, QSizePolicy::Fixed);
171+ dataAnalysisImpressum->setStyleSheet (" font-size: 13px" );
172+ dataProtectionBox->layout ()->addWidget (dataAnalysisImpressum);
173+
174+ auto *dataAnalysisData = new QLabel (this );
175+ 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" )));
176+ dataAnalysisData->setTextFormat (Qt::RichText);
177+ dataAnalysisData->setTextInteractionFlags (Qt::TextBrowserInteraction);
178+ dataAnalysisData->setOpenExternalLinks (true );
179+ dataAnalysisData->setSizePolicy (QSizePolicy::Preferred, QSizePolicy::Fixed);
180+ dataAnalysisData->setStyleSheet (" font-size: 13px" );
181+ dataProtectionBox->layout ()->addWidget (dataAnalysisData);
182+
183+ auto *dataAnalysisOpenSource = new QLabel (this );
184+ dataAnalysisOpenSource->setText (QString (" <a href=\" https://static.magentacloud.de/licences/windowsdesktop.html\" ><span style=\" color:#2238df\" >%1</span></a>" ).arg (QCoreApplication::translate (" " , " LICENCE" )));
185+ dataAnalysisOpenSource->setTextFormat (Qt::RichText);
186+ dataAnalysisOpenSource->setTextInteractionFlags (Qt::TextBrowserInteraction);
187+ dataAnalysisOpenSource->setOpenExternalLinks (true );
188+ dataAnalysisOpenSource->setSizePolicy (QSizePolicy::Preferred, QSizePolicy::Fixed);
189+ dataAnalysisOpenSource->setStyleSheet (" font-size: 13px" );
190+ dataProtectionBox->layout ()->addWidget (dataAnalysisOpenSource);
191+
192+ auto *dataAnalysisFurtherInfo = new QLabel (this );
193+ dataAnalysisFurtherInfo->setText (QString (" <a href=\" https://cloud.telekom-dienste.de/hilfe\" ><span style=\" color:#2238df\" >%1</span></a>" ).arg (QCoreApplication::translate (" " , " FURTHER_INFO" )));
194+ dataAnalysisFurtherInfo->setTextFormat (Qt::RichText);
195+ dataAnalysisFurtherInfo->setTextInteractionFlags (Qt::TextBrowserInteraction);
196+ dataAnalysisFurtherInfo->setOpenExternalLinks (true );
197+ dataAnalysisFurtherInfo->setSizePolicy (QSizePolicy::Preferred, QSizePolicy::Fixed);
198+ dataAnalysisFurtherInfo->setStyleSheet (" font-size: 13px" );
199+ dataProtectionBox->layout ()->addWidget (dataAnalysisFurtherInfo);
200+
201+ dataProtectionBox->layout ()->addItem (new QSpacerItem (1 ,8 ,QSizePolicy::Fixed,QSizePolicy::Fixed));
202+
203+ auto *currentVersion = new QLabel (this );
204+ currentVersion->setText (Theme::instance ()->about ());
205+ currentVersion->setSizePolicy (QSizePolicy::Preferred, QSizePolicy::Fixed);
206+ // Todo, set current version
207+ dataProtectionBox->layout ()->addWidget (currentVersion);
208+
209+ getUi ()->gridLayout_3 ->addWidget (dataProtectionBox, 3 , 0 );
210+
211+ auto *vExpandSpacer = new QSpacerItem (1 ,1 ,QSizePolicy::Fixed,QSizePolicy::Expanding);
212+ getUi ()->gridLayout_3 ->addItem (vExpandSpacer, 99 , 0 );
213+ }
214+
215+ } // namespace OCC
0 commit comments