1 |
capela |
1464 |
// qsamplerOptionsForm.cpp |
2 |
|
|
// |
3 |
|
|
/**************************************************************************** |
4 |
capela |
4030 |
Copyright (C) 2004-2022, 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 |
capela |
4038 |
#if QT_VERSION < QT_VERSION_CHECK(6, 1, 0) |
52 |
|
|
QDialog::setWindowIcon(QIcon(":/images/qsampler.png")); |
53 |
|
|
#endif |
54 |
capela |
1473 |
// No settings descriptor initially (the caller will set it). |
55 |
capela |
3555 |
m_pOptions = nullptr; |
56 |
schoenebeck |
1461 |
|
57 |
capela |
1473 |
// Initialize dirty control state. |
58 |
|
|
m_iDirtySetup = 0; |
59 |
|
|
m_iDirtyCount = 0; |
60 |
schoenebeck |
1461 |
|
61 |
capela |
1473 |
// Set dialog validators... |
62 |
capela |
1509 |
m_ui.ServerPortComboBox->setValidator( |
63 |
|
|
new QIntValidator(m_ui.ServerPortComboBox)); |
64 |
schoenebeck |
1461 |
|
65 |
capela |
1473 |
// Try to restore old window positioning. |
66 |
|
|
adjustSize(); |
67 |
capela |
1466 |
|
68 |
capela |
1509 |
QObject::connect(m_ui.ServerHostComboBox, |
69 |
capela |
1504 |
SIGNAL(editTextChanged(const QString&)), |
70 |
capela |
1466 |
SLOT(optionsChanged())); |
71 |
capela |
1509 |
QObject::connect(m_ui.ServerPortComboBox, |
72 |
capela |
1504 |
SIGNAL(editTextChanged(const QString&)), |
73 |
capela |
1466 |
SLOT(optionsChanged())); |
74 |
capela |
1509 |
QObject::connect(m_ui.ServerTimeoutSpinBox, |
75 |
capela |
1466 |
SIGNAL(valueChanged(int)), |
76 |
|
|
SLOT(optionsChanged())); |
77 |
capela |
1509 |
QObject::connect(m_ui.ServerStartCheckBox, |
78 |
capela |
1466 |
SIGNAL(stateChanged(int)), |
79 |
|
|
SLOT(optionsChanged())); |
80 |
capela |
1509 |
QObject::connect(m_ui.ServerCmdLineComboBox, |
81 |
capela |
1504 |
SIGNAL(editTextChanged(const QString&)), |
82 |
capela |
1466 |
SLOT(optionsChanged())); |
83 |
capela |
1509 |
QObject::connect(m_ui.StartDelaySpinBox, |
84 |
capela |
1466 |
SIGNAL(valueChanged(int)), |
85 |
|
|
SLOT(optionsChanged())); |
86 |
capela |
1738 |
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 |
capela |
1509 |
QObject::connect(m_ui.DisplayFontPushButton, |
96 |
capela |
1466 |
SIGNAL(clicked()), |
97 |
|
|
SLOT(chooseDisplayFont())); |
98 |
capela |
1509 |
QObject::connect(m_ui.DisplayEffectCheckBox, |
99 |
capela |
1466 |
SIGNAL(toggled(bool)), |
100 |
|
|
SLOT(toggleDisplayEffect(bool))); |
101 |
capela |
1509 |
QObject::connect(m_ui.AutoRefreshCheckBox, |
102 |
capela |
1466 |
SIGNAL(stateChanged(int)), |
103 |
|
|
SLOT(optionsChanged())); |
104 |
capela |
1509 |
QObject::connect(m_ui.AutoRefreshTimeSpinBox, |
105 |
capela |
1466 |
SIGNAL(valueChanged(int)), |
106 |
|
|
SLOT(optionsChanged())); |
107 |
capela |
1509 |
QObject::connect(m_ui.MaxVolumeSpinBox, |
108 |
capela |
1466 |
SIGNAL(valueChanged(int)), |
109 |
|
|
SLOT(optionsChanged())); |
110 |
capela |
1509 |
QObject::connect(m_ui.MessagesFontPushButton, |
111 |
capela |
1466 |
SIGNAL(clicked()), |
112 |
|
|
SLOT(chooseMessagesFont())); |
113 |
capela |
1509 |
QObject::connect(m_ui.MessagesLimitCheckBox, |
114 |
capela |
1466 |
SIGNAL(stateChanged(int)), |
115 |
|
|
SLOT(optionsChanged())); |
116 |
capela |
1509 |
QObject::connect(m_ui.MessagesLimitLinesSpinBox, |
117 |
capela |
1466 |
SIGNAL(valueChanged(int)), |
118 |
|
|
SLOT(optionsChanged())); |
119 |
capela |
1509 |
QObject::connect(m_ui.ConfirmRemoveCheckBox, |
120 |
capela |
1466 |
SIGNAL(stateChanged(int)), |
121 |
|
|
SLOT(optionsChanged())); |
122 |
capela |
2722 |
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 |
capela |
1509 |
QObject::connect(m_ui.KeepOnTopCheckBox, |
132 |
capela |
1466 |
SIGNAL(stateChanged(int)), |
133 |
|
|
SLOT(optionsChanged())); |
134 |
capela |
1509 |
QObject::connect(m_ui.StdoutCaptureCheckBox, |
135 |
capela |
1466 |
SIGNAL(stateChanged(int)), |
136 |
|
|
SLOT(optionsChanged())); |
137 |
capela |
1509 |
QObject::connect(m_ui.MaxRecentFilesSpinBox, |
138 |
capela |
1466 |
SIGNAL(valueChanged(int)), |
139 |
|
|
SLOT(optionsChanged())); |
140 |
capela |
1509 |
QObject::connect(m_ui.CompletePathCheckBox, |
141 |
capela |
1466 |
SIGNAL(stateChanged(int)), |
142 |
|
|
SLOT(optionsChanged())); |
143 |
capela |
1509 |
QObject::connect(m_ui.InstrumentNamesCheckBox, |
144 |
capela |
1466 |
SIGNAL(stateChanged(int)), |
145 |
|
|
SLOT(optionsChanged())); |
146 |
capela |
3648 |
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 |
capela |
1749 |
QObject::connect(m_ui.BaseFontSizeComboBox, |
156 |
|
|
SIGNAL(editTextChanged(const QString&)), |
157 |
|
|
SLOT(optionsChanged())); |
158 |
schoenebeck |
1803 |
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 |
capela |
2107 |
QObject::connect(m_ui.DialogButtonBox, |
165 |
|
|
SIGNAL(accepted()), |
166 |
capela |
1466 |
SLOT(accept())); |
167 |
capela |
2107 |
QObject::connect(m_ui.DialogButtonBox, |
168 |
|
|
SIGNAL(rejected()), |
169 |
capela |
1466 |
SLOT(reject())); |
170 |
schoenebeck |
1461 |
} |
171 |
|
|
|
172 |
capela |
1473 |
OptionsForm::~OptionsForm() |
173 |
|
|
{ |
174 |
schoenebeck |
1461 |
} |
175 |
|
|
|
176 |
|
|
// Populate (setup) dialog controls from settings descriptors. |
177 |
capela |
1558 |
void OptionsForm::setup ( Options *pOptions ) |
178 |
schoenebeck |
1461 |
{ |
179 |
capela |
1509 |
// Set reference descriptor. |
180 |
|
|
m_pOptions = pOptions; |
181 |
schoenebeck |
1461 |
|
182 |
capela |
1509 |
// Start clean. |
183 |
|
|
m_iDirtyCount = 0; |
184 |
|
|
// Avoid nested changes. |
185 |
|
|
m_iDirtySetup++; |
186 |
schoenebeck |
1461 |
|
187 |
capela |
1509 |
// 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 |
capela |
1738 |
m_pOptions->loadComboBoxHistory(m_ui.MessagesLogPathComboBox); |
192 |
schoenebeck |
1461 |
|
193 |
capela |
1509 |
// 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 |
schoenebeck |
1461 |
|
201 |
capela |
1738 |
// Logging options... |
202 |
|
|
m_ui.MessagesLogCheckBox->setChecked(m_pOptions->bMessagesLog); |
203 |
|
|
m_ui.MessagesLogPathComboBox->setEditText(m_pOptions->sMessagesLogPath); |
204 |
|
|
|
205 |
capela |
1509 |
// Load Display options... |
206 |
|
|
QFont font; |
207 |
capela |
1504 |
QPalette pal; |
208 |
schoenebeck |
1461 |
|
209 |
capela |
1509 |
// 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 |
schoenebeck |
1461 |
|
217 |
capela |
1509 |
// Display effect. |
218 |
|
|
m_ui.DisplayEffectCheckBox->setChecked(m_pOptions->bDisplayEffect); |
219 |
|
|
toggleDisplayEffect(m_pOptions->bDisplayEffect); |
220 |
schoenebeck |
1461 |
|
221 |
capela |
1509 |
// 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 |
schoenebeck |
1461 |
|
226 |
capela |
1509 |
// Messages font. |
227 |
|
|
if (m_pOptions->sMessagesFont.isEmpty() |
228 |
|
|
|| !font.fromString(m_pOptions->sMessagesFont)) |
229 |
capela |
1788 |
font = QFont("Monospace", 8); |
230 |
capela |
1509 |
pal = m_ui.MessagesFontTextLabel->palette(); |
231 |
capela |
3794 |
pal.setColor(QPalette::Window, pal.base().color()); |
232 |
capela |
1509 |
m_ui.MessagesFontTextLabel->setPalette(pal); |
233 |
|
|
m_ui.MessagesFontTextLabel->setFont(font); |
234 |
|
|
m_ui.MessagesFontTextLabel->setText(font.family() |
235 |
|
|
+ ' ' + QString::number(font.pointSize())); |
236 |
schoenebeck |
1461 |
|
237 |
capela |
1509 |
// Messages limit option. |
238 |
|
|
m_ui.MessagesLimitCheckBox->setChecked(m_pOptions->bMessagesLimit); |
239 |
|
|
m_ui.MessagesLimitLinesSpinBox->setValue(m_pOptions->iMessagesLimitLines); |
240 |
schoenebeck |
1461 |
|
241 |
capela |
1509 |
// Other options finally. |
242 |
|
|
m_ui.ConfirmRemoveCheckBox->setChecked(m_pOptions->bConfirmRemove); |
243 |
capela |
2722 |
m_ui.ConfirmRestartCheckBox->setChecked(m_pOptions->bConfirmRestart); |
244 |
|
|
m_ui.ConfirmResetCheckBox->setChecked(m_pOptions->bConfirmReset); |
245 |
|
|
m_ui.ConfirmErrorCheckBox->setChecked(m_pOptions->bConfirmError); |
246 |
capela |
1509 |
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 |
capela |
1749 |
if (m_pOptions->iBaseFontSize > 0) |
252 |
|
|
m_ui.BaseFontSizeComboBox->setEditText(QString::number(m_pOptions->iBaseFontSize)); |
253 |
|
|
else |
254 |
|
|
m_ui.BaseFontSizeComboBox->setCurrentIndex(0); |
255 |
schoenebeck |
1461 |
|
256 |
|
|
#ifndef CONFIG_LIBGIG |
257 |
capela |
1509 |
m_ui.InstrumentNamesCheckBox->setEnabled(false); |
258 |
schoenebeck |
1461 |
#endif |
259 |
|
|
|
260 |
schoenebeck |
1803 |
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 |
capela |
3386 |
"simultaneously.") |
278 |
schoenebeck |
1803 |
); |
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 |
capela |
3386 |
"simultaneously.") |
291 |
schoenebeck |
1803 |
); |
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 |
capela |
3648 |
// Custom display options... |
304 |
|
|
resetCustomColorThemes(m_pOptions->sCustomColorTheme); |
305 |
|
|
resetCustomStyleThemes(m_pOptions->sCustomStyleTheme); |
306 |
|
|
|
307 |
capela |
1509 |
// Done. |
308 |
|
|
m_iDirtySetup--; |
309 |
|
|
stabilizeForm(); |
310 |
schoenebeck |
1461 |
} |
311 |
|
|
|
312 |
|
|
|
313 |
|
|
// Accept settings (OK button slot). |
314 |
|
|
void OptionsForm::accept (void) |
315 |
|
|
{ |
316 |
capela |
1509 |
// 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 |
capela |
1738 |
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 |
capela |
1509 |
// 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 |
capela |
2722 |
m_pOptions->bConfirmRestart = m_ui.ConfirmRestartCheckBox->isChecked(); |
341 |
|
|
m_pOptions->bConfirmReset = m_ui.ConfirmResetCheckBox->isChecked(); |
342 |
|
|
m_pOptions->bConfirmError = m_ui.ConfirmErrorCheckBox->isChecked(); |
343 |
capela |
1509 |
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 |
capela |
1749 |
m_pOptions->iBaseFontSize = m_ui.BaseFontSizeComboBox->currentText().toInt(); |
349 |
capela |
3648 |
// 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 |
capela |
1509 |
// Reset dirty flag. |
359 |
|
|
m_iDirtyCount = 0; |
360 |
|
|
} |
361 |
schoenebeck |
1461 |
|
362 |
capela |
3761 |
// If the user modified the limits, apply them to the sampler |
363 |
schoenebeck |
1803 |
// (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 |
capela |
1509 |
// 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 |
capela |
1738 |
m_pOptions->saveComboBoxHistory(m_ui.MessagesLogPathComboBox); |
374 |
schoenebeck |
1461 |
|
375 |
capela |
2028 |
// Save/commit to disk. |
376 |
|
|
m_pOptions->saveOptions(); |
377 |
|
|
|
378 |
capela |
1509 |
// Just go with dialog acceptance. |
379 |
|
|
QDialog::accept(); |
380 |
schoenebeck |
1461 |
} |
381 |
|
|
|
382 |
|
|
|
383 |
|
|
// Reject settings (Cancel button slot). |
384 |
|
|
void OptionsForm::reject (void) |
385 |
|
|
{ |
386 |
capela |
1509 |
bool bReject = true; |
387 |
schoenebeck |
1461 |
|
388 |
capela |
1509 |
// Check if there's any pending changes... |
389 |
|
|
if (m_iDirtyCount > 0) { |
390 |
|
|
switch (QMessageBox::warning(this, |
391 |
capela |
3559 |
tr("Warning"), |
392 |
capela |
1509 |
tr("Some settings have been changed.\n\n" |
393 |
|
|
"Do you want to apply the changes?"), |
394 |
capela |
1840 |
QMessageBox::Apply | |
395 |
|
|
QMessageBox::Discard | |
396 |
|
|
QMessageBox::Cancel)) { |
397 |
|
|
case QMessageBox::Apply: |
398 |
capela |
1509 |
accept(); |
399 |
|
|
return; |
400 |
capela |
1840 |
case QMessageBox::Discard: |
401 |
capela |
1509 |
break; |
402 |
|
|
default: // Cancel. |
403 |
|
|
bReject = false; |
404 |
|
|
} |
405 |
|
|
} |
406 |
schoenebeck |
1461 |
|
407 |
capela |
1509 |
if (bReject) |
408 |
|
|
QDialog::reject(); |
409 |
schoenebeck |
1461 |
} |
410 |
|
|
|
411 |
|
|
|
412 |
|
|
// Dirty up settings. |
413 |
|
|
void OptionsForm::optionsChanged (void) |
414 |
|
|
{ |
415 |
capela |
1509 |
if (m_iDirtySetup > 0) |
416 |
|
|
return; |
417 |
schoenebeck |
1461 |
|
418 |
capela |
1509 |
m_iDirtyCount++; |
419 |
|
|
stabilizeForm(); |
420 |
schoenebeck |
1461 |
} |
421 |
|
|
|
422 |
|
|
|
423 |
|
|
// Stabilize current form state. |
424 |
|
|
void OptionsForm::stabilizeForm (void) |
425 |
|
|
{ |
426 |
capela |
1738 |
bool bValid = (m_iDirtyCount > 0); |
427 |
|
|
|
428 |
capela |
1509 |
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 |
schoenebeck |
1461 |
|
434 |
capela |
1738 |
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 |
capela |
1509 |
m_ui.AutoRefreshTimeSpinBox->setEnabled( |
443 |
|
|
m_ui.AutoRefreshCheckBox->isChecked()); |
444 |
|
|
m_ui.MessagesLimitLinesSpinBox->setEnabled( |
445 |
|
|
m_ui.MessagesLimitCheckBox->isChecked()); |
446 |
schoenebeck |
1461 |
|
447 |
capela |
2107 |
m_ui.DialogButtonBox->button(QDialogButtonBox::Ok)->setEnabled(bValid); |
448 |
schoenebeck |
1461 |
} |
449 |
|
|
|
450 |
|
|
|
451 |
capela |
1738 |
// 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 |
schoenebeck |
1461 |
// The channel display font selection dialog. |
470 |
|
|
void OptionsForm::chooseDisplayFont (void) |
471 |
|
|
{ |
472 |
capela |
1509 |
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 |
schoenebeck |
1461 |
} |
482 |
|
|
|
483 |
|
|
|
484 |
|
|
// The messages font selection dialog. |
485 |
|
|
void OptionsForm::chooseMessagesFont (void) |
486 |
|
|
{ |
487 |
capela |
1509 |
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 |
schoenebeck |
1461 |
} |
497 |
|
|
|
498 |
|
|
|
499 |
|
|
// The channel display effect demo changer. |
500 |
|
|
void OptionsForm::toggleDisplayEffect ( bool bOn ) |
501 |
|
|
{ |
502 |
capela |
1499 |
QPalette pal; |
503 |
capela |
3794 |
pal.setColor(QPalette::WindowText, Qt::green); |
504 |
capela |
1499 |
if (bOn) { |
505 |
capela |
2074 |
QPixmap pm(":/images/displaybg1.png"); |
506 |
capela |
3794 |
pal.setBrush(QPalette::Window, QBrush(pm)); |
507 |
capela |
1499 |
} else { |
508 |
capela |
3794 |
pal.setColor(QPalette::Window, Qt::black); |
509 |
capela |
1499 |
} |
510 |
capela |
1509 |
m_ui.DisplayFontTextLabel->setPalette(pal); |
511 |
schoenebeck |
1461 |
|
512 |
capela |
1499 |
optionsChanged(); |
513 |
schoenebeck |
1461 |
} |
514 |
|
|
|
515 |
schoenebeck |
1803 |
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 |
capela |
3648 |
|
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 |
capela |
3649 |
if (!sCustomColorTheme.isEmpty()) { |
569 |
capela |
3648 |
iCustomColorTheme = m_ui.CustomColorThemeComboBox->findText( |
570 |
|
|
sCustomColorTheme); |
571 |
capela |
3649 |
if (iCustomColorTheme < 0) |
572 |
|
|
iCustomColorTheme = 0; |
573 |
|
|
} |
574 |
capela |
3648 |
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 |
capela |
3649 |
if (!sCustomStyleTheme.isEmpty()) { |
589 |
capela |
3648 |
iCustomStyleTheme = m_ui.CustomStyleThemeComboBox->findText( |
590 |
|
|
sCustomStyleTheme); |
591 |
capela |
3649 |
if (iCustomStyleTheme < 0) |
592 |
|
|
iCustomStyleTheme = 0; |
593 |
|
|
} |
594 |
capela |
3648 |
m_ui.CustomStyleThemeComboBox->setCurrentIndex(iCustomStyleTheme); |
595 |
|
|
} |
596 |
|
|
|
597 |
|
|
|
598 |
schoenebeck |
1461 |
} // namespace QSampler |
599 |
capela |
1464 |
|
600 |
capela |
1466 |
// end of qsamplerOptionsForm.cpp |