/[svn]/qsampler/trunk/src/qsamplerOptionsForm.cpp
ViewVC logotype

Contents of /qsampler/trunk/src/qsamplerOptionsForm.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 4038 - (show annotations) (download)
Sun May 15 18:43:41 2022 UTC (7 weeks, 1 day ago) by capela
File size: 19281 byte(s)
- Sync to upstream git repo.
1 // qsamplerOptionsForm.cpp
2 //
3 /****************************************************************************
4 Copyright (C) 2004-2022, rncbc aka Rui Nuno Capela. All rights reserved.
5 Copyright (C) 2007, Christian Schoenebeck
6
7 This program is free software; you can redistribute it and/or
8 modify it under the terms of the GNU General Public License
9 as published by the Free Software Foundation; either version 2
10 of the License, or (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License along
18 with this program; if not, write to the Free Software Foundation, Inc.,
19 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20
21 *****************************************************************************/
22
23 #include "qsamplerOptionsForm.h"
24
25 #include "qsamplerAbout.h"
26 #include "qsamplerOptions.h"
27
28 #include "qsamplerPaletteForm.h"
29
30 #include <QMessageBox>
31 #include <QFontDialog>
32 #include <QFileDialog>
33
34 #include <QStyleFactory>
35
36
37 // Default (empty/blank) name.
38 static const char *g_pszDefName = QT_TRANSLATE_NOOP("qsamplerOptionsForm", "(default)");
39
40
41 namespace QSampler {
42
43 //-------------------------------------------------------------------------
44 // QSampler::OptionsForm -- Options form implementation.
45 //
46
47 OptionsForm::OptionsForm ( QWidget* pParent )
48 : QDialog(pParent)
49 {
50 m_ui.setupUi(this);
51 #if QT_VERSION < QT_VERSION_CHECK(6, 1, 0)
52 QDialog::setWindowIcon(QIcon(":/images/qsampler.png"));
53 #endif
54 // No settings descriptor initially (the caller will set it).
55 m_pOptions = nullptr;
56
57 // Initialize dirty control state.
58 m_iDirtySetup = 0;
59 m_iDirtyCount = 0;
60
61 // Set dialog validators...
62 m_ui.ServerPortComboBox->setValidator(
63 new QIntValidator(m_ui.ServerPortComboBox));
64
65 // Try to restore old window positioning.
66 adjustSize();
67
68 QObject::connect(m_ui.ServerHostComboBox,
69 SIGNAL(editTextChanged(const QString&)),
70 SLOT(optionsChanged()));
71 QObject::connect(m_ui.ServerPortComboBox,
72 SIGNAL(editTextChanged(const QString&)),
73 SLOT(optionsChanged()));
74 QObject::connect(m_ui.ServerTimeoutSpinBox,
75 SIGNAL(valueChanged(int)),
76 SLOT(optionsChanged()));
77 QObject::connect(m_ui.ServerStartCheckBox,
78 SIGNAL(stateChanged(int)),
79 SLOT(optionsChanged()));
80 QObject::connect(m_ui.ServerCmdLineComboBox,
81 SIGNAL(editTextChanged(const QString&)),
82 SLOT(optionsChanged()));
83 QObject::connect(m_ui.StartDelaySpinBox,
84 SIGNAL(valueChanged(int)),
85 SLOT(optionsChanged()));
86 QObject::connect(m_ui.MessagesLogCheckBox,
87 SIGNAL(stateChanged(int)),
88 SLOT(optionsChanged()));
89 QObject::connect(m_ui.MessagesLogPathComboBox,
90 SIGNAL(editTextChanged(const QString&)),
91 SLOT(optionsChanged()));
92 QObject::connect(m_ui.MessagesLogPathToolButton,
93 SIGNAL(clicked()),
94 SLOT(browseMessagesLogPath()));
95 QObject::connect(m_ui.DisplayFontPushButton,
96 SIGNAL(clicked()),
97 SLOT(chooseDisplayFont()));
98 QObject::connect(m_ui.DisplayEffectCheckBox,
99 SIGNAL(toggled(bool)),
100 SLOT(toggleDisplayEffect(bool)));
101 QObject::connect(m_ui.AutoRefreshCheckBox,
102 SIGNAL(stateChanged(int)),
103 SLOT(optionsChanged()));
104 QObject::connect(m_ui.AutoRefreshTimeSpinBox,
105 SIGNAL(valueChanged(int)),
106 SLOT(optionsChanged()));
107 QObject::connect(m_ui.MaxVolumeSpinBox,
108 SIGNAL(valueChanged(int)),
109 SLOT(optionsChanged()));
110 QObject::connect(m_ui.MessagesFontPushButton,
111 SIGNAL(clicked()),
112 SLOT(chooseMessagesFont()));
113 QObject::connect(m_ui.MessagesLimitCheckBox,
114 SIGNAL(stateChanged(int)),
115 SLOT(optionsChanged()));
116 QObject::connect(m_ui.MessagesLimitLinesSpinBox,
117 SIGNAL(valueChanged(int)),
118 SLOT(optionsChanged()));
119 QObject::connect(m_ui.ConfirmRemoveCheckBox,
120 SIGNAL(stateChanged(int)),
121 SLOT(optionsChanged()));
122 QObject::connect(m_ui.ConfirmResetCheckBox,
123 SIGNAL(stateChanged(int)),
124 SLOT(optionsChanged()));
125 QObject::connect(m_ui.ConfirmRestartCheckBox,
126 SIGNAL(stateChanged(int)),
127 SLOT(optionsChanged()));
128 QObject::connect(m_ui.ConfirmErrorCheckBox,
129 SIGNAL(stateChanged(int)),
130 SLOT(optionsChanged()));
131 QObject::connect(m_ui.KeepOnTopCheckBox,
132 SIGNAL(stateChanged(int)),
133 SLOT(optionsChanged()));
134 QObject::connect(m_ui.StdoutCaptureCheckBox,
135 SIGNAL(stateChanged(int)),
136 SLOT(optionsChanged()));
137 QObject::connect(m_ui.MaxRecentFilesSpinBox,
138 SIGNAL(valueChanged(int)),
139 SLOT(optionsChanged()));
140 QObject::connect(m_ui.CompletePathCheckBox,
141 SIGNAL(stateChanged(int)),
142 SLOT(optionsChanged()));
143 QObject::connect(m_ui.InstrumentNamesCheckBox,
144 SIGNAL(stateChanged(int)),
145 SLOT(optionsChanged()));
146 QObject::connect(m_ui.CustomColorThemeComboBox,
147 SIGNAL(activated(int)),
148 SLOT(optionsChanged()));
149 QObject::connect(m_ui.CustomColorThemeToolButton,
150 SIGNAL(clicked()),
151 SLOT(editCustomColorThemes()));
152 QObject::connect(m_ui.CustomStyleThemeComboBox,
153 SIGNAL(activated(int)),
154 SLOT(optionsChanged()));
155 QObject::connect(m_ui.BaseFontSizeComboBox,
156 SIGNAL(editTextChanged(const QString&)),
157 SLOT(optionsChanged()));
158 QObject::connect(m_ui.MaxVoicesSpinBox,
159 SIGNAL(valueChanged(int)),
160 SLOT(maxVoicesChanged(int)));
161 QObject::connect(m_ui.MaxStreamsSpinBox,
162 SIGNAL(valueChanged(int)),
163 SLOT(maxStreamsChanged(int)));
164 QObject::connect(m_ui.DialogButtonBox,
165 SIGNAL(accepted()),
166 SLOT(accept()));
167 QObject::connect(m_ui.DialogButtonBox,
168 SIGNAL(rejected()),
169 SLOT(reject()));
170 }
171
172 OptionsForm::~OptionsForm()
173 {
174 }
175
176 // Populate (setup) dialog controls from settings descriptors.
177 void OptionsForm::setup ( Options *pOptions )
178 {
179 // Set reference descriptor.
180 m_pOptions = pOptions;
181
182 // Start clean.
183 m_iDirtyCount = 0;
184 // Avoid nested changes.
185 m_iDirtySetup++;
186
187 // Load combo box history...
188 m_pOptions->loadComboBoxHistory(m_ui.ServerHostComboBox);
189 m_pOptions->loadComboBoxHistory(m_ui.ServerPortComboBox);
190 m_pOptions->loadComboBoxHistory(m_ui.ServerCmdLineComboBox);
191 m_pOptions->loadComboBoxHistory(m_ui.MessagesLogPathComboBox);
192
193 // Load Server settings...
194 m_ui.ServerHostComboBox->setEditText(m_pOptions->sServerHost);
195 m_ui.ServerPortComboBox->setEditText(QString::number(m_pOptions->iServerPort));
196 m_ui.ServerTimeoutSpinBox->setValue(m_pOptions->iServerTimeout);
197 m_ui.ServerStartCheckBox->setChecked(m_pOptions->bServerStart);
198 m_ui.ServerCmdLineComboBox->setEditText(m_pOptions->sServerCmdLine);
199 m_ui.StartDelaySpinBox->setValue(m_pOptions->iStartDelay);
200
201 // Logging options...
202 m_ui.MessagesLogCheckBox->setChecked(m_pOptions->bMessagesLog);
203 m_ui.MessagesLogPathComboBox->setEditText(m_pOptions->sMessagesLogPath);
204
205 // Load Display options...
206 QFont font;
207 QPalette pal;
208
209 // Display font.
210 if (m_pOptions->sDisplayFont.isEmpty()
211 || !font.fromString(m_pOptions->sDisplayFont))
212 font = QFont("Sans Serif", 8);
213 m_ui.DisplayFontTextLabel->setFont(font);
214 m_ui.DisplayFontTextLabel->setText(font.family()
215 + ' ' + QString::number(font.pointSize()));
216
217 // Display effect.
218 m_ui.DisplayEffectCheckBox->setChecked(m_pOptions->bDisplayEffect);
219 toggleDisplayEffect(m_pOptions->bDisplayEffect);
220
221 // Auto-refresh and maximum volume options.
222 m_ui.AutoRefreshCheckBox->setChecked(m_pOptions->bAutoRefresh);
223 m_ui.AutoRefreshTimeSpinBox->setValue(m_pOptions->iAutoRefreshTime);
224 m_ui.MaxVolumeSpinBox->setValue(m_pOptions->iMaxVolume);
225
226 // Messages font.
227 if (m_pOptions->sMessagesFont.isEmpty()
228 || !font.fromString(m_pOptions->sMessagesFont))
229 font = QFont("Monospace", 8);
230 pal = m_ui.MessagesFontTextLabel->palette();
231 pal.setColor(QPalette::Window, pal.base().color());
232 m_ui.MessagesFontTextLabel->setPalette(pal);
233 m_ui.MessagesFontTextLabel->setFont(font);
234 m_ui.MessagesFontTextLabel->setText(font.family()
235 + ' ' + QString::number(font.pointSize()));
236
237 // Messages limit option.
238 m_ui.MessagesLimitCheckBox->setChecked(m_pOptions->bMessagesLimit);
239 m_ui.MessagesLimitLinesSpinBox->setValue(m_pOptions->iMessagesLimitLines);
240
241 // Other options finally.
242 m_ui.ConfirmRemoveCheckBox->setChecked(m_pOptions->bConfirmRemove);
243 m_ui.ConfirmRestartCheckBox->setChecked(m_pOptions->bConfirmRestart);
244 m_ui.ConfirmResetCheckBox->setChecked(m_pOptions->bConfirmReset);
245 m_ui.ConfirmErrorCheckBox->setChecked(m_pOptions->bConfirmError);
246 m_ui.KeepOnTopCheckBox->setChecked(m_pOptions->bKeepOnTop);
247 m_ui.StdoutCaptureCheckBox->setChecked(m_pOptions->bStdoutCapture);
248 m_ui.CompletePathCheckBox->setChecked(m_pOptions->bCompletePath);
249 m_ui.InstrumentNamesCheckBox->setChecked(m_pOptions->bInstrumentNames);
250 m_ui.MaxRecentFilesSpinBox->setValue(m_pOptions->iMaxRecentFiles);
251 if (m_pOptions->iBaseFontSize > 0)
252 m_ui.BaseFontSizeComboBox->setEditText(QString::number(m_pOptions->iBaseFontSize));
253 else
254 m_ui.BaseFontSizeComboBox->setCurrentIndex(0);
255
256 #ifndef CONFIG_LIBGIG
257 m_ui.InstrumentNamesCheckBox->setEnabled(false);
258 #endif
259
260 bMaxVoicesModified = bMaxStreamsModified = false;
261 #ifdef CONFIG_MAX_VOICES
262 const bool bMaxVoicesSupported =
263 m_pOptions->getEffectiveMaxVoices() >= 0;
264 const bool bMaxStreamsSupported =
265 m_pOptions->getEffectiveMaxStreams() >= 0;
266
267 m_ui.MaxVoicesSpinBox->setEnabled(bMaxVoicesSupported);
268 m_ui.MaxVoicesSpinBox->setValue(m_pOptions->getMaxVoices());
269 if (!bMaxVoicesSupported)
270 m_ui.MaxVoicesSpinBox->setToolTip(
271 tr("This parameter is not supported by the current sampler "
272 "version in use.")
273 );
274 else
275 m_ui.MaxVoicesSpinBox->setToolTip(
276 tr("The max. amount of voices the sampler shall process "
277 "simultaneously.")
278 );
279
280 m_ui.MaxStreamsSpinBox->setEnabled(bMaxStreamsSupported);
281 m_ui.MaxStreamsSpinBox->setValue(m_pOptions->getMaxStreams());
282 if (!bMaxStreamsSupported)
283 m_ui.MaxStreamsSpinBox->setToolTip(
284 tr("This parameter is not supported by the current sampler "
285 "version in use.")
286 );
287 else
288 m_ui.MaxStreamsSpinBox->setToolTip(
289 tr("The max. amount of disk streams the sampler shall process "
290 "simultaneously.")
291 );
292 #else
293 m_ui.MaxVoicesSpinBox->setEnabled(false);
294 m_ui.MaxStreamsSpinBox->setEnabled(false);
295 m_ui.MaxVoicesSpinBox->setToolTip(
296 tr("QSampler was built without support for this parameter.")
297 );
298 m_ui.MaxStreamsSpinBox->setToolTip(
299 tr("QSampler was built without support for this parameter.")
300 );
301 #endif // CONFIG_MAX_VOICES
302
303 // Custom display options...
304 resetCustomColorThemes(m_pOptions->sCustomColorTheme);
305 resetCustomStyleThemes(m_pOptions->sCustomStyleTheme);
306
307 // Done.
308 m_iDirtySetup--;
309 stabilizeForm();
310 }
311
312
313 // Accept settings (OK button slot).
314 void OptionsForm::accept (void)
315 {
316 // Save options...
317 if (m_iDirtyCount > 0) {
318 // Server settings....
319 m_pOptions->sServerHost = m_ui.ServerHostComboBox->currentText().trimmed();
320 m_pOptions->iServerPort = m_ui.ServerPortComboBox->currentText().toInt();
321 m_pOptions->iServerTimeout = m_ui.ServerTimeoutSpinBox->value();
322 m_pOptions->bServerStart = m_ui.ServerStartCheckBox->isChecked();
323 m_pOptions->sServerCmdLine = m_ui.ServerCmdLineComboBox->currentText().trimmed();
324 m_pOptions->iStartDelay = m_ui.StartDelaySpinBox->value();
325 // Logging options...
326 m_pOptions->bMessagesLog = m_ui.MessagesLogCheckBox->isChecked();
327 m_pOptions->sMessagesLogPath = m_ui.MessagesLogPathComboBox->currentText();
328 // Channels options...
329 m_pOptions->sDisplayFont = m_ui.DisplayFontTextLabel->font().toString();
330 m_pOptions->bDisplayEffect = m_ui.DisplayEffectCheckBox->isChecked();
331 m_pOptions->bAutoRefresh = m_ui.AutoRefreshCheckBox->isChecked();
332 m_pOptions->iAutoRefreshTime = m_ui.AutoRefreshTimeSpinBox->value();
333 m_pOptions->iMaxVolume = m_ui.MaxVolumeSpinBox->value();
334 // Messages options...
335 m_pOptions->sMessagesFont = m_ui.MessagesFontTextLabel->font().toString();
336 m_pOptions->bMessagesLimit = m_ui.MessagesLimitCheckBox->isChecked();
337 m_pOptions->iMessagesLimitLines = m_ui.MessagesLimitLinesSpinBox->value();
338 // Other options...
339 m_pOptions->bConfirmRemove = m_ui.ConfirmRemoveCheckBox->isChecked();
340 m_pOptions->bConfirmRestart = m_ui.ConfirmRestartCheckBox->isChecked();
341 m_pOptions->bConfirmReset = m_ui.ConfirmResetCheckBox->isChecked();
342 m_pOptions->bConfirmError = m_ui.ConfirmErrorCheckBox->isChecked();
343 m_pOptions->bKeepOnTop = m_ui.KeepOnTopCheckBox->isChecked();
344 m_pOptions->bStdoutCapture = m_ui.StdoutCaptureCheckBox->isChecked();
345 m_pOptions->bCompletePath = m_ui.CompletePathCheckBox->isChecked();
346 m_pOptions->bInstrumentNames = m_ui.InstrumentNamesCheckBox->isChecked();
347 m_pOptions->iMaxRecentFiles = m_ui.MaxRecentFilesSpinBox->value();
348 m_pOptions->iBaseFontSize = m_ui.BaseFontSizeComboBox->currentText().toInt();
349 // Custom color/style theme options...
350 if (m_ui.CustomStyleThemeComboBox->currentIndex() > 0)
351 m_pOptions->sCustomStyleTheme = m_ui.CustomStyleThemeComboBox->currentText();
352 else
353 m_pOptions->sCustomStyleTheme.clear();
354 if (m_ui.CustomColorThemeComboBox->currentIndex() > 0)
355 m_pOptions->sCustomColorTheme = m_ui.CustomColorThemeComboBox->currentText();
356 else
357 m_pOptions->sCustomColorTheme.clear();
358 // Reset dirty flag.
359 m_iDirtyCount = 0;
360 }
361
362 // If the user modified the limits, apply them to the sampler
363 // (and store it later in qsampler's configuration)
364 if (bMaxVoicesModified && m_ui.MaxVoicesSpinBox->isEnabled())
365 m_pOptions->setMaxVoices(m_ui.MaxVoicesSpinBox->value());
366 if (bMaxStreamsModified && m_ui.MaxStreamsSpinBox->isEnabled())
367 m_pOptions->setMaxStreams(m_ui.MaxStreamsSpinBox->value());
368
369 // Save combobox history...
370 m_pOptions->saveComboBoxHistory(m_ui.ServerHostComboBox);
371 m_pOptions->saveComboBoxHistory(m_ui.ServerPortComboBox);
372 m_pOptions->saveComboBoxHistory(m_ui.ServerCmdLineComboBox);
373 m_pOptions->saveComboBoxHistory(m_ui.MessagesLogPathComboBox);
374
375 // Save/commit to disk.
376 m_pOptions->saveOptions();
377
378 // Just go with dialog acceptance.
379 QDialog::accept();
380 }
381
382
383 // Reject settings (Cancel button slot).
384 void OptionsForm::reject (void)
385 {
386 bool bReject = true;
387
388 // Check if there's any pending changes...
389 if (m_iDirtyCount > 0) {
390 switch (QMessageBox::warning(this,
391 tr("Warning"),
392 tr("Some settings have been changed.\n\n"
393 "Do you want to apply the changes?"),
394 QMessageBox::Apply |
395 QMessageBox::Discard |
396 QMessageBox::Cancel)) {
397 case QMessageBox::Apply:
398 accept();
399 return;
400 case QMessageBox::Discard:
401 break;
402 default: // Cancel.
403 bReject = false;
404 }
405 }
406
407 if (bReject)
408 QDialog::reject();
409 }
410
411
412 // Dirty up settings.
413 void OptionsForm::optionsChanged (void)
414 {
415 if (m_iDirtySetup > 0)
416 return;
417
418 m_iDirtyCount++;
419 stabilizeForm();
420 }
421
422
423 // Stabilize current form state.
424 void OptionsForm::stabilizeForm (void)
425 {
426 bool bValid = (m_iDirtyCount > 0);
427
428 bool bEnabled = m_ui.ServerStartCheckBox->isChecked();
429 m_ui.ServerCmdLineTextLabel->setEnabled(bEnabled);
430 m_ui.ServerCmdLineComboBox->setEnabled(bEnabled);
431 m_ui.StartDelayTextLabel->setEnabled(bEnabled);
432 m_ui.StartDelaySpinBox->setEnabled(bEnabled);
433
434 bEnabled = m_ui.MessagesLogCheckBox->isChecked();
435 m_ui.MessagesLogPathComboBox->setEnabled(bEnabled);
436 m_ui.MessagesLogPathToolButton->setEnabled(bEnabled);
437 if (bEnabled && bValid) {
438 const QString& sPath = m_ui.MessagesLogPathComboBox->currentText();
439 bValid = !sPath.isEmpty();
440 }
441
442 m_ui.AutoRefreshTimeSpinBox->setEnabled(
443 m_ui.AutoRefreshCheckBox->isChecked());
444 m_ui.MessagesLimitLinesSpinBox->setEnabled(
445 m_ui.MessagesLimitCheckBox->isChecked());
446
447 m_ui.DialogButtonBox->button(QDialogButtonBox::Ok)->setEnabled(bValid);
448 }
449
450
451 // Messages log path browse slot.
452 void OptionsForm::browseMessagesLogPath (void)
453 {
454 QString sFileName = QFileDialog::getSaveFileName(
455 this, // Parent.
456 tr("Messages Log"), // Caption.
457 m_ui.MessagesLogPathComboBox->currentText(), // Start here.
458 tr("Log files") + " (*.log)" // Filter (log files)
459 );
460
461 if (!sFileName.isEmpty()) {
462 m_ui.MessagesLogPathComboBox->setEditText(sFileName);
463 m_ui.MessagesLogPathComboBox->setFocus();
464 optionsChanged();
465 }
466 }
467
468
469 // The channel display font selection dialog.
470 void OptionsForm::chooseDisplayFont (void)
471 {
472 bool bOk = false;
473 QFont font = QFontDialog::getFont(&bOk,
474 m_ui.DisplayFontTextLabel->font(), this);
475 if (bOk) {
476 m_ui.DisplayFontTextLabel->setFont(font);
477 m_ui.DisplayFontTextLabel->setText(font.family()
478 + ' ' + QString::number(font.pointSize()));
479 optionsChanged();
480 }
481 }
482
483
484 // The messages font selection dialog.
485 void OptionsForm::chooseMessagesFont (void)
486 {
487 bool bOk = false;
488 QFont font = QFontDialog::getFont(&bOk,
489 m_ui.MessagesFontTextLabel->font(), this);
490 if (bOk) {
491 m_ui.MessagesFontTextLabel->setFont(font);
492 m_ui.MessagesFontTextLabel->setText(font.family()
493 + ' ' + QString::number(font.pointSize()));
494 optionsChanged();
495 }
496 }
497
498
499 // The channel display effect demo changer.
500 void OptionsForm::toggleDisplayEffect ( bool bOn )
501 {
502 QPalette pal;
503 pal.setColor(QPalette::WindowText, Qt::green);
504 if (bOn) {
505 QPixmap pm(":/images/displaybg1.png");
506 pal.setBrush(QPalette::Window, QBrush(pm));
507 } else {
508 pal.setColor(QPalette::Window, Qt::black);
509 }
510 m_ui.DisplayFontTextLabel->setPalette(pal);
511
512 optionsChanged();
513 }
514
515 void OptionsForm::maxVoicesChanged(int /*iMaxVoices*/)
516 {
517 bMaxVoicesModified = true;
518 optionsChanged();
519 }
520
521 void OptionsForm::maxStreamsChanged(int /*iMaxStreams*/)
522 {
523 bMaxStreamsModified = true;
524 optionsChanged();
525 }
526
527
528 // Custom color palette theme manager.
529 void OptionsForm::editCustomColorThemes (void)
530 {
531 PaletteForm form(this);
532 form.setSettings(&m_pOptions->settings());
533
534 QString sCustomColorTheme;
535 int iDirtyCustomColorTheme = 0;
536
537 const int iCustomColorTheme
538 = m_ui.CustomColorThemeComboBox->currentIndex();
539 if (iCustomColorTheme > 0) {
540 sCustomColorTheme = m_ui.CustomColorThemeComboBox->itemText(
541 iCustomColorTheme);
542 form.setPaletteName(sCustomColorTheme);
543 }
544
545 if (form.exec() == QDialog::Accepted) {
546 sCustomColorTheme = form.paletteName();
547 ++iDirtyCustomColorTheme;
548 }
549
550 if (iDirtyCustomColorTheme > 0 || form.isDirty()) {
551 resetCustomColorThemes(sCustomColorTheme);
552 optionsChanged();
553 }
554 }
555
556
557 // Custom color palette themes settler.
558 void OptionsForm::resetCustomColorThemes (
559 const QString& sCustomColorTheme )
560 {
561 m_ui.CustomColorThemeComboBox->clear();
562 m_ui.CustomColorThemeComboBox->addItem(
563 tr(g_pszDefName));
564 m_ui.CustomColorThemeComboBox->addItems(
565 PaletteForm::namedPaletteList(&m_pOptions->settings()));
566
567 int iCustomColorTheme = 0;
568 if (!sCustomColorTheme.isEmpty()) {
569 iCustomColorTheme = m_ui.CustomColorThemeComboBox->findText(
570 sCustomColorTheme);
571 if (iCustomColorTheme < 0)
572 iCustomColorTheme = 0;
573 }
574 m_ui.CustomColorThemeComboBox->setCurrentIndex(iCustomColorTheme);
575 }
576
577
578 // Custom widget style themes settler.
579 void OptionsForm::resetCustomStyleThemes (
580 const QString& sCustomStyleTheme )
581 {
582 m_ui.CustomStyleThemeComboBox->clear();
583 m_ui.CustomStyleThemeComboBox->addItem(
584 tr(g_pszDefName));
585 m_ui.CustomStyleThemeComboBox->addItems(QStyleFactory::keys());
586
587 int iCustomStyleTheme = 0;
588 if (!sCustomStyleTheme.isEmpty()) {
589 iCustomStyleTheme = m_ui.CustomStyleThemeComboBox->findText(
590 sCustomStyleTheme);
591 if (iCustomStyleTheme < 0)
592 iCustomStyleTheme = 0;
593 }
594 m_ui.CustomStyleThemeComboBox->setCurrentIndex(iCustomStyleTheme);
595 }
596
597
598 } // namespace QSampler
599
600 // end of qsamplerOptionsForm.cpp

  ViewVC Help
Powered by ViewVC