comparison base/Preferences.cpp @ 136:e4acb520ad2a

* fledgling preferences stuff
author Chris Cannam
date Mon, 10 Jul 2006 13:54:49 +0000
parents
children 0aafdda005ce
comparison
equal deleted inserted replaced
135:fb8422cf4326 136:e4acb520ad2a
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2
3 /*
4 Sonic Visualiser
5 An audio file viewer and annotation editor.
6 Centre for Digital Music, Queen Mary, University of London.
7 This file copyright 2006 Chris Cannam.
8
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License as
11 published by the Free Software Foundation; either version 2 of the
12 License, or (at your option) any later version. See the file
13 COPYING included with this distribution for more information.
14 */
15
16 #include "Preferences.h"
17
18 Preferences *
19 Preferences::m_instance = new Preferences();
20
21 Preferences::Preferences() :
22 m_smoothSpectrogram(false),
23 m_tuningFrequency(440)
24 {
25 }
26
27 Preferences::PropertyList
28 Preferences::getProperties() const
29 {
30 PropertyList props;
31 props.push_back("Smooth Spectrogram");
32 props.push_back("Tuning Frequency");
33 return props;
34 }
35
36 QString
37 Preferences::getPropertyLabel(const PropertyName &name) const
38 {
39 if (name == "Smooth Spectrogram") {
40 return tr("Spectrogram Display Smoothing");
41 }
42 if (name == "Tuning Frequency") {
43 return tr("Tuning Frequency (concert A)");
44 }
45 return name;
46 }
47
48 Preferences::PropertyType
49 Preferences::getPropertyType(const PropertyName &name) const
50 {
51 if (name == "Smooth Spectrogram") {
52 return ToggleProperty;
53 }
54 if (name == "Tuning Frequency") {
55 return RangeProperty;
56 }
57 return InvalidProperty;
58 }
59
60 int
61 Preferences::getPropertyRangeAndValue(const PropertyName &name,
62 int *min, int *max) const
63 {
64 if (name == "Smooth Spectrogram") {
65 if (min) *min = 0;
66 if (max) *max = 1;
67 return m_smoothSpectrogram ? 1 : 0;
68 }
69
70 //!!! freq mapping
71
72 return 0;
73 }
74
75 QString
76 Preferences::getPropertyValueLabel(const PropertyName &name,
77 int value) const
78 {
79 //!!!
80 return "";
81 }
82
83 QString
84 Preferences::getPropertyContainerName() const
85 {
86 return tr("Preferences");
87 }
88
89 QString
90 Preferences::getPropertyContainerIconName() const
91 {
92 return "preferences";
93 }
94
95 void
96 Preferences::setProperty(const PropertyName &name, int value)
97 {
98 if (name == "Smooth Spectrogram") {
99 setSmoothSpectrogram(value > 0.1);
100 } else if (name == "Tuning Frequency") {
101 //!!!
102 }
103 }
104
105 void
106 Preferences::setSmoothSpectrogram(bool smooth)
107 {
108 m_smoothSpectrogram = smooth;
109 //!!! emit
110 }
111
112 void
113 Preferences::setTuningFrequency(float freq)
114 {
115 m_tuningFrequency = freq;
116 //!!! emit
117 }
118