OSDN Git Service

Don't cut off zoomed font sizes to the nearest integer point size
authorThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>
Fri, 15 Oct 2010 15:19:36 +0000 (17:19 +0200)
committerThorbjørn Lindeijer <thorbjorn.lindeijer@nokia.com>
Fri, 15 Oct 2010 15:44:15 +0000 (17:44 +0200)
This caused it to go to 0 when for example displaying size 9 at 10%,
which is an invalid value so it caused the text to revert back to the
default size.

It also caused zooming to sometimes appearing to have no effect. For
example zooming size 9 to 110% would still yield size 9 rather than 9.9.

Task-number: QTCREATORBUG-2744
Task-number: QTCREATORBUG-2745
Reviewed-by: Robert Loehning
Reviewed-by: hjk
src/plugins/debugger/debuggerplugin.cpp
src/plugins/texteditor/basetexteditor.cpp
src/plugins/texteditor/fontsettings.cpp

index 72f6ab9..7a605bc 100644 (file)
@@ -2096,17 +2096,17 @@ void DebuggerPluginPrivate::connectEngine(DebuggerEngine *engine, bool notify)
         notifyCurrentEngine(RequestActivationRole, true);
 }
 
-static void changeFontSize(QWidget *widget, int size)
+static void changeFontSize(QWidget *widget, qreal size)
 {
     QFont font = widget->font();
-    font.setPointSize(size);
+    font.setPointSizeF(size);
     widget->setFont(font);
 }
 
 void DebuggerPluginPrivate::fontSettingsChanged
     (const TextEditor::FontSettings &settings)
 {
-    int size = settings.fontZoom() * settings.fontSize() / 100;
+    qreal size = settings.fontZoom() * settings.fontSize() / 100.;
     changeFontSize(m_breakWindow, size);
     changeFontSize(m_logWindow, size);
     changeFontSize(m_localsWindow, size);
index bd9e672..eaa3633 100644 (file)
@@ -4722,7 +4722,7 @@ void BaseTextEditor::changeEvent(QEvent *e)
         || e->type() == QEvent::FontChange) {
         if (d->m_extraArea) {
             QFont f = d->m_extraArea->font();
-            f.setPointSize(font().pointSize());
+            f.setPointSizeF(font().pointSizeF());
             d->m_extraArea->setFont(f);
             slotUpdateExtraAreaWidth();
             d->m_extraArea->update();
index 540f2d5..6d8b994 100644 (file)
@@ -172,7 +172,7 @@ QTextCharFormat FontSettings::toTextCharFormat(const QString &category) const
 
     if (category == textCategory) {
         tf.setFontFamily(m_family);
-        tf.setFontPointSize(m_fontSize * m_fontZoom / 100);
+        tf.setFontPointSize(m_fontSize * m_fontZoom / 100.);
         tf.setFontStyleStrategy(m_antialias ? QFont::PreferAntialias : QFont::NoAntialias);
     }