annotate base/Preferences.cpp @ 1219:794b64e62e58 msvc2015_64

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