changeset 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 1c6816220185
children d02f71281639
files base/Preferences.cpp base/Preferences.h
diffstat 2 files changed, 41 insertions(+), 1 deletions(-) [+]
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");
+    }
+}
+
--- a/base/Preferences.h	Mon Dec 10 17:37:13 2007 +0000
+++ b/base/Preferences.h	Tue Dec 11 14:58:29 2007 +0000
@@ -54,6 +54,8 @@
     };
     PropertyBoxLayout getPropertyBoxLayout() const { return m_propertyBoxLayout; }
 
+    int getViewFontSize() const { return m_viewFontSize; }
+
     bool getOmitTempsFromRecentFiles() const { return m_omitRecentTemps; }
 
     QString getTemporaryDirectoryRoot() const { return m_tempDirRoot; }
@@ -79,6 +81,7 @@
     void setTemporaryDirectoryRoot(QString tempDirRoot);
     void setResampleOnLoad(bool);
     void setBackgroundMode(BackgroundMode mode);
+    void setViewFontSize(int size);
 
 private:
     Preferences(); // may throw DirectoryCreationFailed
@@ -94,6 +97,7 @@
     bool m_omitRecentTemps;
     QString m_tempDirRoot;
     bool m_resampleOnLoad;
+    int m_viewFontSize;
     BackgroundMode m_backgroundMode;
 };