Mercurial > hg > svgui
comparison layer/WaveformLayer.cpp @ 87:4b98bda7e94d
* Add property labels to property containers (so i18n() won't affect file format)
author | Chris Cannam |
---|---|
date | Wed, 03 May 2006 16:48:03 +0000 |
parents | 19bf27e4fb29 |
children | 0f36cdf407a6 |
comparison
equal
deleted
inserted
replaced
86:93a7efc75fb7 | 87:4b98bda7e94d |
---|---|
88 | 88 |
89 Layer::PropertyList | 89 Layer::PropertyList |
90 WaveformLayer::getProperties() const | 90 WaveformLayer::getProperties() const |
91 { | 91 { |
92 PropertyList list; | 92 PropertyList list; |
93 list.push_back(tr("Colour")); | 93 list.push_back("Colour"); |
94 list.push_back(tr("Scale")); | 94 list.push_back("Scale"); |
95 list.push_back(tr("Gain")); | 95 list.push_back("Gain"); |
96 list.push_back(tr("Normalize Visible Area")); | 96 list.push_back("Normalize Visible Area"); |
97 | 97 |
98 if (m_model && m_model->getChannelCount() > 1 && m_channel == -1) { | 98 if (m_model && m_model->getChannelCount() > 1 && m_channel == -1) { |
99 list.push_back(tr("Channels")); | 99 list.push_back("Channels"); |
100 } | 100 } |
101 | 101 |
102 return list; | 102 return list; |
103 } | |
104 | |
105 QString | |
106 WaveformLayer::getPropertyLabel(const PropertyName &name) const | |
107 { | |
108 if (name == "Colour") return tr("Colour"); | |
109 if (name == "Scale") return tr("Scale"); | |
110 if (name == "Gain") return tr("Gain"); | |
111 if (name == "Normalize Visible Area") return tr("Normalize Visible Area"); | |
112 if (name == "Channels") return tr("Channels"); | |
113 return ""; | |
103 } | 114 } |
104 | 115 |
105 Layer::PropertyType | 116 Layer::PropertyType |
106 WaveformLayer::getPropertyType(const PropertyName &name) const | 117 WaveformLayer::getPropertyType(const PropertyName &name) const |
107 { | 118 { |
108 if (name == tr("Gain")) return RangeProperty; | 119 if (name == "Gain") return RangeProperty; |
109 if (name == tr("Normalize Visible Area")) return ToggleProperty; | 120 if (name == "Normalize Visible Area") return ToggleProperty; |
110 if (name == tr("Colour")) return ValueProperty; | 121 if (name == "Colour") return ValueProperty; |
111 if (name == tr("Channels")) return ValueProperty; | 122 if (name == "Channels") return ValueProperty; |
112 if (name == tr("Scale")) return ValueProperty; | 123 if (name == "Scale") return ValueProperty; |
113 return InvalidProperty; | 124 return InvalidProperty; |
114 } | 125 } |
115 | 126 |
116 QString | 127 QString |
117 WaveformLayer::getPropertyGroupName(const PropertyName &name) const | 128 WaveformLayer::getPropertyGroupName(const PropertyName &name) const |
118 { | 129 { |
119 if (name == tr("Gain") || | 130 if (name == "Gain" || |
120 name == tr("Normalize Visible Area") || | 131 name == "Normalize Visible Area" || |
121 name == tr("Scale")) return tr("Scale"); | 132 name == "Scale") return tr("Scale"); |
122 return QString(); | 133 return QString(); |
123 } | 134 } |
124 | 135 |
125 int | 136 int |
126 WaveformLayer::getPropertyRangeAndValue(const PropertyName &name, | 137 WaveformLayer::getPropertyRangeAndValue(const PropertyName &name, |
130 | 141 |
131 int garbage0, garbage1; | 142 int garbage0, garbage1; |
132 if (!min) min = &garbage0; | 143 if (!min) min = &garbage0; |
133 if (!max) max = &garbage1; | 144 if (!max) max = &garbage1; |
134 | 145 |
135 if (name == tr("Gain")) { | 146 if (name == "Gain") { |
136 | 147 |
137 *min = -50; | 148 *min = -50; |
138 *max = 50; | 149 *max = 50; |
139 | 150 |
140 deft = lrint(log10(m_gain) * 20.0); | 151 deft = lrint(log10(m_gain) * 20.0); |
141 if (deft < *min) deft = *min; | 152 if (deft < *min) deft = *min; |
142 if (deft > *max) deft = *max; | 153 if (deft > *max) deft = *max; |
143 | 154 |
144 } else if (name == tr("Normalize Visible Area")) { | 155 } else if (name == "Normalize Visible Area") { |
145 | 156 |
146 deft = (m_autoNormalize ? 1 : 0); | 157 deft = (m_autoNormalize ? 1 : 0); |
147 | 158 |
148 } else if (name == tr("Colour")) { | 159 } else if (name == "Colour") { |
149 | 160 |
150 *min = 0; | 161 *min = 0; |
151 *max = 5; | 162 *max = 5; |
152 | 163 |
153 if (m_colour == Qt::black) deft = 0; | 164 if (m_colour == Qt::black) deft = 0; |
155 else if (m_colour == Qt::darkBlue) deft = 2; | 166 else if (m_colour == Qt::darkBlue) deft = 2; |
156 else if (m_colour == Qt::darkGreen) deft = 3; | 167 else if (m_colour == Qt::darkGreen) deft = 3; |
157 else if (m_colour == QColor(200, 50, 255)) deft = 4; | 168 else if (m_colour == QColor(200, 50, 255)) deft = 4; |
158 else if (m_colour == QColor(255, 150, 50)) deft = 5; | 169 else if (m_colour == QColor(255, 150, 50)) deft = 5; |
159 | 170 |
160 } else if (name == tr("Channels")) { | 171 } else if (name == "Channels") { |
161 | 172 |
162 *min = 0; | 173 *min = 0; |
163 *max = 2; | 174 *max = 2; |
164 if (m_channelMode == MixChannels) deft = 1; | 175 if (m_channelMode == MixChannels) deft = 1; |
165 else if (m_channelMode == MergeChannels) deft = 2; | 176 else if (m_channelMode == MergeChannels) deft = 2; |
166 else deft = 0; | 177 else deft = 0; |
167 | 178 |
168 } else if (name == tr("Scale")) { | 179 } else if (name == "Scale") { |
169 | 180 |
170 *min = 0; | 181 *min = 0; |
171 *max = 2; | 182 *max = 2; |
172 | 183 |
173 deft = (int)m_scale; | 184 deft = (int)m_scale; |
181 | 192 |
182 QString | 193 QString |
183 WaveformLayer::getPropertyValueLabel(const PropertyName &name, | 194 WaveformLayer::getPropertyValueLabel(const PropertyName &name, |
184 int value) const | 195 int value) const |
185 { | 196 { |
186 if (name == tr("Colour")) { | 197 if (name == "Colour") { |
187 switch (value) { | 198 switch (value) { |
188 default: | 199 default: |
189 case 0: return tr("Black"); | 200 case 0: return tr("Black"); |
190 case 1: return tr("Red"); | 201 case 1: return tr("Red"); |
191 case 2: return tr("Blue"); | 202 case 2: return tr("Blue"); |
192 case 3: return tr("Green"); | 203 case 3: return tr("Green"); |
193 case 4: return tr("Purple"); | 204 case 4: return tr("Purple"); |
194 case 5: return tr("Orange"); | 205 case 5: return tr("Orange"); |
195 } | 206 } |
196 } | 207 } |
197 if (name == tr("Scale")) { | 208 if (name == "Scale") { |
198 switch (value) { | 209 switch (value) { |
199 default: | 210 default: |
200 case 0: return tr("Linear"); | 211 case 0: return tr("Linear"); |
201 case 1: return tr("Meter"); | 212 case 1: return tr("Meter"); |
202 case 2: return tr("dB"); | 213 case 2: return tr("dB"); |
203 } | 214 } |
204 } | 215 } |
205 if (name == tr("Channels")) { | 216 if (name == "Channels") { |
206 switch (value) { | 217 switch (value) { |
207 default: | 218 default: |
208 case 0: return tr("Separate"); | 219 case 0: return tr("Separate"); |
209 case 1: return tr("Mean"); | 220 case 1: return tr("Mean"); |
210 case 2: return tr("Butterfly"); | 221 case 2: return tr("Butterfly"); |
214 } | 225 } |
215 | 226 |
216 void | 227 void |
217 WaveformLayer::setProperty(const PropertyName &name, int value) | 228 WaveformLayer::setProperty(const PropertyName &name, int value) |
218 { | 229 { |
219 if (name == tr("Gain")) { | 230 if (name == "Gain") { |
220 setGain(pow(10, float(value)/20.0)); | 231 setGain(pow(10, float(value)/20.0)); |
221 } else if (name == tr("Normalize Visible Area")) { | 232 } else if (name == "Normalize Visible Area") { |
222 setAutoNormalize(value ? true : false); | 233 setAutoNormalize(value ? true : false); |
223 } else if (name == tr("Colour")) { | 234 } else if (name == "Colour") { |
224 switch (value) { | 235 switch (value) { |
225 default: | 236 default: |
226 case 0: setBaseColour(Qt::black); break; | 237 case 0: setBaseColour(Qt::black); break; |
227 case 1: setBaseColour(Qt::darkRed); break; | 238 case 1: setBaseColour(Qt::darkRed); break; |
228 case 2: setBaseColour(Qt::darkBlue); break; | 239 case 2: setBaseColour(Qt::darkBlue); break; |
229 case 3: setBaseColour(Qt::darkGreen); break; | 240 case 3: setBaseColour(Qt::darkGreen); break; |
230 case 4: setBaseColour(QColor(200, 50, 255)); break; | 241 case 4: setBaseColour(QColor(200, 50, 255)); break; |
231 case 5: setBaseColour(QColor(255, 150, 50)); break; | 242 case 5: setBaseColour(QColor(255, 150, 50)); break; |
232 } | 243 } |
233 } else if (name == tr("Channels")) { | 244 } else if (name == "Channels") { |
234 if (value == 1) setChannelMode(MixChannels); | 245 if (value == 1) setChannelMode(MixChannels); |
235 else if (value == 2) setChannelMode(MergeChannels); | 246 else if (value == 2) setChannelMode(MergeChannels); |
236 else setChannelMode(SeparateChannels); | 247 else setChannelMode(SeparateChannels); |
237 } else if (name == tr("Scale")) { | 248 } else if (name == "Scale") { |
238 switch (value) { | 249 switch (value) { |
239 default: | 250 default: |
240 case 0: setScale(LinearScale); break; | 251 case 0: setScale(LinearScale); break; |
241 case 1: setScale(MeterScale); break; | 252 case 1: setScale(MeterScale); break; |
242 case 2: setScale(dBScale); break; | 253 case 2: setScale(dBScale); break; |