@@ -131,9 +131,53 @@ Nedrysoft::SettingsDialog::SettingsDialog(QWidget *parent) :
131
131
132
132
m_controlsLayout->addSpacerItem (new QSpacerItem (0 ,0 ,QSizePolicy::Expanding, QSizePolicy::Minimum));
133
133
134
- m_okButton = new QPushButton (" OK" );
135
- m_cancelButton = new QPushButton (" Cancel" );
136
- m_applyButton = new QPushButton (" Apply" );
134
+ m_okButton = new QPushButton (tr (" OK" ));
135
+ m_cancelButton = new QPushButton (tr (" Cancel" ));
136
+ m_applyButton = new QPushButton (tr (" Apply)" ));
137
+
138
+ connect (m_okButton, &QPushButton::clicked, [=](bool /* checked*/ ) {
139
+ bool settingsValid = true ;
140
+
141
+ for (auto page : m_pages) {
142
+ if (!page->m_pageSettings ->canAcceptSettings ()) {
143
+ settingsValid = false ;
144
+ break ;
145
+ }
146
+ }
147
+
148
+ if (!settingsValid) {
149
+ // TODO go to page with error
150
+ } else {
151
+ for (auto page : m_pages) {
152
+ page->m_pageSettings ->acceptSettings ();
153
+ }
154
+
155
+ close ();
156
+ }
157
+ });
158
+
159
+ connect (m_applyButton, &QPushButton::clicked, [=](bool /* checked*/ ) {
160
+ bool settingsValid = true ;
161
+
162
+ for (auto page : m_pages) {
163
+ if (!page->m_pageSettings ->canAcceptSettings ()) {
164
+ settingsValid = false ;
165
+ break ;
166
+ }
167
+ }
168
+
169
+ if (!settingsValid) {
170
+ // TODO go to page with error
171
+ } else {
172
+ for (auto page : m_pages) {
173
+ page->m_pageSettings ->acceptSettings ();
174
+ }
175
+ }
176
+ });
177
+
178
+ connect (m_cancelButton, &QPushButton::clicked, [=](bool /* checked*/ ) {
179
+ close ();
180
+ });
137
181
138
182
m_controlsLayout->addWidget (m_okButton);
139
183
m_controlsLayout->addWidget (m_cancelButton);
@@ -143,8 +187,8 @@ Nedrysoft::SettingsDialog::SettingsDialog(QWidget *parent) :
143
187
144
188
setLayout (m_layout);
145
189
#endif
146
- addPage (tr (" General" ), tr (" General settings" ), SettingsPage::Icon::General, new GeneralSettingsPage, true );
147
- addPage (tr (" Database" ), tr (" The database settings" ), SettingsPage::Icon::Database, new DatabaseSettingsPage);
190
+ addPage (tr (" General" ), tr (" Application Clone " ), tr ( " General settings" ), SettingsPage::Icon::General, new GeneralSettingsPage, true );
191
+ addPage (tr (" Database" ), tr (" Connection " ), tr ( " Database connection settings" ), SettingsPage::Icon::Database, new DatabaseSettingsPage);
148
192
149
193
#if defined(Q_OS_MACOS)
150
194
m_toolBar->attachToWindow (nativeWindowHandle ());
@@ -202,7 +246,9 @@ bool Nedrysoft::SettingsDialog::close()
202
246
page->m_pageSettings ->acceptSettings ();
203
247
}
204
248
#endif
205
- return true ;
249
+ emit closed ();
250
+
251
+ return QWidget::close ();
206
252
}
207
253
void Nedrysoft::SettingsDialog::resizeEvent (QResizeEvent *event)
208
254
{
@@ -223,14 +269,14 @@ QWindow *Nedrysoft::SettingsDialog::nativeWindowHandle()
223
269
return window ()->windowHandle ();
224
270
}
225
271
226
- Nedrysoft::SettingsPage *Nedrysoft::SettingsDialog::addPage (QString name , QString description, SettingsPage::Icon icon, QWidget *widget, bool defaultPage)
272
+ Nedrysoft::SettingsPage *Nedrysoft::SettingsDialog::addPage (QString section, QString category , QString description, SettingsPage::Icon icon, QWidget *widget, bool defaultPage)
227
273
{
228
274
#if defined(Q_OS_MACOS)
229
275
auto widgetContainer = new TransparentWidget (widget, 0 , this );
230
276
231
277
auto settingsPage = new SettingsPage;
232
278
233
- settingsPage->m_name = name ;
279
+ settingsPage->m_name = section ;
234
280
settingsPage->m_widget = widgetContainer;
235
281
settingsPage->m_pageSettings = dynamic_cast <ISettingsPage *>(widget);
236
282
settingsPage->m_icon = icon;
@@ -321,19 +367,19 @@ Nedrysoft::SettingsPage *Nedrysoft::SettingsDialog::addPage(QString name, QStrin
321
367
auto tabWidget = new QTabWidget ();
322
368
323
369
newTreeItem->setIcon (0 , getIcon (icon));
324
- newTreeItem->setText (0 , name );
370
+ newTreeItem->setText (0 , section );
325
371
newTreeItem->setData (0 , Qt::UserRole, QVariant::fromValue (tabWidget));
326
372
newTreeItem->setData (0 , Qt::ToolTipRole, description);
327
373
328
374
m_treeWidget->addTopLevelItem (newTreeItem);
329
375
330
- tabWidget->addTab (widget, " Interface " );
376
+ tabWidget->addTab (widget, category );
331
377
332
378
m_stackedWidget->addWidget (tabWidget);
333
379
334
380
auto settingsPage = new SettingsPage;
335
381
336
- settingsPage->m_name = name ;
382
+ settingsPage->m_name = section ;
337
383
settingsPage->m_widget = widget;
338
384
settingsPage->m_pageSettings = dynamic_cast <ISettingsPage *>(widget);
339
385
settingsPage->m_icon = icon;
0 commit comments