annotate base/Preferences.cpp @ 1858:14747f24ad04

Use cancellable serialiser; add some more profiling points
author Chris Cannam
date Thu, 14 May 2020 16:36:48 +0100
parents 70e172e6cc59
children 44dba7cd9ec3
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@1582 28 Preferences::m_instance = nullptr;
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@1578 244 if (max) *max = 1;
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 }
Chris@553 357 }
Chris@553 358 if (name == "Spectrogram X Smoothing") {
Chris@553 359 switch (value) {
Chris@553 360 case NoSpectrogramXSmoothing: return tr("None");
Chris@553 361 case SpectrogramXInterpolated: return tr("Linear interpolation");
Chris@246 362 }
Chris@246 363 }
Chris@297 364 if (name == "Background Mode") {
Chris@297 365 switch (value) {
Chris@297 366 case BackgroundFromTheme: return tr("Follow desktop theme");
Chris@297 367 case DarkBackground: return tr("Dark background");
Chris@297 368 case LightBackground: return tr("Light background");
Chris@297 369 }
Chris@297 370 }
Chris@612 371 if (name == "Time To Text Mode") {
Chris@612 372 switch (value) {
Chris@612 373 case TimeToTextMs: return tr("Standard (to millisecond)");
Chris@612 374 case TimeToTextUs: return tr("High resolution (to microsecond)");
Chris@612 375 case TimeToText24Frame: return tr("24 FPS");
Chris@612 376 case TimeToText25Frame: return tr("25 FPS");
Chris@612 377 case TimeToText30Frame: return tr("30 FPS");
Chris@612 378 case TimeToText50Frame: return tr("50 FPS");
Chris@612 379 case TimeToText60Frame: return tr("60 FPS");
Chris@612 380 }
Chris@612 381 }
Chris@892 382 if (name == "Octave Numbering System") {
Chris@892 383 switch (value) {
Chris@892 384 case C0_Centre: return tr("C0 - middle of octave scale");
Chris@892 385 case C3_Logic: return tr("C3 - common MIDI sequencer convention");
Chris@892 386 case C4_ASA: return tr("C4 - ASA American standard");
Chris@892 387 case C5_Sonar: return tr("C5 - used in Cakewalk and others");
Chris@892 388 }
Chris@892 389 }
Chris@246 390
Chris@136 391 return "";
Chris@136 392 }
Chris@136 393
Chris@136 394 QString
Chris@136 395 Preferences::getPropertyContainerName() const
Chris@136 396 {
Chris@136 397 return tr("Preferences");
Chris@136 398 }
Chris@136 399
Chris@136 400 QString
Chris@136 401 Preferences::getPropertyContainerIconName() const
Chris@136 402 {
Chris@136 403 return "preferences";
Chris@136 404 }
Chris@136 405
Chris@136 406 void
Chris@136 407 Preferences::setProperty(const PropertyName &name, int value)
Chris@136 408 {
Chris@553 409 if (name == "Spectrogram Y Smoothing") {
Chris@246 410 setSpectrogramSmoothing(SpectrogramSmoothing(value));
Chris@553 411 } else if (name == "Spectrogram X Smoothing") {
Chris@553 412 setSpectrogramXSmoothing(SpectrogramXSmoothing(value));
Chris@136 413 } else if (name == "Tuning Frequency") {
Chris@136 414 //!!!
Chris@138 415 } else if (name == "Property Box Layout") {
Chris@138 416 setPropertyBoxLayout(value == 0 ? VerticallyStacked : Layered);
Chris@140 417 } else if (name == "Window Type") {
Chris@140 418 setWindowType(WindowType(value));
Chris@1225 419 } else if (name == "Run Vamp Plugins In Process") {
Chris@1225 420 setRunPluginsInProcess(value ? true : false);
Chris@277 421 } else if (name == "Omit Temporaries from Recent Files") {
Chris@277 422 setOmitTempsFromRecentFiles(value ? true : false);
Chris@297 423 } else if (name == "Background Mode") {
Chris@297 424 setBackgroundMode(BackgroundMode(value));
Chris@612 425 } else if (name == "Time To Text Mode") {
Chris@612 426 setTimeToTextMode(TimeToTextMode(value));
Chris@1031 427 } else if (name == "Show Hours And Minutes") {
Chris@1031 428 setShowHMS(value ? true : false);
Chris@892 429 } else if (name == "Octave Numbering System") {
Chris@892 430 setOctaveOfMiddleC(getOctaveOfMiddleCInSystem
Chris@892 431 (OctaveNumberingSystem(value)));
Chris@354 432 } else if (name == "View Font Size") {
Chris@354 433 setViewFontSize(value);
Chris@372 434 } else if (name == "Show Splash Screen") {
Chris@372 435 setShowSplash(value ? true : false);
Chris@136 436 }
Chris@136 437 }
Chris@136 438
Chris@136 439 void
Chris@246 440 Preferences::setSpectrogramSmoothing(SpectrogramSmoothing smoothing)
Chris@136 441 {
Chris@246 442 if (m_spectrogramSmoothing != smoothing) {
Chris@246 443
Chris@246 444 // "smoothing" is one of those words that looks increasingly
Chris@246 445 // ridiculous the more you see it. Smoothing smoothing smoothing.
Chris@246 446 m_spectrogramSmoothing = smoothing;
Chris@246 447
Chris@156 448 QSettings settings;
Chris@156 449 settings.beginGroup("Preferences");
Chris@553 450 settings.setValue("spectrogram-y-smoothing", int(smoothing));
Chris@156 451 settings.endGroup();
Chris@553 452 emit propertyChanged("Spectrogram Y Smoothing");
Chris@553 453 }
Chris@553 454 }
Chris@553 455
Chris@553 456 void
Chris@553 457 Preferences::setSpectrogramXSmoothing(SpectrogramXSmoothing smoothing)
Chris@553 458 {
Chris@553 459 if (m_spectrogramXSmoothing != smoothing) {
Chris@553 460
Chris@553 461 // "smoothing" is one of those words that looks increasingly
Chris@553 462 // ridiculous the more you see it. Smoothing smoothing smoothing.
Chris@553 463 m_spectrogramXSmoothing = smoothing;
Chris@553 464
Chris@553 465 QSettings settings;
Chris@553 466 settings.beginGroup("Preferences");
Chris@553 467 settings.setValue("spectrogram-x-smoothing", int(smoothing));
Chris@553 468 settings.endGroup();
Chris@553 469 emit propertyChanged("Spectrogram X Smoothing");
Chris@138 470 }
Chris@136 471 }
Chris@136 472
Chris@136 473 void
Chris@1038 474 Preferences::setTuningFrequency(double freq)
Chris@136 475 {
Chris@138 476 if (m_tuningFrequency != freq) {
Chris@138 477 m_tuningFrequency = freq;
Chris@156 478 QSettings settings;
Chris@156 479 settings.beginGroup("Preferences");
Chris@156 480 settings.setValue("tuning-frequency", freq);
Chris@156 481 settings.endGroup();
Chris@141 482 emit propertyChanged("Tuning Frequency");
Chris@138 483 }
Chris@136 484 }
Chris@136 485
Chris@138 486 void
Chris@138 487 Preferences::setPropertyBoxLayout(PropertyBoxLayout layout)
Chris@138 488 {
Chris@138 489 if (m_propertyBoxLayout != layout) {
Chris@138 490 m_propertyBoxLayout = layout;
Chris@156 491 QSettings settings;
Chris@156 492 settings.beginGroup("Preferences");
Chris@156 493 settings.setValue("property-box-layout", int(layout));
Chris@156 494 settings.endGroup();
Chris@141 495 emit propertyChanged("Property Box Layout");
Chris@138 496 }
Chris@138 497 }
Chris@138 498
Chris@140 499 void
Chris@140 500 Preferences::setWindowType(WindowType type)
Chris@140 501 {
Chris@140 502 if (m_windowType != type) {
Chris@140 503 m_windowType = type;
Chris@156 504 QSettings settings;
Chris@156 505 settings.beginGroup("Preferences");
Chris@156 506 settings.setValue("window-type", int(type));
Chris@156 507 settings.endGroup();
Chris@141 508 emit propertyChanged("Window Type");
Chris@140 509 }
Chris@140 510 }
Chris@140 511
Chris@164 512 void
Chris@1225 513 Preferences::setRunPluginsInProcess(bool run)
Chris@1225 514 {
Chris@1225 515 if (m_runPluginsInProcess != run) {
Chris@1225 516 m_runPluginsInProcess = run;
Chris@1225 517 QSettings settings;
Chris@1225 518 settings.beginGroup("Preferences");
Chris@1225 519 settings.setValue("run-vamp-plugins-in-process", run);
Chris@1225 520 settings.endGroup();
Chris@1225 521 emit propertyChanged("Run Vamp Plugins In Process");
Chris@1225 522 }
Chris@1225 523 }
Chris@1225 524
Chris@1225 525 void
Chris@277 526 Preferences::setOmitTempsFromRecentFiles(bool omit)
Chris@277 527 {
Chris@277 528 if (m_omitRecentTemps != omit) {
Chris@277 529 m_omitRecentTemps = omit;
Chris@277 530 QSettings settings;
Chris@277 531 settings.beginGroup("Preferences");
Chris@277 532 settings.setValue("omit-recent-temporaries", omit);
Chris@277 533 settings.endGroup();
Chris@277 534 emit propertyChanged("Omit Temporaries from Recent Files");
Chris@277 535 }
Chris@277 536 }
Chris@297 537
Chris@297 538 void
Chris@297 539 Preferences::setTemporaryDirectoryRoot(QString root)
Chris@297 540 {
Chris@297 541 if (root == QDir::home().absolutePath()) {
Chris@297 542 root = "$HOME";
Chris@297 543 }
Chris@297 544 if (m_tempDirRoot != root) {
Chris@297 545 m_tempDirRoot = root;
Chris@297 546 QSettings settings;
Chris@297 547 settings.beginGroup("TempDirectory");
Chris@297 548 settings.setValue("create-in", root);
Chris@297 549 settings.endGroup();
Chris@297 550 emit propertyChanged("Temporary Directory Root");
Chris@297 551 }
Chris@297 552 }
Chris@297 553
Chris@297 554 void
Chris@297 555 Preferences::setResampleOnLoad(bool resample)
Chris@297 556 {
Chris@297 557 if (m_resampleOnLoad != resample) {
Chris@297 558 m_resampleOnLoad = resample;
Chris@297 559 QSettings settings;
Chris@297 560 settings.beginGroup("Preferences");
Chris@297 561 settings.setValue("resample-on-load", resample);
Chris@297 562 settings.endGroup();
Chris@297 563 emit propertyChanged("Resample On Load");
Chris@297 564 }
Chris@297 565 }
Chris@297 566
Chris@297 567 void
Chris@1313 568 Preferences::setUseGaplessMode(bool gapless)
Chris@1313 569 {
Chris@1313 570 if (m_gapless != gapless) {
Chris@1313 571 m_gapless = gapless;
Chris@1313 572 QSettings settings;
Chris@1313 573 settings.beginGroup("Preferences");
Chris@1313 574 settings.setValue("gapless", gapless);
Chris@1313 575 settings.endGroup();
Chris@1313 576 emit propertyChanged("Use Gapless Mode");
Chris@1313 577 }
Chris@1313 578 }
Chris@1313 579
Chris@1313 580 void
Chris@1047 581 Preferences::setFixedSampleRate(sv_samplerate_t rate)
Chris@919 582 {
Chris@919 583 if (m_fixedSampleRate != rate) {
Chris@919 584 m_fixedSampleRate = rate;
Chris@919 585 QSettings settings;
Chris@919 586 settings.beginGroup("Preferences");
Chris@919 587 settings.setValue("fixed-sample-rate", rate);
Chris@919 588 settings.endGroup();
Chris@919 589 emit propertyChanged("Fixed Sample Rate");
Chris@919 590 }
Chris@919 591 }
Chris@919 592
Chris@919 593 void
Chris@921 594 Preferences::setNormaliseAudio(bool norm)
Chris@921 595 {
Chris@921 596 if (m_normaliseAudio != norm) {
Chris@921 597 m_normaliseAudio = norm;
Chris@921 598 QSettings settings;
Chris@921 599 settings.beginGroup("Preferences");
Chris@921 600 settings.setValue("normalise-audio", norm);
Chris@921 601 settings.endGroup();
Chris@921 602 emit propertyChanged("Normalise Audio");
Chris@921 603 }
Chris@921 604 }
Chris@921 605
Chris@921 606 void
Chris@297 607 Preferences::setBackgroundMode(BackgroundMode mode)
Chris@297 608 {
Chris@297 609 if (m_backgroundMode != mode) {
Chris@297 610
Chris@297 611 m_backgroundMode = mode;
Chris@297 612
Chris@297 613 QSettings settings;
Chris@297 614 settings.beginGroup("Preferences");
Chris@297 615 settings.setValue("background-mode", int(mode));
Chris@297 616 settings.endGroup();
Chris@297 617 emit propertyChanged("Background Mode");
Chris@297 618 }
Chris@297 619 }
Chris@297 620
Chris@354 621 void
Chris@612 622 Preferences::setTimeToTextMode(TimeToTextMode mode)
Chris@612 623 {
Chris@612 624 if (m_timeToTextMode != mode) {
Chris@612 625
Chris@612 626 m_timeToTextMode = mode;
Chris@612 627
Chris@612 628 QSettings settings;
Chris@612 629 settings.beginGroup("Preferences");
Chris@612 630 settings.setValue("time-to-text-mode", int(mode));
Chris@612 631 settings.endGroup();
Chris@612 632 emit propertyChanged("Time To Text Mode");
Chris@612 633 }
Chris@612 634 }
Chris@612 635
Chris@612 636 void
Chris@1031 637 Preferences::setShowHMS(bool show)
Chris@1031 638 {
Chris@1031 639 if (m_showHMS != show) {
Chris@1031 640
Chris@1031 641 m_showHMS = show;
Chris@1031 642
Chris@1031 643 QSettings settings;
Chris@1031 644 settings.beginGroup("Preferences");
Chris@1031 645 settings.setValue("show-hours-minutes-seconds", show);
Chris@1031 646 settings.endGroup();
Chris@1031 647 emit propertyChanged("Show Hours And Minutes");
Chris@1031 648 }
Chris@1031 649 }
Chris@1031 650
Chris@1031 651 void
Chris@892 652 Preferences::setOctaveOfMiddleC(int oct)
Chris@892 653 {
Chris@892 654 if (m_octave != oct) {
Chris@892 655
Chris@892 656 m_octave = oct;
Chris@892 657
Chris@892 658 QSettings settings;
Chris@892 659 settings.beginGroup("Preferences");
Chris@892 660 settings.setValue("octave-of-middle-c", int(oct));
Chris@892 661 settings.endGroup();
Chris@892 662 emit propertyChanged("Octave Numbering System");
Chris@892 663 }
Chris@892 664 }
Chris@892 665
Chris@892 666 int
Chris@892 667 Preferences::getOctaveOfMiddleCInSystem(OctaveNumberingSystem s)
Chris@892 668 {
Chris@892 669 switch (s) {
Chris@892 670 case C0_Centre: return 0;
Chris@892 671 case C3_Logic: return 3;
Chris@892 672 case C4_ASA: return 4;
Chris@892 673 case C5_Sonar: return 5;
Chris@892 674 default: return 4;
Chris@892 675 }
Chris@892 676 }
Chris@892 677
Chris@892 678 Preferences::OctaveNumberingSystem
Chris@892 679 Preferences::getSystemWithMiddleCInOctave(int o)
Chris@892 680 {
Chris@892 681 switch (o) {
Chris@892 682 case 0: return C0_Centre;
Chris@892 683 case 3: return C3_Logic;
Chris@892 684 case 4: return C4_ASA;
Chris@892 685 case 5: return C5_Sonar;
Chris@892 686 default: return C4_ASA;
Chris@892 687 }
Chris@892 688 }
Chris@892 689
Chris@892 690 void
Chris@354 691 Preferences::setViewFontSize(int size)
Chris@354 692 {
Chris@354 693 if (m_viewFontSize != size) {
Chris@297 694
Chris@354 695 m_viewFontSize = size;
Chris@354 696
Chris@354 697 QSettings settings;
Chris@354 698 settings.beginGroup("Preferences");
Chris@354 699 settings.setValue("view-font-size", size);
Chris@354 700 settings.endGroup();
Chris@354 701 emit propertyChanged("View Font Size");
Chris@354 702 }
Chris@354 703 }
Chris@354 704
Chris@372 705 void
Chris@372 706 Preferences::setShowSplash(bool show)
Chris@372 707 {
Chris@372 708 if (m_showSplash != show) {
Chris@372 709
Chris@372 710 m_showSplash = show;
Chris@372 711
Chris@372 712 QSettings settings;
Chris@372 713 settings.beginGroup("Preferences");
Chris@372 714 settings.setValue("show-splash", show);
Chris@372 715 settings.endGroup();
Chris@372 716 emit propertyChanged("Show Splash Screen");
Chris@372 717 }
Chris@372 718 }
Chris@372 719