Chris@0
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@0
|
2
|
Chris@0
|
3 /*
|
Chris@0
|
4 Sonic Visualiser
|
Chris@0
|
5 An audio file viewer and annotation editor.
|
Chris@0
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@0
|
7 This file copyright 2006 Chris Cannam.
|
Chris@0
|
8
|
Chris@0
|
9 This program is free software; you can redistribute it and/or
|
Chris@0
|
10 modify it under the terms of the GNU General Public License as
|
Chris@0
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@0
|
12 License, or (at your option) any later version. See the file
|
Chris@0
|
13 COPYING included with this distribution for more information.
|
Chris@0
|
14 */
|
Chris@0
|
15
|
Chris@0
|
16 #include "PreferencesDialog.h"
|
Chris@0
|
17
|
Chris@0
|
18 #include <QGridLayout>
|
Chris@0
|
19 #include <QComboBox>
|
Chris@0
|
20 #include <QCheckBox>
|
Chris@0
|
21 #include <QGroupBox>
|
Chris@0
|
22 #include <QDoubleSpinBox>
|
Chris@0
|
23 #include <QLabel>
|
Chris@0
|
24 #include <QPushButton>
|
Chris@0
|
25 #include <QHBoxLayout>
|
Chris@0
|
26 #include <QString>
|
Chris@163
|
27 #include <QDialogButtonBox>
|
Chris@163
|
28 #include <QMessageBox>
|
Chris@180
|
29 #include <QTabWidget>
|
Chris@180
|
30 #include <QLineEdit>
|
Chris@180
|
31 #include <QFileDialog>
|
Chris@180
|
32 #include <QMessageBox>
|
Chris@225
|
33 #include <QSpinBox>
|
Chris@263
|
34 #include <QSettings>
|
Chris@0
|
35
|
Chris@9
|
36 #include "widgets/WindowTypeSelector.h"
|
Chris@180
|
37 #include "widgets/IconLoader.h"
|
Chris@0
|
38 #include "base/Preferences.h"
|
Chris@263
|
39 #include "audioio/AudioTargetFactory.h"
|
Chris@0
|
40
|
Chris@0
|
41 PreferencesDialog::PreferencesDialog(QWidget *parent, Qt::WFlags flags) :
|
Chris@180
|
42 QDialog(parent, flags),
|
Chris@263
|
43 m_audioDevice(0),
|
Chris@180
|
44 m_changesOnRestart(false)
|
Chris@0
|
45 {
|
Chris@163
|
46 setWindowTitle(tr("Sonic Visualiser: Application Preferences"));
|
Chris@0
|
47
|
Chris@0
|
48 Preferences *prefs = Preferences::getInstance();
|
Chris@0
|
49
|
Chris@0
|
50 QGridLayout *grid = new QGridLayout;
|
Chris@0
|
51 setLayout(grid);
|
Chris@180
|
52
|
Chris@180
|
53 QTabWidget *tab = new QTabWidget;
|
Chris@180
|
54 grid->addWidget(tab, 0, 0);
|
Chris@0
|
55
|
Chris@180
|
56 tab->setTabPosition(QTabWidget::North);
|
Chris@0
|
57
|
Chris@0
|
58 // Create this first, as slots that get called from the ctor will
|
Chris@0
|
59 // refer to it
|
Chris@0
|
60 m_applyButton = new QPushButton(tr("Apply"));
|
Chris@0
|
61
|
Chris@180
|
62 // Create all the preference widgets first, then create the
|
Chris@180
|
63 // individual tab widgets and place the preferences in their
|
Chris@180
|
64 // appropriate places in one go afterwards
|
Chris@180
|
65
|
Chris@114
|
66 int min, max, deflt, i;
|
Chris@0
|
67
|
Chris@9
|
68 m_windowType = WindowType(prefs->getPropertyRangeAndValue
|
Chris@114
|
69 ("Window Type", &min, &max, &deflt));
|
Chris@9
|
70 m_windowTypeSelector = new WindowTypeSelector(m_windowType);
|
Chris@0
|
71
|
Chris@9
|
72 connect(m_windowTypeSelector, SIGNAL(windowTypeChanged(WindowType)),
|
Chris@9
|
73 this, SLOT(windowTypeChanged(WindowType)));
|
Chris@0
|
74
|
Chris@115
|
75 QComboBox *smoothing = new QComboBox;
|
Chris@115
|
76
|
Chris@115
|
77 int sm = prefs->getPropertyRangeAndValue("Spectrogram Smoothing", &min, &max,
|
Chris@115
|
78 &deflt);
|
Chris@115
|
79 m_spectrogramSmoothing = sm;
|
Chris@0
|
80
|
Chris@115
|
81 for (i = min; i <= max; ++i) {
|
Chris@115
|
82 smoothing->addItem(prefs->getPropertyValueLabel("Spectrogram Smoothing", i));
|
Chris@115
|
83 }
|
Chris@115
|
84
|
Chris@115
|
85 smoothing->setCurrentIndex(sm);
|
Chris@115
|
86
|
Chris@115
|
87 connect(smoothing, SIGNAL(currentIndexChanged(int)),
|
Chris@115
|
88 this, SLOT(spectrogramSmoothingChanged(int)));
|
Chris@0
|
89
|
Chris@0
|
90 QComboBox *propertyLayout = new QComboBox;
|
Chris@114
|
91 int pl = prefs->getPropertyRangeAndValue("Property Box Layout", &min, &max,
|
Chris@115
|
92 &deflt);
|
Chris@0
|
93 m_propertyLayout = pl;
|
Chris@0
|
94
|
Chris@0
|
95 for (i = min; i <= max; ++i) {
|
Chris@0
|
96 propertyLayout->addItem(prefs->getPropertyValueLabel("Property Box Layout", i));
|
Chris@0
|
97 }
|
Chris@0
|
98
|
Chris@0
|
99 propertyLayout->setCurrentIndex(pl);
|
Chris@0
|
100
|
Chris@0
|
101 connect(propertyLayout, SIGNAL(currentIndexChanged(int)),
|
Chris@0
|
102 this, SLOT(propertyLayoutChanged(int)));
|
Chris@0
|
103
|
Chris@0
|
104 m_tuningFrequency = prefs->getTuningFrequency();
|
Chris@0
|
105
|
Chris@0
|
106 QDoubleSpinBox *frequency = new QDoubleSpinBox;
|
Chris@0
|
107 frequency->setMinimum(100.0);
|
Chris@0
|
108 frequency->setMaximum(5000.0);
|
Chris@0
|
109 frequency->setSuffix(" Hz");
|
Chris@0
|
110 frequency->setSingleStep(1);
|
Chris@0
|
111 frequency->setValue(m_tuningFrequency);
|
Chris@0
|
112 frequency->setDecimals(2);
|
Chris@0
|
113
|
Chris@0
|
114 connect(frequency, SIGNAL(valueChanged(double)),
|
Chris@0
|
115 this, SLOT(tuningFrequencyChanged(double)));
|
Chris@0
|
116
|
Chris@263
|
117 QComboBox *audioDevice = new QComboBox;
|
Chris@263
|
118 std::vector<QString> devices =
|
Chris@263
|
119 AudioTargetFactory::getInstance()->getCallbackTargetNames();
|
Chris@263
|
120
|
Chris@263
|
121 QSettings settings;
|
Chris@263
|
122 settings.beginGroup("Preferences");
|
Chris@263
|
123 QString targetName = settings.value("audio-target", "").toString();
|
Chris@263
|
124 settings.endGroup();
|
Chris@263
|
125
|
Chris@263
|
126 for (int i = 0; i < devices.size(); ++i) {
|
Chris@263
|
127 audioDevice->addItem(AudioTargetFactory::getInstance()
|
Chris@263
|
128 ->getCallbackTargetDescription(devices[i]));
|
Chris@263
|
129 if (targetName == devices[i]) audioDevice->setCurrentIndex(i);
|
Chris@263
|
130 }
|
Chris@263
|
131
|
Chris@263
|
132 connect(audioDevice, SIGNAL(currentIndexChanged(int)),
|
Chris@263
|
133 this, SLOT(audioDeviceChanged(int)));
|
Chris@263
|
134
|
Chris@32
|
135 QComboBox *resampleQuality = new QComboBox;
|
Chris@32
|
136
|
Chris@114
|
137 int rsq = prefs->getPropertyRangeAndValue("Resample Quality", &min, &max,
|
Chris@114
|
138 &deflt);
|
Chris@32
|
139 m_resampleQuality = rsq;
|
Chris@32
|
140
|
Chris@32
|
141 for (i = min; i <= max; ++i) {
|
Chris@32
|
142 resampleQuality->addItem(prefs->getPropertyValueLabel("Resample Quality", i));
|
Chris@32
|
143 }
|
Chris@32
|
144
|
Chris@32
|
145 resampleQuality->setCurrentIndex(rsq);
|
Chris@32
|
146
|
Chris@32
|
147 connect(resampleQuality, SIGNAL(currentIndexChanged(int)),
|
Chris@32
|
148 this, SLOT(resampleQualityChanged(int)));
|
Chris@32
|
149
|
Chris@180
|
150 QCheckBox *resampleOnLoad = new QCheckBox;
|
Chris@180
|
151 m_resampleOnLoad = prefs->getResampleOnLoad();
|
Chris@180
|
152 resampleOnLoad->setCheckState(m_resampleOnLoad ? Qt::Checked :
|
Chris@180
|
153 Qt::Unchecked);
|
Chris@180
|
154 connect(resampleOnLoad, SIGNAL(stateChanged(int)),
|
Chris@180
|
155 this, SLOT(resampleOnLoadChanged(int)));
|
Chris@180
|
156
|
Chris@180
|
157 m_tempDirRootEdit = new QLineEdit;
|
Chris@180
|
158 QString dir = prefs->getTemporaryDirectoryRoot();
|
Chris@180
|
159 m_tempDirRoot = dir;
|
Chris@180
|
160 dir.replace("$HOME", tr("<home directory>"));
|
Chris@180
|
161 m_tempDirRootEdit->setText(dir);
|
Chris@180
|
162 m_tempDirRootEdit->setReadOnly(true);
|
Chris@180
|
163 QPushButton *tempDirButton = new QPushButton;
|
Chris@180
|
164 tempDirButton->setIcon(IconLoader().load("fileopen"));
|
Chris@180
|
165 connect(tempDirButton, SIGNAL(clicked()),
|
Chris@180
|
166 this, SLOT(tempDirButtonClicked()));
|
Chris@180
|
167 tempDirButton->setFixedSize(QSize(24, 24));
|
Chris@180
|
168
|
Chris@237
|
169 QCheckBox *showSplash = new QCheckBox;
|
Chris@237
|
170 m_showSplash = prefs->getShowSplash();
|
Chris@237
|
171 showSplash->setCheckState(m_showSplash ? Qt::Checked : Qt::Unchecked);
|
Chris@237
|
172 connect(showSplash, SIGNAL(stateChanged(int)),
|
Chris@237
|
173 this, SLOT(showSplashChanged(int)));
|
Chris@237
|
174
|
Chris@237
|
175 #ifndef Q_WS_MAC
|
Chris@180
|
176 QComboBox *bgMode = new QComboBox;
|
Chris@180
|
177 int bg = prefs->getPropertyRangeAndValue("Background Mode", &min, &max,
|
Chris@180
|
178 &deflt);
|
Chris@180
|
179 m_backgroundMode = bg;
|
Chris@180
|
180 for (i = min; i <= max; ++i) {
|
Chris@180
|
181 bgMode->addItem(prefs->getPropertyValueLabel("Background Mode", i));
|
Chris@180
|
182 }
|
Chris@180
|
183 bgMode->setCurrentIndex(bg);
|
Chris@180
|
184
|
Chris@180
|
185 connect(bgMode, SIGNAL(currentIndexChanged(int)),
|
Chris@180
|
186 this, SLOT(backgroundModeChanged(int)));
|
Chris@237
|
187 #endif
|
Chris@180
|
188
|
Chris@225
|
189 QSpinBox *fontSize = new QSpinBox;
|
Chris@225
|
190 int fs = prefs->getPropertyRangeAndValue("View Font Size", &min, &max,
|
Chris@225
|
191 &deflt);
|
Chris@234
|
192 m_viewFontSize = fs;
|
Chris@225
|
193 fontSize->setMinimum(min);
|
Chris@225
|
194 fontSize->setMaximum(max);
|
Chris@225
|
195 fontSize->setSuffix(" pt");
|
Chris@225
|
196 fontSize->setSingleStep(1);
|
Chris@225
|
197 fontSize->setValue(fs);
|
Chris@225
|
198
|
Chris@225
|
199 connect(fontSize, SIGNAL(valueChanged(int)),
|
Chris@225
|
200 this, SLOT(viewFontSizeChanged(int)));
|
Chris@225
|
201
|
Chris@180
|
202 // General tab
|
Chris@180
|
203
|
Chris@180
|
204 QFrame *frame = new QFrame;
|
Chris@180
|
205
|
Chris@180
|
206 QGridLayout *subgrid = new QGridLayout;
|
Chris@180
|
207 frame->setLayout(subgrid);
|
Chris@180
|
208
|
Chris@0
|
209 int row = 0;
|
Chris@0
|
210
|
Chris@0
|
211 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
Chris@263
|
212 ("Temporary Directory Root"))),
|
Chris@263
|
213 row, 0);
|
Chris@263
|
214 subgrid->addWidget(m_tempDirRootEdit, row, 1, 1, 1);
|
Chris@263
|
215 subgrid->addWidget(tempDirButton, row, 2, 1, 1);
|
Chris@263
|
216 row++;
|
Chris@263
|
217
|
Chris@263
|
218 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
Chris@263
|
219 ("Resample On Load"))),
|
Chris@263
|
220 row, 0);
|
Chris@263
|
221 subgrid->addWidget(resampleOnLoad, row++, 1, 1, 1);
|
Chris@263
|
222
|
Chris@263
|
223 subgrid->addWidget(new QLabel(tr("Playback audio device:")), row, 0);
|
Chris@263
|
224 subgrid->addWidget(audioDevice, row++, 1, 1, 2);
|
Chris@263
|
225
|
Chris@263
|
226 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
Chris@263
|
227 ("Resample Quality"))),
|
Chris@263
|
228 row, 0);
|
Chris@263
|
229 subgrid->addWidget(resampleQuality, row++, 1, 1, 2);
|
Chris@263
|
230
|
Chris@263
|
231 subgrid->setRowStretch(row, 10);
|
Chris@263
|
232
|
Chris@263
|
233 tab->addTab(frame, tr("&General"));
|
Chris@263
|
234
|
Chris@263
|
235 // Appearance tab
|
Chris@263
|
236
|
Chris@263
|
237 frame = new QFrame;
|
Chris@263
|
238 subgrid = new QGridLayout;
|
Chris@263
|
239 frame->setLayout(subgrid);
|
Chris@263
|
240 row = 0;
|
Chris@263
|
241
|
Chris@263
|
242 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
Chris@0
|
243 ("Property Box Layout"))),
|
Chris@0
|
244 row, 0);
|
Chris@0
|
245 subgrid->addWidget(propertyLayout, row++, 1, 1, 2);
|
Chris@0
|
246
|
Chris@242
|
247 #ifndef Q_WS_MAC
|
Chris@0
|
248 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
Chris@180
|
249 ("Background Mode"))),
|
Chris@0
|
250 row, 0);
|
Chris@180
|
251 subgrid->addWidget(bgMode, row++, 1, 1, 2);
|
Chris@242
|
252 #endif
|
Chris@180
|
253
|
Chris@180
|
254 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
Chris@225
|
255 ("View Font Size"))),
|
Chris@225
|
256 row, 0);
|
Chris@225
|
257 subgrid->addWidget(fontSize, row++, 1, 1, 2);
|
Chris@225
|
258
|
Chris@225
|
259 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
Chris@237
|
260 ("Show Splash Screen"))),
|
Chris@237
|
261 row, 0);
|
Chris@237
|
262 subgrid->addWidget(showSplash, row++, 1, 1, 1);
|
Chris@237
|
263
|
Chris@180
|
264 subgrid->setRowStretch(row, 10);
|
Chris@180
|
265
|
Chris@263
|
266 tab->addTab(frame, tr("&Appearance"));
|
Chris@180
|
267
|
Chris@180
|
268 // Analysis tab
|
Chris@180
|
269
|
Chris@180
|
270 frame = new QFrame;
|
Chris@180
|
271 subgrid = new QGridLayout;
|
Chris@180
|
272 frame->setLayout(subgrid);
|
Chris@180
|
273 row = 0;
|
Chris@180
|
274
|
Chris@180
|
275 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
Chris@180
|
276 ("Tuning Frequency"))),
|
Chris@180
|
277 row, 0);
|
Chris@180
|
278 subgrid->addWidget(frequency, row++, 1, 1, 2);
|
Chris@180
|
279
|
Chris@0
|
280 subgrid->addWidget(new QLabel(prefs->getPropertyLabel
|
Chris@115
|
281 ("Spectrogram Smoothing")),
|
Chris@115
|
282 row, 0);
|
Chris@115
|
283 subgrid->addWidget(smoothing, row++, 1, 1, 2);
|
Chris@0
|
284
|
Chris@0
|
285 subgrid->addWidget(new QLabel(tr("%1:").arg(prefs->getPropertyLabel
|
Chris@0
|
286 ("Window Type"))),
|
Chris@0
|
287 row, 0);
|
Chris@9
|
288 subgrid->addWidget(m_windowTypeSelector, row++, 1, 2, 2);
|
Chris@9
|
289 subgrid->setRowStretch(row, 10);
|
Chris@9
|
290 row++;
|
Chris@0
|
291
|
Chris@180
|
292 subgrid->setRowStretch(row, 10);
|
Chris@180
|
293
|
Chris@263
|
294 tab->addTab(frame, tr("Anal&ysis"));
|
Chris@180
|
295
|
Chris@163
|
296 QDialogButtonBox *bb = new QDialogButtonBox(Qt::Horizontal);
|
Chris@163
|
297 grid->addWidget(bb, 1, 0);
|
Chris@0
|
298
|
Chris@0
|
299 QPushButton *ok = new QPushButton(tr("OK"));
|
Chris@0
|
300 QPushButton *cancel = new QPushButton(tr("Cancel"));
|
Chris@163
|
301 bb->addButton(ok, QDialogButtonBox::AcceptRole);
|
Chris@163
|
302 bb->addButton(m_applyButton, QDialogButtonBox::ApplyRole);
|
Chris@163
|
303 bb->addButton(cancel, QDialogButtonBox::RejectRole);
|
Chris@0
|
304 connect(ok, SIGNAL(clicked()), this, SLOT(okClicked()));
|
Chris@0
|
305 connect(m_applyButton, SIGNAL(clicked()), this, SLOT(applyClicked()));
|
Chris@0
|
306 connect(cancel, SIGNAL(clicked()), this, SLOT(cancelClicked()));
|
Chris@0
|
307
|
Chris@0
|
308 m_applyButton->setEnabled(false);
|
Chris@0
|
309 }
|
Chris@0
|
310
|
Chris@0
|
311 PreferencesDialog::~PreferencesDialog()
|
Chris@0
|
312 {
|
Chris@0
|
313 std::cerr << "PreferencesDialog::~PreferencesDialog()" << std::endl;
|
Chris@0
|
314 }
|
Chris@0
|
315
|
Chris@0
|
316 void
|
Chris@9
|
317 PreferencesDialog::windowTypeChanged(WindowType type)
|
Chris@0
|
318 {
|
Chris@0
|
319 m_windowType = type;
|
Chris@0
|
320 m_applyButton->setEnabled(true);
|
Chris@0
|
321 }
|
Chris@0
|
322
|
Chris@0
|
323 void
|
Chris@115
|
324 PreferencesDialog::spectrogramSmoothingChanged(int smoothing)
|
Chris@0
|
325 {
|
Chris@115
|
326 m_spectrogramSmoothing = smoothing;
|
Chris@0
|
327 m_applyButton->setEnabled(true);
|
Chris@0
|
328 }
|
Chris@0
|
329
|
Chris@0
|
330 void
|
Chris@0
|
331 PreferencesDialog::propertyLayoutChanged(int layout)
|
Chris@0
|
332 {
|
Chris@0
|
333 m_propertyLayout = layout;
|
Chris@0
|
334 m_applyButton->setEnabled(true);
|
Chris@0
|
335 }
|
Chris@0
|
336
|
Chris@0
|
337 void
|
Chris@0
|
338 PreferencesDialog::tuningFrequencyChanged(double freq)
|
Chris@0
|
339 {
|
Chris@0
|
340 m_tuningFrequency = freq;
|
Chris@0
|
341 m_applyButton->setEnabled(true);
|
Chris@0
|
342 }
|
Chris@0
|
343
|
Chris@0
|
344 void
|
Chris@263
|
345 PreferencesDialog::audioDeviceChanged(int s)
|
Chris@263
|
346 {
|
Chris@263
|
347 m_audioDevice = s;
|
Chris@263
|
348 m_applyButton->setEnabled(true);
|
Chris@263
|
349 m_changesOnRestart = true;
|
Chris@263
|
350 }
|
Chris@263
|
351
|
Chris@263
|
352 void
|
Chris@32
|
353 PreferencesDialog::resampleQualityChanged(int q)
|
Chris@32
|
354 {
|
Chris@32
|
355 m_resampleQuality = q;
|
Chris@32
|
356 m_applyButton->setEnabled(true);
|
Chris@32
|
357 }
|
Chris@32
|
358
|
Chris@32
|
359 void
|
Chris@180
|
360 PreferencesDialog::resampleOnLoadChanged(int state)
|
Chris@180
|
361 {
|
Chris@180
|
362 m_resampleOnLoad = (state == Qt::Checked);
|
Chris@180
|
363 m_applyButton->setEnabled(true);
|
Chris@180
|
364 m_changesOnRestart = true;
|
Chris@180
|
365 }
|
Chris@180
|
366
|
Chris@180
|
367 void
|
Chris@237
|
368 PreferencesDialog::showSplashChanged(int state)
|
Chris@237
|
369 {
|
Chris@237
|
370 m_showSplash = (state == Qt::Checked);
|
Chris@237
|
371 m_applyButton->setEnabled(true);
|
Chris@237
|
372 m_changesOnRestart = true;
|
Chris@237
|
373 }
|
Chris@237
|
374
|
Chris@237
|
375 void
|
Chris@180
|
376 PreferencesDialog::tempDirRootChanged(QString r)
|
Chris@180
|
377 {
|
Chris@180
|
378 m_tempDirRoot = r;
|
Chris@180
|
379 m_applyButton->setEnabled(true);
|
Chris@180
|
380 }
|
Chris@180
|
381
|
Chris@180
|
382 void
|
Chris@180
|
383 PreferencesDialog::tempDirButtonClicked()
|
Chris@180
|
384 {
|
Chris@180
|
385 QString dir = QFileDialog::getExistingDirectory
|
Chris@180
|
386 (this, tr("Select a directory to create cache subdirectory in"),
|
Chris@180
|
387 m_tempDirRoot);
|
Chris@180
|
388 if (dir == "") return;
|
Chris@180
|
389 m_tempDirRootEdit->setText(dir);
|
Chris@180
|
390 tempDirRootChanged(dir);
|
Chris@180
|
391 m_changesOnRestart = true;
|
Chris@180
|
392 }
|
Chris@180
|
393
|
Chris@180
|
394 void
|
Chris@180
|
395 PreferencesDialog::backgroundModeChanged(int mode)
|
Chris@180
|
396 {
|
Chris@180
|
397 m_backgroundMode = mode;
|
Chris@180
|
398 m_applyButton->setEnabled(true);
|
Chris@180
|
399 m_changesOnRestart = true;
|
Chris@180
|
400 }
|
Chris@180
|
401
|
Chris@180
|
402 void
|
Chris@225
|
403 PreferencesDialog::viewFontSizeChanged(int sz)
|
Chris@225
|
404 {
|
Chris@225
|
405 m_viewFontSize = sz;
|
Chris@225
|
406 m_applyButton->setEnabled(true);
|
Chris@225
|
407 }
|
Chris@225
|
408
|
Chris@225
|
409 void
|
Chris@0
|
410 PreferencesDialog::okClicked()
|
Chris@0
|
411 {
|
Chris@0
|
412 applyClicked();
|
Chris@0
|
413 accept();
|
Chris@0
|
414 }
|
Chris@0
|
415
|
Chris@0
|
416 void
|
Chris@0
|
417 PreferencesDialog::applyClicked()
|
Chris@0
|
418 {
|
Chris@0
|
419 Preferences *prefs = Preferences::getInstance();
|
Chris@0
|
420 prefs->setWindowType(WindowType(m_windowType));
|
Chris@115
|
421 prefs->setSpectrogramSmoothing(Preferences::SpectrogramSmoothing
|
Chris@115
|
422 (m_spectrogramSmoothing));
|
Chris@0
|
423 prefs->setPropertyBoxLayout(Preferences::PropertyBoxLayout
|
Chris@0
|
424 (m_propertyLayout));
|
Chris@0
|
425 prefs->setTuningFrequency(m_tuningFrequency);
|
Chris@32
|
426 prefs->setResampleQuality(m_resampleQuality);
|
Chris@180
|
427 prefs->setResampleOnLoad(m_resampleOnLoad);
|
Chris@237
|
428 prefs->setShowSplash(m_showSplash);
|
Chris@180
|
429 prefs->setTemporaryDirectoryRoot(m_tempDirRoot);
|
Chris@180
|
430 prefs->setBackgroundMode(Preferences::BackgroundMode(m_backgroundMode));
|
Chris@225
|
431 prefs->setViewFontSize(m_viewFontSize);
|
Chris@263
|
432
|
Chris@263
|
433 std::vector<QString> devices =
|
Chris@263
|
434 AudioTargetFactory::getInstance()->getCallbackTargetNames();
|
Chris@263
|
435
|
Chris@263
|
436 QSettings settings;
|
Chris@263
|
437 settings.beginGroup("Preferences");
|
Chris@263
|
438 settings.setValue("audio-target", devices[m_audioDevice]);
|
Chris@263
|
439 settings.endGroup();
|
Chris@180
|
440
|
Chris@0
|
441 m_applyButton->setEnabled(false);
|
Chris@180
|
442
|
Chris@180
|
443 if (m_changesOnRestart) {
|
Chris@180
|
444 QMessageBox::information(this, tr("Preferences"),
|
Chris@255
|
445 tr("<b>Restart required</b><p>One or more of the application preferences you have changed may not take full effect until Sonic Visualiser is restarted.</p><p>Please exit and restart the application now if you want these changes to take effect immediately.</p>"));
|
Chris@180
|
446 m_changesOnRestart = false;
|
Chris@180
|
447 }
|
Chris@0
|
448 }
|
Chris@0
|
449
|
Chris@0
|
450 void
|
Chris@0
|
451 PreferencesDialog::cancelClicked()
|
Chris@0
|
452 {
|
Chris@0
|
453 reject();
|
Chris@0
|
454 }
|
Chris@0
|
455
|
Chris@163
|
456 void
|
Chris@163
|
457 PreferencesDialog::applicationClosing(bool quickly)
|
Chris@163
|
458 {
|
Chris@163
|
459 if (quickly) {
|
Chris@163
|
460 reject();
|
Chris@163
|
461 return;
|
Chris@163
|
462 }
|
Chris@163
|
463
|
Chris@163
|
464 if (m_applyButton->isEnabled()) {
|
Chris@163
|
465 int rv = QMessageBox::warning
|
Chris@163
|
466 (this, tr("Preferences Changed"),
|
Chris@163
|
467 tr("Some preferences have been changed but not applied.\n"
|
Chris@163
|
468 "Apply them before closing?"),
|
Chris@163
|
469 QMessageBox::Apply | QMessageBox::Discard,
|
Chris@163
|
470 QMessageBox::Discard);
|
Chris@163
|
471 if (rv == QMessageBox::Apply) {
|
Chris@163
|
472 applyClicked();
|
Chris@163
|
473 accept();
|
Chris@163
|
474 } else {
|
Chris@163
|
475 reject();
|
Chris@163
|
476 }
|
Chris@163
|
477 } else {
|
Chris@163
|
478 accept();
|
Chris@163
|
479 }
|
Chris@163
|
480 }
|
Chris@163
|
481
|