Chris@136
|
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
|
Chris@136
|
2
|
Chris@136
|
3 /*
|
Chris@136
|
4 Sonic Visualiser
|
Chris@136
|
5 An audio file viewer and annotation editor.
|
Chris@136
|
6 Centre for Digital Music, Queen Mary, University of London.
|
Chris@202
|
7 This file copyright 2006 Chris Cannam and QMUL.
|
Chris@136
|
8
|
Chris@136
|
9 This program is free software; you can redistribute it and/or
|
Chris@136
|
10 modify it under the terms of the GNU General Public License as
|
Chris@136
|
11 published by the Free Software Foundation; either version 2 of the
|
Chris@136
|
12 License, or (at your option) any later version. See the file
|
Chris@136
|
13 COPYING included with this distribution for more information.
|
Chris@136
|
14 */
|
Chris@136
|
15
|
Chris@136
|
16 #include "Preferences.h"
|
Chris@136
|
17
|
Chris@145
|
18 #include "Exceptions.h"
|
Chris@145
|
19
|
Chris@145
|
20 #include "TempDirectory.h"
|
Chris@145
|
21
|
Chris@145
|
22 #include <QDir>
|
Chris@145
|
23 #include <QFileInfo>
|
Chris@156
|
24 #include <QMutex>
|
Chris@156
|
25 #include <QSettings>
|
Chris@145
|
26
|
Chris@136
|
27 Preferences *
|
Chris@156
|
28 Preferences::m_instance = 0;
|
Chris@156
|
29
|
Chris@156
|
30 Preferences *
|
Chris@156
|
31 Preferences::getInstance()
|
Chris@156
|
32 {
|
Chris@156
|
33 if (!m_instance) m_instance = new Preferences();
|
Chris@156
|
34 return m_instance;
|
Chris@156
|
35 }
|
Chris@136
|
36
|
Chris@136
|
37 Preferences::Preferences() :
|
Chris@553
|
38 m_spectrogramSmoothing(SpectrogramInterpolated),
|
Chris@553
|
39 m_spectrogramXSmoothing(SpectrogramXInterpolated),
|
Chris@140
|
40 m_tuningFrequency(440),
|
Chris@140
|
41 m_propertyBoxLayout(VerticallyStacked),
|
Chris@164
|
42 m_windowType(HanningWindow),
|
Chris@277
|
43 m_resampleQuality(1),
|
Chris@297
|
44 m_omitRecentTemps(true),
|
Chris@297
|
45 m_tempDirRoot(""),
|
Chris@919
|
46 m_fixedSampleRate(0),
|
Chris@354
|
47 m_resampleOnLoad(false),
|
Chris@354
|
48 m_viewFontSize(10),
|
Chris@372
|
49 m_backgroundMode(BackgroundFromTheme),
|
Chris@612
|
50 m_timeToTextMode(TimeToTextMs),
|
Chris@892
|
51 m_octave(4),
|
Chris@372
|
52 m_showSplash(true)
|
Chris@136
|
53 {
|
Chris@156
|
54 QSettings settings;
|
Chris@156
|
55 settings.beginGroup("Preferences");
|
Chris@246
|
56 m_spectrogramSmoothing = SpectrogramSmoothing
|
Chris@553
|
57 (settings.value("spectrogram-y-smoothing", int(m_spectrogramSmoothing)).toInt());
|
Chris@553
|
58 m_spectrogramXSmoothing = SpectrogramXSmoothing
|
Chris@553
|
59 (settings.value("spectrogram-x-smoothing", int(m_spectrogramXSmoothing)).toInt());
|
Chris@156
|
60 m_tuningFrequency = settings.value("tuning-frequency", 440.f).toDouble();
|
Chris@145
|
61 m_propertyBoxLayout = PropertyBoxLayout
|
Chris@156
|
62 (settings.value("property-box-layout", int(VerticallyStacked)).toInt());
|
Chris@145
|
63 m_windowType = WindowType
|
Chris@156
|
64 (settings.value("window-type", int(HanningWindow)).toInt());
|
Chris@164
|
65 m_resampleQuality = settings.value("resample-quality", 1).toInt();
|
Chris@919
|
66 m_fixedSampleRate = settings.value("fixed-sample-rate", 0).toInt();
|
Chris@304
|
67 m_resampleOnLoad = settings.value("resample-on-load", false).toBool();
|
Chris@297
|
68 m_backgroundMode = BackgroundMode
|
Chris@297
|
69 (settings.value("background-mode", int(BackgroundFromTheme)).toInt());
|
Chris@612
|
70 m_timeToTextMode = TimeToTextMode
|
Chris@612
|
71 (settings.value("time-to-text-mode", int(TimeToTextMs)).toInt());
|
Chris@892
|
72 m_octave = (settings.value("octave-of-middle-c", 4)).toInt();
|
Chris@387
|
73 m_viewFontSize = settings.value("view-font-size", 10).toInt();
|
Chris@372
|
74 m_showSplash = settings.value("show-splash", true).toBool();
|
Chris@297
|
75 settings.endGroup();
|
Chris@297
|
76
|
Chris@297
|
77 settings.beginGroup("TempDirectory");
|
Chris@297
|
78 m_tempDirRoot = settings.value("create-in", "$HOME").toString();
|
Chris@156
|
79 settings.endGroup();
|
Chris@145
|
80 }
|
Chris@145
|
81
|
Chris@145
|
82 Preferences::~Preferences()
|
Chris@145
|
83 {
|
Chris@136
|
84 }
|
Chris@136
|
85
|
Chris@136
|
86 Preferences::PropertyList
|
Chris@136
|
87 Preferences::getProperties() const
|
Chris@136
|
88 {
|
Chris@136
|
89 PropertyList props;
|
Chris@553
|
90 props.push_back("Spectrogram Y Smoothing");
|
Chris@553
|
91 props.push_back("Spectrogram X Smoothing");
|
Chris@136
|
92 props.push_back("Tuning Frequency");
|
Chris@138
|
93 props.push_back("Property Box Layout");
|
Chris@140
|
94 props.push_back("Window Type");
|
Chris@164
|
95 props.push_back("Resample Quality");
|
Chris@277
|
96 props.push_back("Omit Temporaries from Recent Files");
|
Chris@297
|
97 props.push_back("Resample On Load");
|
Chris@919
|
98 props.push_back("Fixed Sample Rate");
|
Chris@297
|
99 props.push_back("Temporary Directory Root");
|
Chris@297
|
100 props.push_back("Background Mode");
|
Chris@612
|
101 props.push_back("Time To Text Mode");
|
Chris@892
|
102 props.push_back("Octave Numbering System");
|
Chris@354
|
103 props.push_back("View Font Size");
|
Chris@372
|
104 props.push_back("Show Splash Screen");
|
Chris@136
|
105 return props;
|
Chris@136
|
106 }
|
Chris@136
|
107
|
Chris@136
|
108 QString
|
Chris@136
|
109 Preferences::getPropertyLabel(const PropertyName &name) const
|
Chris@136
|
110 {
|
Chris@553
|
111 if (name == "Spectrogram Y Smoothing") {
|
Chris@372
|
112 return tr("Spectrogram y-axis interpolation:");
|
Chris@136
|
113 }
|
Chris@553
|
114 if (name == "Spectrogram X Smoothing") {
|
Chris@553
|
115 return tr("Spectrogram x-axis interpolation:");
|
Chris@553
|
116 }
|
Chris@136
|
117 if (name == "Tuning Frequency") {
|
Chris@141
|
118 return tr("Frequency of concert A");
|
Chris@136
|
119 }
|
Chris@138
|
120 if (name == "Property Box Layout") {
|
Chris@141
|
121 return tr("Property box layout");
|
Chris@138
|
122 }
|
Chris@140
|
123 if (name == "Window Type") {
|
Chris@141
|
124 return tr("Spectral analysis window shape");
|
Chris@140
|
125 }
|
Chris@164
|
126 if (name == "Resample Quality") {
|
Chris@165
|
127 return tr("Playback resampler type");
|
Chris@164
|
128 }
|
Chris@277
|
129 if (name == "Omit Temporaries from Recent Files") {
|
Chris@297
|
130 return tr("Omit temporaries from Recent Files menu");
|
Chris@297
|
131 }
|
Chris@297
|
132 if (name == "Resample On Load") {
|
Chris@297
|
133 return tr("Resample mismatching files on import");
|
Chris@297
|
134 }
|
Chris@919
|
135 if (name == "Fixed Sample Rate") {
|
Chris@919
|
136 return tr("Single fixed sample rate to resample all files to");
|
Chris@919
|
137 }
|
Chris@297
|
138 if (name == "Temporary Directory Root") {
|
Chris@297
|
139 return tr("Location for cache file directory");
|
Chris@297
|
140 }
|
Chris@297
|
141 if (name == "Background Mode") {
|
Chris@297
|
142 return tr("Background colour preference");
|
Chris@277
|
143 }
|
Chris@612
|
144 if (name == "Time To Text Mode") {
|
Chris@612
|
145 return tr("Time display format");
|
Chris@612
|
146 }
|
Chris@892
|
147 if (name == "Octave Numbering System") {
|
Chris@892
|
148 return tr("Label middle C as");
|
Chris@892
|
149 }
|
Chris@354
|
150 if (name == "View Font Size") {
|
Chris@354
|
151 return tr("Font size for text overlays");
|
Chris@354
|
152 }
|
Chris@372
|
153 if (name == "Show Splash Screen") {
|
Chris@372
|
154 return tr("Show splash screen on startup");
|
Chris@372
|
155 }
|
Chris@136
|
156 return name;
|
Chris@136
|
157 }
|
Chris@136
|
158
|
Chris@136
|
159 Preferences::PropertyType
|
Chris@136
|
160 Preferences::getPropertyType(const PropertyName &name) const
|
Chris@136
|
161 {
|
Chris@553
|
162 if (name == "Spectrogram Y Smoothing") {
|
Chris@553
|
163 return ValueProperty;
|
Chris@553
|
164 }
|
Chris@553
|
165 if (name == "Spectrogram X Smoothing") {
|
Chris@246
|
166 return ValueProperty;
|
Chris@136
|
167 }
|
Chris@136
|
168 if (name == "Tuning Frequency") {
|
Chris@136
|
169 return RangeProperty;
|
Chris@136
|
170 }
|
Chris@138
|
171 if (name == "Property Box Layout") {
|
Chris@138
|
172 return ValueProperty;
|
Chris@138
|
173 }
|
Chris@140
|
174 if (name == "Window Type") {
|
Chris@140
|
175 return ValueProperty;
|
Chris@140
|
176 }
|
Chris@164
|
177 if (name == "Resample Quality") {
|
Chris@164
|
178 return ValueProperty;
|
Chris@164
|
179 }
|
Chris@277
|
180 if (name == "Omit Temporaries from Recent Files") {
|
Chris@277
|
181 return ToggleProperty;
|
Chris@277
|
182 }
|
Chris@297
|
183 if (name == "Resample On Load") {
|
Chris@297
|
184 return ToggleProperty;
|
Chris@297
|
185 }
|
Chris@919
|
186 if (name == "Fixed Sample Rate") {
|
Chris@919
|
187 return ValueProperty;
|
Chris@919
|
188 }
|
Chris@297
|
189 if (name == "Temporary Directory Root") {
|
Chris@297
|
190 // It's an arbitrary string, we don't have a set of values for this
|
Chris@297
|
191 return InvalidProperty;
|
Chris@297
|
192 }
|
Chris@297
|
193 if (name == "Background Mode") {
|
Chris@297
|
194 return ValueProperty;
|
Chris@297
|
195 }
|
Chris@612
|
196 if (name == "Time To Text Mode") {
|
Chris@612
|
197 return ValueProperty;
|
Chris@612
|
198 }
|
Chris@892
|
199 if (name == "Octave Numbering System") {
|
Chris@892
|
200 return ValueProperty;
|
Chris@892
|
201 }
|
Chris@354
|
202 if (name == "View Font Size") {
|
Chris@354
|
203 return RangeProperty;
|
Chris@354
|
204 }
|
Chris@372
|
205 if (name == "Show Splash Screen") {
|
Chris@372
|
206 return ToggleProperty;
|
Chris@372
|
207 }
|
Chris@136
|
208 return InvalidProperty;
|
Chris@136
|
209 }
|
Chris@136
|
210
|
Chris@136
|
211 int
|
Chris@136
|
212 Preferences::getPropertyRangeAndValue(const PropertyName &name,
|
Chris@245
|
213 int *min, int *max, int *deflt) const
|
Chris@136
|
214 {
|
Chris@553
|
215 if (name == "Spectrogram Y Smoothing") {
|
Chris@136
|
216 if (min) *min = 0;
|
Chris@553
|
217 if (max) *max = 3;
|
Chris@553
|
218 if (deflt) *deflt = int(SpectrogramInterpolated);
|
Chris@246
|
219 return int(m_spectrogramSmoothing);
|
Chris@136
|
220 }
|
Chris@553
|
221 if (name == "Spectrogram X Smoothing") {
|
Chris@553
|
222 if (min) *min = 0;
|
Chris@553
|
223 if (max) *max = 1;
|
Chris@553
|
224 if (deflt) *deflt = int(SpectrogramXInterpolated);
|
Chris@553
|
225 return int(m_spectrogramXSmoothing);
|
Chris@553
|
226 }
|
Chris@136
|
227
|
Chris@136
|
228 //!!! freq mapping
|
Chris@136
|
229
|
Chris@138
|
230 if (name == "Property Box Layout") {
|
Chris@138
|
231 if (min) *min = 0;
|
Chris@138
|
232 if (max) *max = 1;
|
Chris@245
|
233 if (deflt) *deflt = 0;
|
Chris@138
|
234 return m_propertyBoxLayout == Layered ? 1 : 0;
|
Chris@138
|
235 }
|
Chris@138
|
236
|
Chris@140
|
237 if (name == "Window Type") {
|
Chris@140
|
238 if (min) *min = int(RectangularWindow);
|
Chris@142
|
239 if (max) *max = int(BlackmanHarrisWindow);
|
Chris@245
|
240 if (deflt) *deflt = int(HanningWindow);
|
Chris@140
|
241 return int(m_windowType);
|
Chris@140
|
242 }
|
Chris@140
|
243
|
Chris@164
|
244 if (name == "Resample Quality") {
|
Chris@164
|
245 if (min) *min = 0;
|
Chris@164
|
246 if (max) *max = 2;
|
Chris@245
|
247 if (deflt) *deflt = 1;
|
Chris@164
|
248 return m_resampleQuality;
|
Chris@164
|
249 }
|
Chris@164
|
250
|
Chris@277
|
251 if (name == "Omit Temporaries from Recent Files") {
|
Chris@277
|
252 if (deflt) *deflt = 1;
|
Chris@277
|
253 }
|
Chris@277
|
254
|
Chris@297
|
255 if (name == "Background Mode") {
|
Chris@297
|
256 if (min) *min = 0;
|
Chris@297
|
257 if (max) *max = 2;
|
Chris@297
|
258 if (deflt) *deflt = 0;
|
Chris@297
|
259 return int(m_backgroundMode);
|
Chris@297
|
260 }
|
Chris@297
|
261
|
Chris@612
|
262 if (name == "Time To Text Mode") {
|
Chris@612
|
263 if (min) *min = 0;
|
Chris@612
|
264 if (max) *max = 6;
|
Chris@612
|
265 if (deflt) *deflt = 0;
|
Chris@612
|
266 return int(m_timeToTextMode);
|
Chris@612
|
267 }
|
Chris@612
|
268
|
Chris@892
|
269 if (name == "Octave Numbering System") {
|
Chris@892
|
270 // we don't support arbitrary octaves in the gui, because we
|
Chris@892
|
271 // want to be able to label what the octave system comes
|
Chris@892
|
272 // from. so we support 0, 3, 4 and 5.
|
Chris@892
|
273 if (min) *min = 0;
|
Chris@892
|
274 if (max) *max = 3;
|
Chris@892
|
275 if (deflt) *deflt = 2;
|
Chris@892
|
276 return int(getSystemWithMiddleCInOctave(m_octave));
|
Chris@892
|
277 }
|
Chris@892
|
278
|
Chris@354
|
279 if (name == "View Font Size") {
|
Chris@354
|
280 if (min) *min = 3;
|
Chris@354
|
281 if (max) *max = 48;
|
Chris@387
|
282 if (deflt) *deflt = 10;
|
Chris@354
|
283 return int(m_viewFontSize);
|
Chris@354
|
284 }
|
Chris@354
|
285
|
Chris@372
|
286 if (name == "Show Splash Screen") {
|
Chris@372
|
287 if (deflt) *deflt = 1;
|
Chris@372
|
288 }
|
Chris@372
|
289
|
Chris@136
|
290 return 0;
|
Chris@136
|
291 }
|
Chris@136
|
292
|
Chris@136
|
293 QString
|
Chris@136
|
294 Preferences::getPropertyValueLabel(const PropertyName &name,
|
Chris@136
|
295 int value) const
|
Chris@136
|
296 {
|
Chris@138
|
297 if (name == "Property Box Layout") {
|
Chris@141
|
298 if (value == 0) return tr("Show boxes for all panes");
|
Chris@141
|
299 else return tr("Show box for current pane only");
|
Chris@138
|
300 }
|
Chris@140
|
301 if (name == "Window Type") {
|
Chris@140
|
302 switch (WindowType(value)) {
|
Chris@140
|
303 case RectangularWindow: return tr("Rectangular");
|
Chris@141
|
304 case BartlettWindow: return tr("Triangular");
|
Chris@140
|
305 case HammingWindow: return tr("Hamming");
|
Chris@381
|
306 case HanningWindow: return tr("Hann");
|
Chris@140
|
307 case BlackmanWindow: return tr("Blackman");
|
Chris@140
|
308 case GaussianWindow: return tr("Gaussian");
|
Chris@140
|
309 case ParzenWindow: return tr("Parzen");
|
Chris@142
|
310 case NuttallWindow: return tr("Nuttall");
|
Chris@142
|
311 case BlackmanHarrisWindow: return tr("Blackman-Harris");
|
Chris@140
|
312 }
|
Chris@140
|
313 }
|
Chris@164
|
314 if (name == "Resample Quality") {
|
Chris@164
|
315 switch (value) {
|
Chris@164
|
316 case 0: return tr("Fastest");
|
Chris@165
|
317 case 1: return tr("Standard");
|
Chris@164
|
318 case 2: return tr("Highest quality");
|
Chris@164
|
319 }
|
Chris@164
|
320 }
|
Chris@553
|
321 if (name == "Spectrogram Y Smoothing") {
|
Chris@246
|
322 switch (value) {
|
Chris@553
|
323 case NoSpectrogramSmoothing: return tr("None");
|
Chris@553
|
324 case SpectrogramInterpolated: return tr("Linear interpolation");
|
Chris@553
|
325 case SpectrogramZeroPadded: return tr("4 x Oversampling");
|
Chris@553
|
326 case SpectrogramZeroPaddedAndInterpolated: return tr("4 x Oversampling with interpolation");
|
Chris@553
|
327 }
|
Chris@553
|
328 }
|
Chris@553
|
329 if (name == "Spectrogram X Smoothing") {
|
Chris@553
|
330 switch (value) {
|
Chris@553
|
331 case NoSpectrogramXSmoothing: return tr("None");
|
Chris@553
|
332 case SpectrogramXInterpolated: return tr("Linear interpolation");
|
Chris@246
|
333 }
|
Chris@246
|
334 }
|
Chris@297
|
335 if (name == "Background Mode") {
|
Chris@297
|
336 switch (value) {
|
Chris@297
|
337 case BackgroundFromTheme: return tr("Follow desktop theme");
|
Chris@297
|
338 case DarkBackground: return tr("Dark background");
|
Chris@297
|
339 case LightBackground: return tr("Light background");
|
Chris@297
|
340 }
|
Chris@297
|
341 }
|
Chris@612
|
342 if (name == "Time To Text Mode") {
|
Chris@612
|
343 switch (value) {
|
Chris@612
|
344 case TimeToTextMs: return tr("Standard (to millisecond)");
|
Chris@612
|
345 case TimeToTextUs: return tr("High resolution (to microsecond)");
|
Chris@612
|
346 case TimeToText24Frame: return tr("24 FPS");
|
Chris@612
|
347 case TimeToText25Frame: return tr("25 FPS");
|
Chris@612
|
348 case TimeToText30Frame: return tr("30 FPS");
|
Chris@612
|
349 case TimeToText50Frame: return tr("50 FPS");
|
Chris@612
|
350 case TimeToText60Frame: return tr("60 FPS");
|
Chris@612
|
351 }
|
Chris@612
|
352 }
|
Chris@892
|
353 if (name == "Octave Numbering System") {
|
Chris@892
|
354 switch (value) {
|
Chris@892
|
355 case C0_Centre: return tr("C0 - middle of octave scale");
|
Chris@892
|
356 case C3_Logic: return tr("C3 - common MIDI sequencer convention");
|
Chris@892
|
357 case C4_ASA: return tr("C4 - ASA American standard");
|
Chris@892
|
358 case C5_Sonar: return tr("C5 - used in Cakewalk and others");
|
Chris@892
|
359 }
|
Chris@892
|
360 }
|
Chris@246
|
361
|
Chris@136
|
362 return "";
|
Chris@136
|
363 }
|
Chris@136
|
364
|
Chris@136
|
365 QString
|
Chris@136
|
366 Preferences::getPropertyContainerName() const
|
Chris@136
|
367 {
|
Chris@136
|
368 return tr("Preferences");
|
Chris@136
|
369 }
|
Chris@136
|
370
|
Chris@136
|
371 QString
|
Chris@136
|
372 Preferences::getPropertyContainerIconName() const
|
Chris@136
|
373 {
|
Chris@136
|
374 return "preferences";
|
Chris@136
|
375 }
|
Chris@136
|
376
|
Chris@136
|
377 void
|
Chris@136
|
378 Preferences::setProperty(const PropertyName &name, int value)
|
Chris@136
|
379 {
|
Chris@553
|
380 if (name == "Spectrogram Y Smoothing") {
|
Chris@246
|
381 setSpectrogramSmoothing(SpectrogramSmoothing(value));
|
Chris@553
|
382 } else if (name == "Spectrogram X Smoothing") {
|
Chris@553
|
383 setSpectrogramXSmoothing(SpectrogramXSmoothing(value));
|
Chris@136
|
384 } else if (name == "Tuning Frequency") {
|
Chris@136
|
385 //!!!
|
Chris@138
|
386 } else if (name == "Property Box Layout") {
|
Chris@138
|
387 setPropertyBoxLayout(value == 0 ? VerticallyStacked : Layered);
|
Chris@140
|
388 } else if (name == "Window Type") {
|
Chris@140
|
389 setWindowType(WindowType(value));
|
Chris@164
|
390 } else if (name == "Resample Quality") {
|
Chris@164
|
391 setResampleQuality(value);
|
Chris@277
|
392 } else if (name == "Omit Temporaries from Recent Files") {
|
Chris@277
|
393 setOmitTempsFromRecentFiles(value ? true : false);
|
Chris@297
|
394 } else if (name == "Background Mode") {
|
Chris@297
|
395 setBackgroundMode(BackgroundMode(value));
|
Chris@612
|
396 } else if (name == "Time To Text Mode") {
|
Chris@612
|
397 setTimeToTextMode(TimeToTextMode(value));
|
Chris@892
|
398 } else if (name == "Octave Numbering System") {
|
Chris@892
|
399 setOctaveOfMiddleC(getOctaveOfMiddleCInSystem
|
Chris@892
|
400 (OctaveNumberingSystem(value)));
|
Chris@354
|
401 } else if (name == "View Font Size") {
|
Chris@354
|
402 setViewFontSize(value);
|
Chris@372
|
403 } else if (name == "Show Splash Screen") {
|
Chris@372
|
404 setShowSplash(value ? true : false);
|
Chris@136
|
405 }
|
Chris@136
|
406 }
|
Chris@136
|
407
|
Chris@136
|
408 void
|
Chris@246
|
409 Preferences::setSpectrogramSmoothing(SpectrogramSmoothing smoothing)
|
Chris@136
|
410 {
|
Chris@246
|
411 if (m_spectrogramSmoothing != smoothing) {
|
Chris@246
|
412
|
Chris@246
|
413 // "smoothing" is one of those words that looks increasingly
|
Chris@246
|
414 // ridiculous the more you see it. Smoothing smoothing smoothing.
|
Chris@246
|
415 m_spectrogramSmoothing = smoothing;
|
Chris@246
|
416
|
Chris@156
|
417 QSettings settings;
|
Chris@156
|
418 settings.beginGroup("Preferences");
|
Chris@553
|
419 settings.setValue("spectrogram-y-smoothing", int(smoothing));
|
Chris@156
|
420 settings.endGroup();
|
Chris@553
|
421 emit propertyChanged("Spectrogram Y Smoothing");
|
Chris@553
|
422 }
|
Chris@553
|
423 }
|
Chris@553
|
424
|
Chris@553
|
425 void
|
Chris@553
|
426 Preferences::setSpectrogramXSmoothing(SpectrogramXSmoothing smoothing)
|
Chris@553
|
427 {
|
Chris@553
|
428 if (m_spectrogramXSmoothing != smoothing) {
|
Chris@553
|
429
|
Chris@553
|
430 // "smoothing" is one of those words that looks increasingly
|
Chris@553
|
431 // ridiculous the more you see it. Smoothing smoothing smoothing.
|
Chris@553
|
432 m_spectrogramXSmoothing = smoothing;
|
Chris@553
|
433
|
Chris@553
|
434 QSettings settings;
|
Chris@553
|
435 settings.beginGroup("Preferences");
|
Chris@553
|
436 settings.setValue("spectrogram-x-smoothing", int(smoothing));
|
Chris@553
|
437 settings.endGroup();
|
Chris@553
|
438 emit propertyChanged("Spectrogram X Smoothing");
|
Chris@138
|
439 }
|
Chris@136
|
440 }
|
Chris@136
|
441
|
Chris@136
|
442 void
|
Chris@136
|
443 Preferences::setTuningFrequency(float freq)
|
Chris@136
|
444 {
|
Chris@138
|
445 if (m_tuningFrequency != freq) {
|
Chris@138
|
446 m_tuningFrequency = freq;
|
Chris@156
|
447 QSettings settings;
|
Chris@156
|
448 settings.beginGroup("Preferences");
|
Chris@156
|
449 settings.setValue("tuning-frequency", freq);
|
Chris@156
|
450 settings.endGroup();
|
Chris@141
|
451 emit propertyChanged("Tuning Frequency");
|
Chris@138
|
452 }
|
Chris@136
|
453 }
|
Chris@136
|
454
|
Chris@138
|
455 void
|
Chris@138
|
456 Preferences::setPropertyBoxLayout(PropertyBoxLayout layout)
|
Chris@138
|
457 {
|
Chris@138
|
458 if (m_propertyBoxLayout != layout) {
|
Chris@138
|
459 m_propertyBoxLayout = layout;
|
Chris@156
|
460 QSettings settings;
|
Chris@156
|
461 settings.beginGroup("Preferences");
|
Chris@156
|
462 settings.setValue("property-box-layout", int(layout));
|
Chris@156
|
463 settings.endGroup();
|
Chris@141
|
464 emit propertyChanged("Property Box Layout");
|
Chris@138
|
465 }
|
Chris@138
|
466 }
|
Chris@138
|
467
|
Chris@140
|
468 void
|
Chris@140
|
469 Preferences::setWindowType(WindowType type)
|
Chris@140
|
470 {
|
Chris@140
|
471 if (m_windowType != type) {
|
Chris@140
|
472 m_windowType = type;
|
Chris@156
|
473 QSettings settings;
|
Chris@156
|
474 settings.beginGroup("Preferences");
|
Chris@156
|
475 settings.setValue("window-type", int(type));
|
Chris@156
|
476 settings.endGroup();
|
Chris@141
|
477 emit propertyChanged("Window Type");
|
Chris@140
|
478 }
|
Chris@140
|
479 }
|
Chris@140
|
480
|
Chris@164
|
481 void
|
Chris@164
|
482 Preferences::setResampleQuality(int q)
|
Chris@164
|
483 {
|
Chris@164
|
484 if (m_resampleQuality != q) {
|
Chris@164
|
485 m_resampleQuality = q;
|
Chris@164
|
486 QSettings settings;
|
Chris@164
|
487 settings.beginGroup("Preferences");
|
Chris@164
|
488 settings.setValue("resample-quality", q);
|
Chris@164
|
489 settings.endGroup();
|
Chris@164
|
490 emit propertyChanged("Resample Quality");
|
Chris@164
|
491 }
|
Chris@164
|
492 }
|
Chris@277
|
493
|
Chris@277
|
494 void
|
Chris@277
|
495 Preferences::setOmitTempsFromRecentFiles(bool omit)
|
Chris@277
|
496 {
|
Chris@277
|
497 if (m_omitRecentTemps != omit) {
|
Chris@277
|
498 m_omitRecentTemps = omit;
|
Chris@277
|
499 QSettings settings;
|
Chris@277
|
500 settings.beginGroup("Preferences");
|
Chris@277
|
501 settings.setValue("omit-recent-temporaries", omit);
|
Chris@277
|
502 settings.endGroup();
|
Chris@277
|
503 emit propertyChanged("Omit Temporaries from Recent Files");
|
Chris@277
|
504 }
|
Chris@277
|
505 }
|
Chris@297
|
506
|
Chris@297
|
507 void
|
Chris@297
|
508 Preferences::setTemporaryDirectoryRoot(QString root)
|
Chris@297
|
509 {
|
Chris@297
|
510 if (root == QDir::home().absolutePath()) {
|
Chris@297
|
511 root = "$HOME";
|
Chris@297
|
512 }
|
Chris@297
|
513 if (m_tempDirRoot != root) {
|
Chris@297
|
514 m_tempDirRoot = root;
|
Chris@297
|
515 QSettings settings;
|
Chris@297
|
516 settings.beginGroup("TempDirectory");
|
Chris@297
|
517 settings.setValue("create-in", root);
|
Chris@297
|
518 settings.endGroup();
|
Chris@297
|
519 emit propertyChanged("Temporary Directory Root");
|
Chris@297
|
520 }
|
Chris@297
|
521 }
|
Chris@297
|
522
|
Chris@297
|
523 void
|
Chris@297
|
524 Preferences::setResampleOnLoad(bool resample)
|
Chris@297
|
525 {
|
Chris@297
|
526 if (m_resampleOnLoad != resample) {
|
Chris@297
|
527 m_resampleOnLoad = resample;
|
Chris@297
|
528 QSettings settings;
|
Chris@297
|
529 settings.beginGroup("Preferences");
|
Chris@297
|
530 settings.setValue("resample-on-load", resample);
|
Chris@297
|
531 settings.endGroup();
|
Chris@297
|
532 emit propertyChanged("Resample On Load");
|
Chris@297
|
533 }
|
Chris@297
|
534 }
|
Chris@297
|
535
|
Chris@297
|
536 void
|
Chris@919
|
537 Preferences::setFixedSampleRate(int rate)
|
Chris@919
|
538 {
|
Chris@919
|
539 if (m_fixedSampleRate != rate) {
|
Chris@919
|
540 m_fixedSampleRate = rate;
|
Chris@919
|
541 QSettings settings;
|
Chris@919
|
542 settings.beginGroup("Preferences");
|
Chris@919
|
543 settings.setValue("fixed-sample-rate", rate);
|
Chris@919
|
544 settings.endGroup();
|
Chris@919
|
545 emit propertyChanged("Fixed Sample Rate");
|
Chris@919
|
546 }
|
Chris@919
|
547 }
|
Chris@919
|
548
|
Chris@919
|
549 void
|
Chris@297
|
550 Preferences::setBackgroundMode(BackgroundMode mode)
|
Chris@297
|
551 {
|
Chris@297
|
552 if (m_backgroundMode != mode) {
|
Chris@297
|
553
|
Chris@297
|
554 m_backgroundMode = mode;
|
Chris@297
|
555
|
Chris@297
|
556 QSettings settings;
|
Chris@297
|
557 settings.beginGroup("Preferences");
|
Chris@297
|
558 settings.setValue("background-mode", int(mode));
|
Chris@297
|
559 settings.endGroup();
|
Chris@297
|
560 emit propertyChanged("Background Mode");
|
Chris@297
|
561 }
|
Chris@297
|
562 }
|
Chris@297
|
563
|
Chris@354
|
564 void
|
Chris@612
|
565 Preferences::setTimeToTextMode(TimeToTextMode mode)
|
Chris@612
|
566 {
|
Chris@612
|
567 if (m_timeToTextMode != mode) {
|
Chris@612
|
568
|
Chris@612
|
569 m_timeToTextMode = mode;
|
Chris@612
|
570
|
Chris@612
|
571 QSettings settings;
|
Chris@612
|
572 settings.beginGroup("Preferences");
|
Chris@612
|
573 settings.setValue("time-to-text-mode", int(mode));
|
Chris@612
|
574 settings.endGroup();
|
Chris@612
|
575 emit propertyChanged("Time To Text Mode");
|
Chris@612
|
576 }
|
Chris@612
|
577 }
|
Chris@612
|
578
|
Chris@612
|
579 void
|
Chris@892
|
580 Preferences::setOctaveOfMiddleC(int oct)
|
Chris@892
|
581 {
|
Chris@892
|
582 if (m_octave != oct) {
|
Chris@892
|
583
|
Chris@892
|
584 m_octave = oct;
|
Chris@892
|
585
|
Chris@892
|
586 QSettings settings;
|
Chris@892
|
587 settings.beginGroup("Preferences");
|
Chris@892
|
588 settings.setValue("octave-of-middle-c", int(oct));
|
Chris@892
|
589 settings.endGroup();
|
Chris@892
|
590 emit propertyChanged("Octave Numbering System");
|
Chris@892
|
591 }
|
Chris@892
|
592 }
|
Chris@892
|
593
|
Chris@892
|
594 int
|
Chris@892
|
595 Preferences::getOctaveOfMiddleCInSystem(OctaveNumberingSystem s)
|
Chris@892
|
596 {
|
Chris@892
|
597 switch (s) {
|
Chris@892
|
598 case C0_Centre: return 0;
|
Chris@892
|
599 case C3_Logic: return 3;
|
Chris@892
|
600 case C4_ASA: return 4;
|
Chris@892
|
601 case C5_Sonar: return 5;
|
Chris@892
|
602 default: return 4;
|
Chris@892
|
603 }
|
Chris@892
|
604 }
|
Chris@892
|
605
|
Chris@892
|
606 Preferences::OctaveNumberingSystem
|
Chris@892
|
607 Preferences::getSystemWithMiddleCInOctave(int o)
|
Chris@892
|
608 {
|
Chris@892
|
609 switch (o) {
|
Chris@892
|
610 case 0: return C0_Centre;
|
Chris@892
|
611 case 3: return C3_Logic;
|
Chris@892
|
612 case 4: return C4_ASA;
|
Chris@892
|
613 case 5: return C5_Sonar;
|
Chris@892
|
614 default: return C4_ASA;
|
Chris@892
|
615 }
|
Chris@892
|
616 }
|
Chris@892
|
617
|
Chris@892
|
618 void
|
Chris@354
|
619 Preferences::setViewFontSize(int size)
|
Chris@354
|
620 {
|
Chris@354
|
621 if (m_viewFontSize != size) {
|
Chris@297
|
622
|
Chris@354
|
623 m_viewFontSize = size;
|
Chris@354
|
624
|
Chris@354
|
625 QSettings settings;
|
Chris@354
|
626 settings.beginGroup("Preferences");
|
Chris@354
|
627 settings.setValue("view-font-size", size);
|
Chris@354
|
628 settings.endGroup();
|
Chris@354
|
629 emit propertyChanged("View Font Size");
|
Chris@354
|
630 }
|
Chris@354
|
631 }
|
Chris@354
|
632
|
Chris@372
|
633 void
|
Chris@372
|
634 Preferences::setShowSplash(bool show)
|
Chris@372
|
635 {
|
Chris@372
|
636 if (m_showSplash != show) {
|
Chris@372
|
637
|
Chris@372
|
638 m_showSplash = show;
|
Chris@372
|
639
|
Chris@372
|
640 QSettings settings;
|
Chris@372
|
641 settings.beginGroup("Preferences");
|
Chris@372
|
642 settings.setValue("show-splash", show);
|
Chris@372
|
643 settings.endGroup();
|
Chris@372
|
644 emit propertyChanged("Show Splash Screen");
|
Chris@372
|
645 }
|
Chris@372
|
646 }
|
Chris@372
|
647
|