comparison base/Preferences.cpp @ 354:048b21bc9891

* Make font size in panes configurable, with a smaller default * Add [ and ] to select prev/next pane
author Chris Cannam
date Tue, 11 Dec 2007 14:58:29 +0000
parents 4fc6f49436b3
children 722bc705775a
comparison
equal deleted inserted replaced
353:1c6816220185 354:048b21bc9891
21 21
22 #include <QDir> 22 #include <QDir>
23 #include <QFileInfo> 23 #include <QFileInfo>
24 #include <QMutex> 24 #include <QMutex>
25 #include <QSettings> 25 #include <QSettings>
26 #include <QApplication>
27 #include <QFont>
26 28
27 Preferences * 29 Preferences *
28 Preferences::m_instance = 0; 30 Preferences::m_instance = 0;
29 31
30 Preferences * 32 Preferences *
40 m_propertyBoxLayout(VerticallyStacked), 42 m_propertyBoxLayout(VerticallyStacked),
41 m_windowType(HanningWindow), 43 m_windowType(HanningWindow),
42 m_resampleQuality(1), 44 m_resampleQuality(1),
43 m_omitRecentTemps(true), 45 m_omitRecentTemps(true),
44 m_tempDirRoot(""), 46 m_tempDirRoot(""),
45 m_resampleOnLoad(false) 47 m_resampleOnLoad(false),
48 m_viewFontSize(10),
49 m_backgroundMode(BackgroundFromTheme)
46 { 50 {
47 QSettings settings; 51 QSettings settings;
48 settings.beginGroup("Preferences"); 52 settings.beginGroup("Preferences");
49 m_spectrogramSmoothing = SpectrogramSmoothing 53 m_spectrogramSmoothing = SpectrogramSmoothing
50 (settings.value("spectrogram-smoothing", int(m_spectrogramSmoothing)).toInt()); 54 (settings.value("spectrogram-smoothing", int(m_spectrogramSmoothing)).toInt());
55 (settings.value("window-type", int(HanningWindow)).toInt()); 59 (settings.value("window-type", int(HanningWindow)).toInt());
56 m_resampleQuality = settings.value("resample-quality", 1).toInt(); 60 m_resampleQuality = settings.value("resample-quality", 1).toInt();
57 m_resampleOnLoad = settings.value("resample-on-load", false).toBool(); 61 m_resampleOnLoad = settings.value("resample-on-load", false).toBool();
58 m_backgroundMode = BackgroundMode 62 m_backgroundMode = BackgroundMode
59 (settings.value("background-mode", int(BackgroundFromTheme)).toInt()); 63 (settings.value("background-mode", int(BackgroundFromTheme)).toInt());
64 m_viewFontSize = settings.value
65 ("view-font-size", QApplication::font().pointSize() * 0.9).toInt();
60 settings.endGroup(); 66 settings.endGroup();
61 67
62 settings.beginGroup("TempDirectory"); 68 settings.beginGroup("TempDirectory");
63 m_tempDirRoot = settings.value("create-in", "$HOME").toString(); 69 m_tempDirRoot = settings.value("create-in", "$HOME").toString();
64 settings.endGroup(); 70 settings.endGroup();
79 props.push_back("Resample Quality"); 85 props.push_back("Resample Quality");
80 props.push_back("Omit Temporaries from Recent Files"); 86 props.push_back("Omit Temporaries from Recent Files");
81 props.push_back("Resample On Load"); 87 props.push_back("Resample On Load");
82 props.push_back("Temporary Directory Root"); 88 props.push_back("Temporary Directory Root");
83 props.push_back("Background Mode"); 89 props.push_back("Background Mode");
90 props.push_back("View Font Size");
84 return props; 91 return props;
85 } 92 }
86 93
87 QString 94 QString
88 Preferences::getPropertyLabel(const PropertyName &name) const 95 Preferences::getPropertyLabel(const PropertyName &name) const
111 if (name == "Temporary Directory Root") { 118 if (name == "Temporary Directory Root") {
112 return tr("Location for cache file directory"); 119 return tr("Location for cache file directory");
113 } 120 }
114 if (name == "Background Mode") { 121 if (name == "Background Mode") {
115 return tr("Background colour preference"); 122 return tr("Background colour preference");
123 }
124 if (name == "View Font Size") {
125 return tr("Font size for text overlays");
116 } 126 }
117 return name; 127 return name;
118 } 128 }
119 129
120 Preferences::PropertyType 130 Preferences::PropertyType
145 // It's an arbitrary string, we don't have a set of values for this 155 // It's an arbitrary string, we don't have a set of values for this
146 return InvalidProperty; 156 return InvalidProperty;
147 } 157 }
148 if (name == "Background Mode") { 158 if (name == "Background Mode") {
149 return ValueProperty; 159 return ValueProperty;
160 }
161 if (name == "View Font Size") {
162 return RangeProperty;
150 } 163 }
151 return InvalidProperty; 164 return InvalidProperty;
152 } 165 }
153 166
154 int 167 int
193 if (min) *min = 0; 206 if (min) *min = 0;
194 if (max) *max = 2; 207 if (max) *max = 2;
195 if (deflt) *deflt = 0; 208 if (deflt) *deflt = 0;
196 return int(m_backgroundMode); 209 return int(m_backgroundMode);
197 } 210 }
211
212 if (name == "View Font Size") {
213 if (min) *min = 3;
214 if (max) *max = 48;
215 if (deflt) *deflt = int(QApplication::font().pointSize() * 0.9);
216 return int(m_viewFontSize);
217 }
198 218
199 return 0; 219 return 0;
200 } 220 }
201 221
202 QString 222 QString
272 setResampleQuality(value); 292 setResampleQuality(value);
273 } else if (name == "Omit Temporaries from Recent Files") { 293 } else if (name == "Omit Temporaries from Recent Files") {
274 setOmitTempsFromRecentFiles(value ? true : false); 294 setOmitTempsFromRecentFiles(value ? true : false);
275 } else if (name == "Background Mode") { 295 } else if (name == "Background Mode") {
276 setBackgroundMode(BackgroundMode(value)); 296 setBackgroundMode(BackgroundMode(value));
297 } else if (name == "View Font Size") {
298 setViewFontSize(value);
277 } 299 }
278 } 300 }
279 301
280 void 302 void
281 Preferences::setSpectrogramSmoothing(SpectrogramSmoothing smoothing) 303 Preferences::setSpectrogramSmoothing(SpectrogramSmoothing smoothing)
401 settings.endGroup(); 423 settings.endGroup();
402 emit propertyChanged("Background Mode"); 424 emit propertyChanged("Background Mode");
403 } 425 }
404 } 426 }
405 427
406 428 void
429 Preferences::setViewFontSize(int size)
430 {
431 if (m_viewFontSize != size) {
432
433 m_viewFontSize = size;
434
435 QSettings settings;
436 settings.beginGroup("Preferences");
437 settings.setValue("view-font-size", size);
438 settings.endGroup();
439 emit propertyChanged("View Font Size");
440 }
441 }
442