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