annotate base/Preferences.cpp @ 1316:a421e752d22c 3.0-integration

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