annotate base/Preferences.cpp @ 137:0aafdda005ce

* Remove dependency on the actual stored object type in MatrixFile * Add alternative Compact storage format for FFTFileCache (16-bit instead of 32-bit)
author Chris Cannam
date Wed, 12 Jul 2006 14:15:46 +0000
parents e4acb520ad2a
children 6332e41c1619
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@136 7 This file copyright 2006 Chris Cannam.
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@136 18 Preferences *
Chris@136 19 Preferences::m_instance = new Preferences();
Chris@136 20
Chris@136 21 Preferences::Preferences() :
Chris@137 22 m_smoothSpectrogram(true),
Chris@136 23 m_tuningFrequency(440)
Chris@136 24 {
Chris@136 25 }
Chris@136 26
Chris@136 27 Preferences::PropertyList
Chris@136 28 Preferences::getProperties() const
Chris@136 29 {
Chris@136 30 PropertyList props;
Chris@136 31 props.push_back("Smooth Spectrogram");
Chris@136 32 props.push_back("Tuning Frequency");
Chris@136 33 return props;
Chris@136 34 }
Chris@136 35
Chris@136 36 QString
Chris@136 37 Preferences::getPropertyLabel(const PropertyName &name) const
Chris@136 38 {
Chris@136 39 if (name == "Smooth Spectrogram") {
Chris@136 40 return tr("Spectrogram Display Smoothing");
Chris@136 41 }
Chris@136 42 if (name == "Tuning Frequency") {
Chris@136 43 return tr("Tuning Frequency (concert A)");
Chris@136 44 }
Chris@136 45 return name;
Chris@136 46 }
Chris@136 47
Chris@136 48 Preferences::PropertyType
Chris@136 49 Preferences::getPropertyType(const PropertyName &name) const
Chris@136 50 {
Chris@136 51 if (name == "Smooth Spectrogram") {
Chris@136 52 return ToggleProperty;
Chris@136 53 }
Chris@136 54 if (name == "Tuning Frequency") {
Chris@136 55 return RangeProperty;
Chris@136 56 }
Chris@136 57 return InvalidProperty;
Chris@136 58 }
Chris@136 59
Chris@136 60 int
Chris@136 61 Preferences::getPropertyRangeAndValue(const PropertyName &name,
Chris@136 62 int *min, int *max) const
Chris@136 63 {
Chris@136 64 if (name == "Smooth Spectrogram") {
Chris@136 65 if (min) *min = 0;
Chris@136 66 if (max) *max = 1;
Chris@136 67 return m_smoothSpectrogram ? 1 : 0;
Chris@136 68 }
Chris@136 69
Chris@136 70 //!!! freq mapping
Chris@136 71
Chris@136 72 return 0;
Chris@136 73 }
Chris@136 74
Chris@136 75 QString
Chris@136 76 Preferences::getPropertyValueLabel(const PropertyName &name,
Chris@136 77 int value) const
Chris@136 78 {
Chris@136 79 //!!!
Chris@136 80 return "";
Chris@136 81 }
Chris@136 82
Chris@136 83 QString
Chris@136 84 Preferences::getPropertyContainerName() const
Chris@136 85 {
Chris@136 86 return tr("Preferences");
Chris@136 87 }
Chris@136 88
Chris@136 89 QString
Chris@136 90 Preferences::getPropertyContainerIconName() const
Chris@136 91 {
Chris@136 92 return "preferences";
Chris@136 93 }
Chris@136 94
Chris@136 95 void
Chris@136 96 Preferences::setProperty(const PropertyName &name, int value)
Chris@136 97 {
Chris@136 98 if (name == "Smooth Spectrogram") {
Chris@136 99 setSmoothSpectrogram(value > 0.1);
Chris@136 100 } else if (name == "Tuning Frequency") {
Chris@136 101 //!!!
Chris@136 102 }
Chris@136 103 }
Chris@136 104
Chris@136 105 void
Chris@136 106 Preferences::setSmoothSpectrogram(bool smooth)
Chris@136 107 {
Chris@136 108 m_smoothSpectrogram = smooth;
Chris@136 109 //!!! emit
Chris@136 110 }
Chris@136 111
Chris@136 112 void
Chris@136 113 Preferences::setTuningFrequency(float freq)
Chris@136 114 {
Chris@136 115 m_tuningFrequency = freq;
Chris@136 116 //!!! emit
Chris@136 117 }
Chris@136 118