Mercurial > hg > svcore
comparison base/Preferences.cpp @ 297:c022976d18e8
* Merge from sv-match-alignment branch (excluding alignment-specific document).
- add aggregate wave model (not yet complete enough to be added as a true
model in a layer, but there's potential)
- add play solo mode
- add alignment model -- unused in plain SV
- fix two plugin leaks
- add m3u playlist support (opens all files at once, potentially hazardous)
- fix retrieval of pre-encoded URLs
- add ability to resample audio files on import, so as to match rates with
other files previously loaded; add preference for same
- add preliminary support in transform code for range and rate of transform
input
- reorganise preferences dialog, move dark-background option to preferences,
add option for temporary directory location
author | Chris Cannam |
---|---|
date | Fri, 28 Sep 2007 13:56:38 +0000 |
parents | 3b8008d09541 |
children | 4fc6f49436b3 |
comparison
equal
deleted
inserted
replaced
296:2b6c99b607f1 | 297:c022976d18e8 |
---|---|
38 m_spectrogramSmoothing(SpectrogramZeroPadded), | 38 m_spectrogramSmoothing(SpectrogramZeroPadded), |
39 m_tuningFrequency(440), | 39 m_tuningFrequency(440), |
40 m_propertyBoxLayout(VerticallyStacked), | 40 m_propertyBoxLayout(VerticallyStacked), |
41 m_windowType(HanningWindow), | 41 m_windowType(HanningWindow), |
42 m_resampleQuality(1), | 42 m_resampleQuality(1), |
43 m_omitRecentTemps(true) | 43 m_omitRecentTemps(true), |
44 m_tempDirRoot(""), | |
45 m_resampleOnLoad(true) | |
44 { | 46 { |
45 QSettings settings; | 47 QSettings settings; |
46 settings.beginGroup("Preferences"); | 48 settings.beginGroup("Preferences"); |
47 m_spectrogramSmoothing = SpectrogramSmoothing | 49 m_spectrogramSmoothing = SpectrogramSmoothing |
48 (settings.value("spectrogram-smoothing", int(m_spectrogramSmoothing)).toInt()); | 50 (settings.value("spectrogram-smoothing", int(m_spectrogramSmoothing)).toInt()); |
50 m_propertyBoxLayout = PropertyBoxLayout | 52 m_propertyBoxLayout = PropertyBoxLayout |
51 (settings.value("property-box-layout", int(VerticallyStacked)).toInt()); | 53 (settings.value("property-box-layout", int(VerticallyStacked)).toInt()); |
52 m_windowType = WindowType | 54 m_windowType = WindowType |
53 (settings.value("window-type", int(HanningWindow)).toInt()); | 55 (settings.value("window-type", int(HanningWindow)).toInt()); |
54 m_resampleQuality = settings.value("resample-quality", 1).toInt(); | 56 m_resampleQuality = settings.value("resample-quality", 1).toInt(); |
57 m_resampleOnLoad = settings.value("resample-on-load", true).toBool(); | |
58 m_backgroundMode = BackgroundMode | |
59 (settings.value("background-mode", int(BackgroundFromTheme)).toInt()); | |
60 settings.endGroup(); | |
61 | |
62 settings.beginGroup("TempDirectory"); | |
63 m_tempDirRoot = settings.value("create-in", "$HOME").toString(); | |
55 settings.endGroup(); | 64 settings.endGroup(); |
56 } | 65 } |
57 | 66 |
58 Preferences::~Preferences() | 67 Preferences::~Preferences() |
59 { | 68 { |
67 props.push_back("Tuning Frequency"); | 76 props.push_back("Tuning Frequency"); |
68 props.push_back("Property Box Layout"); | 77 props.push_back("Property Box Layout"); |
69 props.push_back("Window Type"); | 78 props.push_back("Window Type"); |
70 props.push_back("Resample Quality"); | 79 props.push_back("Resample Quality"); |
71 props.push_back("Omit Temporaries from Recent Files"); | 80 props.push_back("Omit Temporaries from Recent Files"); |
81 props.push_back("Resample On Load"); | |
82 props.push_back("Temporary Directory Root"); | |
83 props.push_back("Background Mode"); | |
72 return props; | 84 return props; |
73 } | 85 } |
74 | 86 |
75 QString | 87 QString |
76 Preferences::getPropertyLabel(const PropertyName &name) const | 88 Preferences::getPropertyLabel(const PropertyName &name) const |
89 } | 101 } |
90 if (name == "Resample Quality") { | 102 if (name == "Resample Quality") { |
91 return tr("Playback resampler type"); | 103 return tr("Playback resampler type"); |
92 } | 104 } |
93 if (name == "Omit Temporaries from Recent Files") { | 105 if (name == "Omit Temporaries from Recent Files") { |
94 return tr("Omit Temporaries from Recent Files"); | 106 return tr("Omit temporaries from Recent Files menu"); |
107 } | |
108 if (name == "Resample On Load") { | |
109 return tr("Resample mismatching files on import"); | |
110 } | |
111 if (name == "Temporary Directory Root") { | |
112 return tr("Location for cache file directory"); | |
113 } | |
114 if (name == "Background Mode") { | |
115 return tr("Background colour preference"); | |
95 } | 116 } |
96 return name; | 117 return name; |
97 } | 118 } |
98 | 119 |
99 Preferences::PropertyType | 120 Preferences::PropertyType |
114 if (name == "Resample Quality") { | 135 if (name == "Resample Quality") { |
115 return ValueProperty; | 136 return ValueProperty; |
116 } | 137 } |
117 if (name == "Omit Temporaries from Recent Files") { | 138 if (name == "Omit Temporaries from Recent Files") { |
118 return ToggleProperty; | 139 return ToggleProperty; |
140 } | |
141 if (name == "Resample On Load") { | |
142 return ToggleProperty; | |
143 } | |
144 if (name == "Temporary Directory Root") { | |
145 // It's an arbitrary string, we don't have a set of values for this | |
146 return InvalidProperty; | |
147 } | |
148 if (name == "Background Mode") { | |
149 return ValueProperty; | |
119 } | 150 } |
120 return InvalidProperty; | 151 return InvalidProperty; |
121 } | 152 } |
122 | 153 |
123 int | 154 int |
155 } | 186 } |
156 | 187 |
157 if (name == "Omit Temporaries from Recent Files") { | 188 if (name == "Omit Temporaries from Recent Files") { |
158 if (deflt) *deflt = 1; | 189 if (deflt) *deflt = 1; |
159 } | 190 } |
191 | |
192 if (name == "Background Mode") { | |
193 if (min) *min = 0; | |
194 if (max) *max = 2; | |
195 if (deflt) *deflt = 0; | |
196 return int(m_backgroundMode); | |
197 } | |
160 | 198 |
161 return 0; | 199 return 0; |
162 } | 200 } |
163 | 201 |
164 QString | 202 QString |
194 case NoSpectrogramSmoothing: return tr("None - blocky but accurate"); | 232 case NoSpectrogramSmoothing: return tr("None - blocky but accurate"); |
195 case SpectrogramInterpolated: return tr("Interpolate - fast but fuzzy"); | 233 case SpectrogramInterpolated: return tr("Interpolate - fast but fuzzy"); |
196 case SpectrogramZeroPadded: return tr("Zero pad FFT - slow but clear"); | 234 case SpectrogramZeroPadded: return tr("Zero pad FFT - slow but clear"); |
197 } | 235 } |
198 } | 236 } |
237 if (name == "Background Mode") { | |
238 switch (value) { | |
239 case BackgroundFromTheme: return tr("Follow desktop theme"); | |
240 case DarkBackground: return tr("Dark background"); | |
241 case LightBackground: return tr("Light background"); | |
242 } | |
243 } | |
199 | 244 |
200 return ""; | 245 return ""; |
201 } | 246 } |
202 | 247 |
203 QString | 248 QString |
225 setWindowType(WindowType(value)); | 270 setWindowType(WindowType(value)); |
226 } else if (name == "Resample Quality") { | 271 } else if (name == "Resample Quality") { |
227 setResampleQuality(value); | 272 setResampleQuality(value); |
228 } else if (name == "Omit Temporaries from Recent Files") { | 273 } else if (name == "Omit Temporaries from Recent Files") { |
229 setOmitTempsFromRecentFiles(value ? true : false); | 274 setOmitTempsFromRecentFiles(value ? true : false); |
275 } else if (name == "Background Mode") { | |
276 setBackgroundMode(BackgroundMode(value)); | |
230 } | 277 } |
231 } | 278 } |
232 | 279 |
233 void | 280 void |
234 Preferences::setSpectrogramSmoothing(SpectrogramSmoothing smoothing) | 281 Preferences::setSpectrogramSmoothing(SpectrogramSmoothing smoothing) |
309 settings.setValue("omit-recent-temporaries", omit); | 356 settings.setValue("omit-recent-temporaries", omit); |
310 settings.endGroup(); | 357 settings.endGroup(); |
311 emit propertyChanged("Omit Temporaries from Recent Files"); | 358 emit propertyChanged("Omit Temporaries from Recent Files"); |
312 } | 359 } |
313 } | 360 } |
361 | |
362 void | |
363 Preferences::setTemporaryDirectoryRoot(QString root) | |
364 { | |
365 if (root == QDir::home().absolutePath()) { | |
366 root = "$HOME"; | |
367 } | |
368 if (m_tempDirRoot != root) { | |
369 m_tempDirRoot = root; | |
370 QSettings settings; | |
371 settings.beginGroup("TempDirectory"); | |
372 settings.setValue("create-in", root); | |
373 settings.endGroup(); | |
374 emit propertyChanged("Temporary Directory Root"); | |
375 } | |
376 } | |
377 | |
378 void | |
379 Preferences::setResampleOnLoad(bool resample) | |
380 { | |
381 if (m_resampleOnLoad != resample) { | |
382 m_resampleOnLoad = resample; | |
383 QSettings settings; | |
384 settings.beginGroup("Preferences"); | |
385 settings.setValue("resample-on-load", resample); | |
386 settings.endGroup(); | |
387 emit propertyChanged("Resample On Load"); | |
388 } | |
389 } | |
390 | |
391 void | |
392 Preferences::setBackgroundMode(BackgroundMode mode) | |
393 { | |
394 if (m_backgroundMode != mode) { | |
395 | |
396 m_backgroundMode = mode; | |
397 | |
398 QSettings settings; | |
399 settings.beginGroup("Preferences"); | |
400 settings.setValue("background-mode", int(mode)); | |
401 settings.endGroup(); | |
402 emit propertyChanged("Background Mode"); | |
403 } | |
404 } | |
405 | |
406 |