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

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

Parent Directory Parent Directory | Revision Log Revision Log


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

  ViewVC Help
Powered by ViewVC