diff 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
line wrap: on
line diff
--- a/base/Preferences.cpp	Mon Dec 10 17:37:13 2007 +0000
+++ b/base/Preferences.cpp	Tue Dec 11 14:58:29 2007 +0000
@@ -23,6 +23,8 @@
 #include <QFileInfo>
 #include <QMutex>
 #include <QSettings>
+#include <QApplication>
+#include <QFont>
 
 Preferences *
 Preferences::m_instance = 0;
@@ -42,7 +44,9 @@
     m_resampleQuality(1),
     m_omitRecentTemps(true),
     m_tempDirRoot(""),
-    m_resampleOnLoad(false)
+    m_resampleOnLoad(false),
+    m_viewFontSize(10),
+    m_backgroundMode(BackgroundFromTheme)
 {
     QSettings settings;
     settings.beginGroup("Preferences");
@@ -57,6 +61,8 @@
     m_resampleOnLoad = settings.value("resample-on-load", false).toBool();
     m_backgroundMode = BackgroundMode
         (settings.value("background-mode", int(BackgroundFromTheme)).toInt());
+    m_viewFontSize = settings.value
+        ("view-font-size", QApplication::font().pointSize() * 0.9).toInt();
     settings.endGroup();
 
     settings.beginGroup("TempDirectory");
@@ -81,6 +87,7 @@
     props.push_back("Resample On Load");
     props.push_back("Temporary Directory Root");
     props.push_back("Background Mode");
+    props.push_back("View Font Size");
     return props;
 }
 
@@ -114,6 +121,9 @@
     if (name == "Background Mode") {
         return tr("Background colour preference");
     }
+    if (name == "View Font Size") {
+        return tr("Font size for text overlays");
+    }
     return name;
 }
 
@@ -148,6 +158,9 @@
     if (name == "Background Mode") {
         return ValueProperty;
     }
+    if (name == "View Font Size") {
+        return RangeProperty;
+    }
     return InvalidProperty;
 }
 
@@ -196,6 +209,13 @@
         return int(m_backgroundMode);
     }        
 
+    if (name == "View Font Size") {
+        if (min) *min = 3;
+        if (max) *max = 48;
+        if (deflt) *deflt = int(QApplication::font().pointSize() * 0.9);
+        return int(m_viewFontSize);
+    }
+
     return 0;
 }
 
@@ -274,6 +294,8 @@
         setOmitTempsFromRecentFiles(value ? true : false);
     } else if (name == "Background Mode") {
         setBackgroundMode(BackgroundMode(value));
+    } else if (name == "View Font Size") {
+        setViewFontSize(value);
     }
 }
 
@@ -403,4 +425,18 @@
     }
 }
 
+void
+Preferences::setViewFontSize(int size)
+{
+    if (m_viewFontSize != size) {
 
+        m_viewFontSize = size;
+
+        QSettings settings;
+        settings.beginGroup("Preferences");
+        settings.setValue("view-font-size", size);
+        settings.endGroup();
+        emit propertyChanged("View Font Size");
+    }
+}
+