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