annotate base/Preferences.cpp @ 1394:9ef1cc26024c

Add Range01 normalisation method to ColumnOp. This is the normalisation that is actually used in the Colour 3D Plot layer historically when column normalisation is enabled (not Max1 after all).
author Chris Cannam
date Tue, 28 Feb 2017 14:04:16 +0000
parents ea28ee929034
children 07f23b90701a
rev   line source
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@1225 43 m_runPluginsInProcess(true),
Chris@297 44 m_omitRecentTemps(true),
Chris@297 45 m_tempDirRoot(""),
Chris@919 46 m_fixedSampleRate(0),
Chris@354 47 m_resampleOnLoad(false),
Chris@1313 48 m_gapless(true),
Chris@921 49 m_normaliseAudio(false),
Chris@354 50 m_viewFontSize(10),
Chris@372 51 m_backgroundMode(BackgroundFromTheme),
Chris@612 52 m_timeToTextMode(TimeToTextMs),
Chris@1031 53 m_showHMS(true),
Chris@892 54 m_octave(4),
Chris@372 55 m_showSplash(true)
Chris@136 56 {
Chris@156 57 QSettings settings;
Chris@156 58 settings.beginGroup("Preferences");
Chris@246 59 m_spectrogramSmoothing = SpectrogramSmoothing
Chris@553 60 (settings.value("spectrogram-y-smoothing", int(m_spectrogramSmoothing)).toInt());
Chris@553 61 m_spectrogramXSmoothing = SpectrogramXSmoothing
Chris@553 62 (settings.value("spectrogram-x-smoothing", int(m_spectrogramXSmoothing)).toInt());
Chris@1038 63 m_tuningFrequency = settings.value("tuning-frequency", 440.).toDouble();
Chris@145 64 m_propertyBoxLayout = PropertyBoxLayout
Chris@156 65 (settings.value("property-box-layout", int(VerticallyStacked)).toInt());
Chris@145 66 m_windowType = WindowType
Chris@156 67 (settings.value("window-type", int(HanningWindow)).toInt());
Chris@1225 68 m_runPluginsInProcess = settings.value("run-vamp-plugins-in-process", true).toBool();
Chris@1047 69 m_fixedSampleRate = settings.value("fixed-sample-rate", 0).toDouble();
Chris@304 70 m_resampleOnLoad = settings.value("resample-on-load", false).toBool();
Chris@1313 71 m_gapless = settings.value("gapless", true).toBool();
Chris@921 72 m_normaliseAudio = settings.value("normalise-audio", false).toBool();
Chris@297 73 m_backgroundMode = BackgroundMode
Chris@297 74 (settings.value("background-mode", int(BackgroundFromTheme)).toInt());
Chris@612 75 m_timeToTextMode = TimeToTextMode
Chris@612 76 (settings.value("time-to-text-mode", int(TimeToTextMs)).toInt());
Chris@1031 77 m_showHMS = (settings.value("show-hours-minutes-seconds", true)).toBool();
Chris@892 78 m_octave = (settings.value("octave-of-middle-c", 4)).toInt();
Chris@387 79 m_viewFontSize = settings.value("view-font-size", 10).toInt();
Chris@372 80 m_showSplash = settings.value("show-splash", true).toBool();
Chris@297 81 settings.endGroup();
Chris@297 82
Chris@297 83 settings.beginGroup("TempDirectory");
Chris@297 84 m_tempDirRoot = settings.value("create-in", "$HOME").toString();
Chris@156 85 settings.endGroup();
Chris@145 86 }
Chris@145 87
Chris@145 88 Preferences::~Preferences()
Chris@145 89 {
Chris@136 90 }
Chris@136 91
Chris@136 92 Preferences::PropertyList
Chris@136 93 Preferences::getProperties() const
Chris@136 94 {
Chris@136 95 PropertyList props;
Chris@553 96 props.push_back("Spectrogram Y Smoothing");
Chris@553 97 props.push_back("Spectrogram X Smoothing");
Chris@136 98 props.push_back("Tuning Frequency");
Chris@138 99 props.push_back("Property Box Layout");
Chris@140 100 props.push_back("Window Type");
Chris@164 101 props.push_back("Resample Quality");
Chris@277 102 props.push_back("Omit Temporaries from Recent Files");
Chris@297 103 props.push_back("Resample On Load");
Chris@1313 104 props.push_back("Use Gapless Mode");
Chris@921 105 props.push_back("Normalise Audio");
Chris@919 106 props.push_back("Fixed Sample Rate");
Chris@297 107 props.push_back("Temporary Directory Root");
Chris@297 108 props.push_back("Background Mode");
Chris@612 109 props.push_back("Time To Text Mode");
Chris@1031 110 props.push_back("Show Hours And Minutes");
Chris@892 111 props.push_back("Octave Numbering System");
Chris@354 112 props.push_back("View Font Size");
Chris@372 113 props.push_back("Show Splash Screen");
Chris@136 114 return props;
Chris@136 115 }
Chris@136 116
Chris@136 117 QString
Chris@136 118 Preferences::getPropertyLabel(const PropertyName &name) const
Chris@136 119 {
Chris@553 120 if (name == "Spectrogram Y Smoothing") {
Chris@372 121 return tr("Spectrogram y-axis interpolation:");
Chris@136 122 }
Chris@553 123 if (name == "Spectrogram X Smoothing") {
Chris@553 124 return tr("Spectrogram x-axis interpolation:");
Chris@553 125 }
Chris@136 126 if (name == "Tuning Frequency") {
Chris@141 127 return tr("Frequency of concert A");
Chris@136 128 }
Chris@138 129 if (name == "Property Box Layout") {
Chris@141 130 return tr("Property box layout");
Chris@138 131 }
Chris@140 132 if (name == "Window Type") {
Chris@141 133 return tr("Spectral analysis window shape");
Chris@140 134 }
Chris@164 135 if (name == "Resample Quality") {
Chris@165 136 return tr("Playback resampler type");
Chris@164 137 }
Chris@921 138 if (name == "Normalise Audio") {
Chris@921 139 return tr("Normalise audio signal when reading from audio file");
Chris@921 140 }
Chris@277 141 if (name == "Omit Temporaries from Recent Files") {
Chris@297 142 return tr("Omit temporaries from Recent Files menu");
Chris@297 143 }
Chris@297 144 if (name == "Resample On Load") {
Chris@297 145 return tr("Resample mismatching files on import");
Chris@297 146 }
Chris@1313 147 if (name == "Use Gapless Mode") {
Chris@1313 148 return tr("Load mp3 files in gapless mode");
Chris@1313 149 }
Chris@919 150 if (name == "Fixed Sample Rate") {
Chris@919 151 return tr("Single fixed sample rate to resample all files to");
Chris@919 152 }
Chris@297 153 if (name == "Temporary Directory Root") {
Chris@297 154 return tr("Location for cache file directory");
Chris@297 155 }
Chris@297 156 if (name == "Background Mode") {
Chris@297 157 return tr("Background colour preference");
Chris@277 158 }
Chris@612 159 if (name == "Time To Text Mode") {
Chris@1031 160 return tr("Time display precision");
Chris@1031 161 }
Chris@1031 162 if (name == "Show Hours And Minutes") {
Chris@1031 163 return tr("Use hours:minutes:seconds format");
Chris@612 164 }
Chris@892 165 if (name == "Octave Numbering System") {
Chris@892 166 return tr("Label middle C as");
Chris@892 167 }
Chris@354 168 if (name == "View Font Size") {
Chris@354 169 return tr("Font size for text overlays");
Chris@354 170 }
Chris@372 171 if (name == "Show Splash Screen") {
Chris@372 172 return tr("Show splash screen on startup");
Chris@372 173 }
Chris@136 174 return name;
Chris@136 175 }
Chris@136 176
Chris@136 177 Preferences::PropertyType
Chris@136 178 Preferences::getPropertyType(const PropertyName &name) const
Chris@136 179 {
Chris@553 180 if (name == "Spectrogram Y Smoothing") {
Chris@553 181 return ValueProperty;
Chris@553 182 }
Chris@553 183 if (name == "Spectrogram X Smoothing") {
Chris@246 184 return ValueProperty;
Chris@136 185 }
Chris@136 186 if (name == "Tuning Frequency") {
Chris@136 187 return RangeProperty;
Chris@136 188 }
Chris@138 189 if (name == "Property Box Layout") {
Chris@138 190 return ValueProperty;
Chris@138 191 }
Chris@140 192 if (name == "Window Type") {
Chris@140 193 return ValueProperty;
Chris@140 194 }
Chris@164 195 if (name == "Resample Quality") {
Chris@164 196 return ValueProperty;
Chris@164 197 }
Chris@921 198 if (name == "Normalise Audio") {
Chris@921 199 return ToggleProperty;
Chris@921 200 }
Chris@277 201 if (name == "Omit Temporaries from Recent Files") {
Chris@277 202 return ToggleProperty;
Chris@277 203 }
Chris@297 204 if (name == "Resample On Load") {
Chris@297 205 return ToggleProperty;
Chris@297 206 }
Chris@1313 207 if (name == "Use Gapless Mode") {
Chris@1313 208 return ToggleProperty;
Chris@1313 209 }
Chris@919 210 if (name == "Fixed Sample Rate") {
Chris@919 211 return ValueProperty;
Chris@919 212 }
Chris@297 213 if (name == "Temporary Directory Root") {
Chris@297 214 // It's an arbitrary string, we don't have a set of values for this
Chris@297 215 return InvalidProperty;
Chris@297 216 }
Chris@297 217 if (name == "Background Mode") {
Chris@297 218 return ValueProperty;
Chris@297 219 }
Chris@612 220 if (name == "Time To Text Mode") {
Chris@612 221 return ValueProperty;
Chris@612 222 }
Chris@1031 223 if (name == "Show Hours And Minutes") {
Chris@1031 224 return ToggleProperty;
Chris@1031 225 }
Chris@892 226 if (name == "Octave Numbering System") {
Chris@892 227 return ValueProperty;
Chris@892 228 }
Chris@354 229 if (name == "View Font Size") {
Chris@354 230 return RangeProperty;
Chris@354 231 }
Chris@372 232 if (name == "Show Splash Screen") {
Chris@372 233 return ToggleProperty;
Chris@372 234 }
Chris@136 235 return InvalidProperty;
Chris@136 236 }
Chris@136 237
Chris@136 238 int
Chris@136 239 Preferences::getPropertyRangeAndValue(const PropertyName &name,
Chris@245 240 int *min, int *max, int *deflt) const
Chris@136 241 {
Chris@553 242 if (name == "Spectrogram Y Smoothing") {
Chris@136 243 if (min) *min = 0;
Chris@553 244 if (max) *max = 3;
Chris@553 245 if (deflt) *deflt = int(SpectrogramInterpolated);
Chris@246 246 return int(m_spectrogramSmoothing);
Chris@136 247 }
Chris@553 248 if (name == "Spectrogram X Smoothing") {
Chris@553 249 if (min) *min = 0;
Chris@553 250 if (max) *max = 1;
Chris@553 251 if (deflt) *deflt = int(SpectrogramXInterpolated);
Chris@553 252 return int(m_spectrogramXSmoothing);
Chris@553 253 }
Chris@136 254
Chris@136 255 //!!! freq mapping
Chris@136 256
Chris@138 257 if (name == "Property Box Layout") {
Chris@138 258 if (min) *min = 0;
Chris@138 259 if (max) *max = 1;
Chris@245 260 if (deflt) *deflt = 0;
Chris@138 261 return m_propertyBoxLayout == Layered ? 1 : 0;
Chris@138 262 }
Chris@138 263
Chris@140 264 if (name == "Window Type") {
Chris@140 265 if (min) *min = int(RectangularWindow);
Chris@142 266 if (max) *max = int(BlackmanHarrisWindow);
Chris@245 267 if (deflt) *deflt = int(HanningWindow);
Chris@140 268 return int(m_windowType);
Chris@140 269 }
Chris@140 270
Chris@1225 271 if (name == "Run Vamp Plugins In Process") {
Chris@1225 272 return m_runPluginsInProcess;
Chris@1225 273 }
Chris@1225 274
Chris@277 275 if (name == "Omit Temporaries from Recent Files") {
Chris@277 276 if (deflt) *deflt = 1;
Chris@1031 277 return m_omitRecentTemps ? 1 : 0;
Chris@277 278 }
Chris@277 279
Chris@297 280 if (name == "Background Mode") {
Chris@297 281 if (min) *min = 0;
Chris@297 282 if (max) *max = 2;
Chris@297 283 if (deflt) *deflt = 0;
Chris@297 284 return int(m_backgroundMode);
Chris@297 285 }
Chris@297 286
Chris@612 287 if (name == "Time To Text Mode") {
Chris@612 288 if (min) *min = 0;
Chris@612 289 if (max) *max = 6;
Chris@612 290 if (deflt) *deflt = 0;
Chris@612 291 return int(m_timeToTextMode);
Chris@612 292 }
Chris@612 293
Chris@1031 294 if (name == "Show Hours And Minutes") {
Chris@1031 295 if (deflt) *deflt = 1;
Chris@1031 296 return m_showHMS ? 1 : 0;
Chris@1031 297 }
Chris@1031 298
Chris@892 299 if (name == "Octave Numbering System") {
Chris@892 300 // we don't support arbitrary octaves in the gui, because we
Chris@892 301 // want to be able to label what the octave system comes
Chris@892 302 // from. so we support 0, 3, 4 and 5.
Chris@892 303 if (min) *min = 0;
Chris@892 304 if (max) *max = 3;
Chris@892 305 if (deflt) *deflt = 2;
Chris@892 306 return int(getSystemWithMiddleCInOctave(m_octave));
Chris@892 307 }
Chris@892 308
Chris@354 309 if (name == "View Font Size") {
Chris@354 310 if (min) *min = 3;
Chris@354 311 if (max) *max = 48;
Chris@387 312 if (deflt) *deflt = 10;
Chris@354 313 return int(m_viewFontSize);
Chris@354 314 }
Chris@354 315
Chris@372 316 if (name == "Show Splash Screen") {
Chris@372 317 if (deflt) *deflt = 1;
Chris@1031 318 return m_showSplash ? 1 : 0;
Chris@372 319 }
Chris@372 320
Chris@136 321 return 0;
Chris@136 322 }
Chris@136 323
Chris@136 324 QString
Chris@136 325 Preferences::getPropertyValueLabel(const PropertyName &name,
Chris@136 326 int value) const
Chris@136 327 {
Chris@138 328 if (name == "Property Box Layout") {
Chris@141 329 if (value == 0) return tr("Show boxes for all panes");
Chris@141 330 else return tr("Show box for current pane only");
Chris@138 331 }
Chris@140 332 if (name == "Window Type") {
Chris@140 333 switch (WindowType(value)) {
Chris@140 334 case RectangularWindow: return tr("Rectangular");
Chris@141 335 case BartlettWindow: return tr("Triangular");
Chris@140 336 case HammingWindow: return tr("Hamming");
Chris@381 337 case HanningWindow: return tr("Hann");
Chris@140 338 case BlackmanWindow: return tr("Blackman");
Chris@140 339 case GaussianWindow: return tr("Gaussian");
Chris@140 340 case ParzenWindow: return tr("Parzen");
Chris@142 341 case NuttallWindow: return tr("Nuttall");
Chris@142 342 case BlackmanHarrisWindow: return tr("Blackman-Harris");
Chris@140 343 }
Chris@140 344 }
Chris@164 345 if (name == "Resample Quality") {
Chris@164 346 switch (value) {
Chris@164 347 case 0: return tr("Fastest");
Chris@165 348 case 1: return tr("Standard");
Chris@164 349 case 2: return tr("Highest quality");
Chris@164 350 }
Chris@164 351 }
Chris@553 352 if (name == "Spectrogram Y Smoothing") {
Chris@246 353 switch (value) {
Chris@553 354 case NoSpectrogramSmoothing: return tr("None");
Chris@553 355 case SpectrogramInterpolated: return tr("Linear interpolation");
Chris@553 356 case SpectrogramZeroPadded: return tr("4 x Oversampling");
Chris@553 357 case SpectrogramZeroPaddedAndInterpolated: return tr("4 x Oversampling with interpolation");
Chris@553 358 }
Chris@553 359 }
Chris@553 360 if (name == "Spectrogram X Smoothing") {
Chris@553 361 switch (value) {
Chris@553 362 case NoSpectrogramXSmoothing: return tr("None");
Chris@553 363 case SpectrogramXInterpolated: return tr("Linear interpolation");
Chris@246 364 }
Chris@246 365 }
Chris@297 366 if (name == "Background Mode") {
Chris@297 367 switch (value) {
Chris@297 368 case BackgroundFromTheme: return tr("Follow desktop theme");
Chris@297 369 case DarkBackground: return tr("Dark background");
Chris@297 370 case LightBackground: return tr("Light background");
Chris@297 371 }
Chris@297 372 }
Chris@612 373 if (name == "Time To Text Mode") {
Chris@612 374 switch (value) {
Chris@612 375 case TimeToTextMs: return tr("Standard (to millisecond)");
Chris@612 376 case TimeToTextUs: return tr("High resolution (to microsecond)");
Chris@612 377 case TimeToText24Frame: return tr("24 FPS");
Chris@612 378 case TimeToText25Frame: return tr("25 FPS");
Chris@612 379 case TimeToText30Frame: return tr("30 FPS");
Chris@612 380 case TimeToText50Frame: return tr("50 FPS");
Chris@612 381 case TimeToText60Frame: return tr("60 FPS");
Chris@612 382 }
Chris@612 383 }
Chris@892 384 if (name == "Octave Numbering System") {
Chris@892 385 switch (value) {
Chris@892 386 case C0_Centre: return tr("C0 - middle of octave scale");
Chris@892 387 case C3_Logic: return tr("C3 - common MIDI sequencer convention");
Chris@892 388 case C4_ASA: return tr("C4 - ASA American standard");
Chris@892 389 case C5_Sonar: return tr("C5 - used in Cakewalk and others");
Chris@892 390 }
Chris@892 391 }
Chris@246 392
Chris@136 393 return "";
Chris@136 394 }
Chris@136 395
Chris@136 396 QString
Chris@136 397 Preferences::getPropertyContainerName() const
Chris@136 398 {
Chris@136 399 return tr("Preferences");
Chris@136 400 }
Chris@136 401
Chris@136 402 QString
Chris@136 403 Preferences::getPropertyContainerIconName() const
Chris@136 404 {
Chris@136 405 return "preferences";
Chris@136 406 }
Chris@136 407
Chris@136 408 void
Chris@136 409 Preferences::setProperty(const PropertyName &name, int value)
Chris@136 410 {
Chris@553 411 if (name == "Spectrogram Y Smoothing") {
Chris@246 412 setSpectrogramSmoothing(SpectrogramSmoothing(value));
Chris@553 413 } else if (name == "Spectrogram X Smoothing") {
Chris@553 414 setSpectrogramXSmoothing(SpectrogramXSmoothing(value));
Chris@136 415 } else if (name == "Tuning Frequency") {
Chris@136 416 //!!!
Chris@138 417 } else if (name == "Property Box Layout") {
Chris@138 418 setPropertyBoxLayout(value == 0 ? VerticallyStacked : Layered);
Chris@140 419 } else if (name == "Window Type") {
Chris@140 420 setWindowType(WindowType(value));
Chris@1225 421 } else if (name == "Run Vamp Plugins In Process") {
Chris@1225 422 setRunPluginsInProcess(value ? true : false);
Chris@277 423 } else if (name == "Omit Temporaries from Recent Files") {
Chris@277 424 setOmitTempsFromRecentFiles(value ? true : false);
Chris@297 425 } else if (name == "Background Mode") {
Chris@297 426 setBackgroundMode(BackgroundMode(value));
Chris@612 427 } else if (name == "Time To Text Mode") {
Chris@612 428 setTimeToTextMode(TimeToTextMode(value));
Chris@1031 429 } else if (name == "Show Hours And Minutes") {
Chris@1031 430 setShowHMS(value ? true : false);
Chris@892 431 } else if (name == "Octave Numbering System") {
Chris@892 432 setOctaveOfMiddleC(getOctaveOfMiddleCInSystem
Chris@892 433 (OctaveNumberingSystem(value)));
Chris@354 434 } else if (name == "View Font Size") {
Chris@354 435 setViewFontSize(value);
Chris@372 436 } else if (name == "Show Splash Screen") {
Chris@372 437 setShowSplash(value ? true : false);
Chris@136 438 }
Chris@136 439 }
Chris@136 440
Chris@136 441 void
Chris@246 442 Preferences::setSpectrogramSmoothing(SpectrogramSmoothing smoothing)
Chris@136 443 {
Chris@246 444 if (m_spectrogramSmoothing != smoothing) {
Chris@246 445
Chris@246 446 // "smoothing" is one of those words that looks increasingly
Chris@246 447 // ridiculous the more you see it. Smoothing smoothing smoothing.
Chris@246 448 m_spectrogramSmoothing = smoothing;
Chris@246 449
Chris@156 450 QSettings settings;
Chris@156 451 settings.beginGroup("Preferences");
Chris@553 452 settings.setValue("spectrogram-y-smoothing", int(smoothing));
Chris@156 453 settings.endGroup();
Chris@553 454 emit propertyChanged("Spectrogram Y Smoothing");
Chris@553 455 }
Chris@553 456 }
Chris@553 457
Chris@553 458 void
Chris@553 459 Preferences::setSpectrogramXSmoothing(SpectrogramXSmoothing smoothing)
Chris@553 460 {
Chris@553 461 if (m_spectrogramXSmoothing != smoothing) {
Chris@553 462
Chris@553 463 // "smoothing" is one of those words that looks increasingly
Chris@553 464 // ridiculous the more you see it. Smoothing smoothing smoothing.
Chris@553 465 m_spectrogramXSmoothing = smoothing;
Chris@553 466
Chris@553 467 QSettings settings;
Chris@553 468 settings.beginGroup("Preferences");
Chris@553 469 settings.setValue("spectrogram-x-smoothing", int(smoothing));
Chris@553 470 settings.endGroup();
Chris@553 471 emit propertyChanged("Spectrogram X Smoothing");
Chris@138 472 }
Chris@136 473 }
Chris@136 474
Chris@136 475 void
Chris@1038 476 Preferences::setTuningFrequency(double freq)
Chris@136 477 {
Chris@138 478 if (m_tuningFrequency != freq) {
Chris@138 479 m_tuningFrequency = freq;
Chris@156 480 QSettings settings;
Chris@156 481 settings.beginGroup("Preferences");
Chris@156 482 settings.setValue("tuning-frequency", freq);
Chris@156 483 settings.endGroup();
Chris@141 484 emit propertyChanged("Tuning Frequency");
Chris@138 485 }
Chris@136 486 }
Chris@136 487
Chris@138 488 void
Chris@138 489 Preferences::setPropertyBoxLayout(PropertyBoxLayout layout)
Chris@138 490 {
Chris@138 491 if (m_propertyBoxLayout != layout) {
Chris@138 492 m_propertyBoxLayout = layout;
Chris@156 493 QSettings settings;
Chris@156 494 settings.beginGroup("Preferences");
Chris@156 495 settings.setValue("property-box-layout", int(layout));
Chris@156 496 settings.endGroup();
Chris@141 497 emit propertyChanged("Property Box Layout");
Chris@138 498 }
Chris@138 499 }
Chris@138 500
Chris@140 501 void
Chris@140 502 Preferences::setWindowType(WindowType type)
Chris@140 503 {
Chris@140 504 if (m_windowType != type) {
Chris@140 505 m_windowType = type;
Chris@156 506 QSettings settings;
Chris@156 507 settings.beginGroup("Preferences");
Chris@156 508 settings.setValue("window-type", int(type));
Chris@156 509 settings.endGroup();
Chris@141 510 emit propertyChanged("Window Type");
Chris@140 511 }
Chris@140 512 }
Chris@140 513
Chris@164 514 void
Chris@1225 515 Preferences::setRunPluginsInProcess(bool run)
Chris@1225 516 {
Chris@1225 517 if (m_runPluginsInProcess != run) {
Chris@1225 518 m_runPluginsInProcess = run;
Chris@1225 519 QSettings settings;
Chris@1225 520 settings.beginGroup("Preferences");
Chris@1225 521 settings.setValue("run-vamp-plugins-in-process", run);
Chris@1225 522 settings.endGroup();
Chris@1225 523 emit propertyChanged("Run Vamp Plugins In Process");
Chris@1225 524 }
Chris@1225 525 }
Chris@1225 526
Chris@1225 527 void
Chris@277 528 Preferences::setOmitTempsFromRecentFiles(bool omit)
Chris@277 529 {
Chris@277 530 if (m_omitRecentTemps != omit) {
Chris@277 531 m_omitRecentTemps = omit;
Chris@277 532 QSettings settings;
Chris@277 533 settings.beginGroup("Preferences");
Chris@277 534 settings.setValue("omit-recent-temporaries", omit);
Chris@277 535 settings.endGroup();
Chris@277 536 emit propertyChanged("Omit Temporaries from Recent Files");
Chris@277 537 }
Chris@277 538 }
Chris@297 539
Chris@297 540 void
Chris@297 541 Preferences::setTemporaryDirectoryRoot(QString root)
Chris@297 542 {
Chris@297 543 if (root == QDir::home().absolutePath()) {
Chris@297 544 root = "$HOME";
Chris@297 545 }
Chris@297 546 if (m_tempDirRoot != root) {
Chris@297 547 m_tempDirRoot = root;
Chris@297 548 QSettings settings;
Chris@297 549 settings.beginGroup("TempDirectory");
Chris@297 550 settings.setValue("create-in", root);
Chris@297 551 settings.endGroup();
Chris@297 552 emit propertyChanged("Temporary Directory Root");
Chris@297 553 }
Chris@297 554 }
Chris@297 555
Chris@297 556 void
Chris@297 557 Preferences::setResampleOnLoad(bool resample)
Chris@297 558 {
Chris@297 559 if (m_resampleOnLoad != resample) {
Chris@297 560 m_resampleOnLoad = resample;
Chris@297 561 QSettings settings;
Chris@297 562 settings.beginGroup("Preferences");
Chris@297 563 settings.setValue("resample-on-load", resample);
Chris@297 564 settings.endGroup();
Chris@297 565 emit propertyChanged("Resample On Load");
Chris@297 566 }
Chris@297 567 }
Chris@297 568
Chris@297 569 void
Chris@1313 570 Preferences::setUseGaplessMode(bool gapless)
Chris@1313 571 {
Chris@1313 572 if (m_gapless != gapless) {
Chris@1313 573 m_gapless = gapless;
Chris@1313 574 QSettings settings;
Chris@1313 575 settings.beginGroup("Preferences");
Chris@1313 576 settings.setValue("gapless", gapless);
Chris@1313 577 settings.endGroup();
Chris@1313 578 emit propertyChanged("Use Gapless Mode");
Chris@1313 579 }
Chris@1313 580 }
Chris@1313 581
Chris@1313 582 void
Chris@1047 583 Preferences::setFixedSampleRate(sv_samplerate_t rate)
Chris@919 584 {
Chris@919 585 if (m_fixedSampleRate != rate) {
Chris@919 586 m_fixedSampleRate = rate;
Chris@919 587 QSettings settings;
Chris@919 588 settings.beginGroup("Preferences");
Chris@919 589 settings.setValue("fixed-sample-rate", rate);
Chris@919 590 settings.endGroup();
Chris@919 591 emit propertyChanged("Fixed Sample Rate");
Chris@919 592 }
Chris@919 593 }
Chris@919 594
Chris@919 595 void
Chris@921 596 Preferences::setNormaliseAudio(bool norm)
Chris@921 597 {
Chris@921 598 if (m_normaliseAudio != norm) {
Chris@921 599 m_normaliseAudio = norm;
Chris@921 600 QSettings settings;
Chris@921 601 settings.beginGroup("Preferences");
Chris@921 602 settings.setValue("normalise-audio", norm);
Chris@921 603 settings.endGroup();
Chris@921 604 emit propertyChanged("Normalise Audio");
Chris@921 605 }
Chris@921 606 }
Chris@921 607
Chris@921 608 void
Chris@297 609 Preferences::setBackgroundMode(BackgroundMode mode)
Chris@297 610 {
Chris@297 611 if (m_backgroundMode != mode) {
Chris@297 612
Chris@297 613 m_backgroundMode = mode;
Chris@297 614
Chris@297 615 QSettings settings;
Chris@297 616 settings.beginGroup("Preferences");
Chris@297 617 settings.setValue("background-mode", int(mode));
Chris@297 618 settings.endGroup();
Chris@297 619 emit propertyChanged("Background Mode");
Chris@297 620 }
Chris@297 621 }
Chris@297 622
Chris@354 623 void
Chris@612 624 Preferences::setTimeToTextMode(TimeToTextMode mode)
Chris@612 625 {
Chris@612 626 if (m_timeToTextMode != mode) {
Chris@612 627
Chris@612 628 m_timeToTextMode = mode;
Chris@612 629
Chris@612 630 QSettings settings;
Chris@612 631 settings.beginGroup("Preferences");
Chris@612 632 settings.setValue("time-to-text-mode", int(mode));
Chris@612 633 settings.endGroup();
Chris@612 634 emit propertyChanged("Time To Text Mode");
Chris@612 635 }
Chris@612 636 }
Chris@612 637
Chris@612 638 void
Chris@1031 639 Preferences::setShowHMS(bool show)
Chris@1031 640 {
Chris@1031 641 if (m_showHMS != show) {
Chris@1031 642
Chris@1031 643 m_showHMS = show;
Chris@1031 644
Chris@1031 645 QSettings settings;
Chris@1031 646 settings.beginGroup("Preferences");
Chris@1031 647 settings.setValue("show-hours-minutes-seconds", show);
Chris@1031 648 settings.endGroup();
Chris@1031 649 emit propertyChanged("Show Hours And Minutes");
Chris@1031 650 }
Chris@1031 651 }
Chris@1031 652
Chris@1031 653 void
Chris@892 654 Preferences::setOctaveOfMiddleC(int oct)
Chris@892 655 {
Chris@892 656 if (m_octave != oct) {
Chris@892 657
Chris@892 658 m_octave = oct;
Chris@892 659
Chris@892 660 QSettings settings;
Chris@892 661 settings.beginGroup("Preferences");
Chris@892 662 settings.setValue("octave-of-middle-c", int(oct));
Chris@892 663 settings.endGroup();
Chris@892 664 emit propertyChanged("Octave Numbering System");
Chris@892 665 }
Chris@892 666 }
Chris@892 667
Chris@892 668 int
Chris@892 669 Preferences::getOctaveOfMiddleCInSystem(OctaveNumberingSystem s)
Chris@892 670 {
Chris@892 671 switch (s) {
Chris@892 672 case C0_Centre: return 0;
Chris@892 673 case C3_Logic: return 3;
Chris@892 674 case C4_ASA: return 4;
Chris@892 675 case C5_Sonar: return 5;
Chris@892 676 default: return 4;
Chris@892 677 }
Chris@892 678 }
Chris@892 679
Chris@892 680 Preferences::OctaveNumberingSystem
Chris@892 681 Preferences::getSystemWithMiddleCInOctave(int o)
Chris@892 682 {
Chris@892 683 switch (o) {
Chris@892 684 case 0: return C0_Centre;
Chris@892 685 case 3: return C3_Logic;
Chris@892 686 case 4: return C4_ASA;
Chris@892 687 case 5: return C5_Sonar;
Chris@892 688 default: return C4_ASA;
Chris@892 689 }
Chris@892 690 }
Chris@892 691
Chris@892 692 void
Chris@354 693 Preferences::setViewFontSize(int size)
Chris@354 694 {
Chris@354 695 if (m_viewFontSize != size) {
Chris@297 696
Chris@354 697 m_viewFontSize = size;
Chris@354 698
Chris@354 699 QSettings settings;
Chris@354 700 settings.beginGroup("Preferences");
Chris@354 701 settings.setValue("view-font-size", size);
Chris@354 702 settings.endGroup();
Chris@354 703 emit propertyChanged("View Font Size");
Chris@354 704 }
Chris@354 705 }
Chris@354 706
Chris@372 707 void
Chris@372 708 Preferences::setShowSplash(bool show)
Chris@372 709 {
Chris@372 710 if (m_showSplash != show) {
Chris@372 711
Chris@372 712 m_showSplash = show;
Chris@372 713
Chris@372 714 QSettings settings;
Chris@372 715 settings.beginGroup("Preferences");
Chris@372 716 settings.setValue("show-splash", show);
Chris@372 717 settings.endGroup();
Chris@372 718 emit propertyChanged("Show Splash Screen");
Chris@372 719 }
Chris@372 720 }
Chris@372 721