changeset 1176:125748a569fa more-hidpi

Another use of WidgetScale
author Chris Cannam
date Mon, 05 Dec 2016 14:51:25 +0000
parents a7df0d728020
children 916b62baf7ac
files widgets/LevelPanWidget.cpp
diffstat 1 files changed, 3 insertions(+), 16 deletions(-) [+]
line wrap: on
line diff
--- a/widgets/LevelPanWidget.cpp	Mon Dec 05 14:31:53 2016 +0000
+++ b/widgets/LevelPanWidget.cpp	Mon Dec 05 14:51:25 2016 +0000
@@ -21,6 +21,8 @@
 #include "layer/ColourMapper.h"
 #include "base/AudioLevel.h"
 
+#include "WidgetScale.h"
+
 #include <iostream>
 #include <cmath>
 #include <cassert>
@@ -47,22 +49,7 @@
 QSize
 LevelPanWidget::sizeHint() const
 {
-    static double ratio = 0.0;
-    if (ratio == 0.0) {
-        double baseEm;
-#ifdef Q_OS_MAC
-        baseEm = 17.0;
-#else
-        baseEm = 15.0;
-#endif
-        double em = QFontMetrics(QFont()).height();
-        ratio = em / baseEm;
-    }
-
-    int pixels = 40;
-    int scaled = int(pixels * ratio + 0.5);
-    if (pixels != 0 && scaled == 0) scaled = 1;
-    return QSize(scaled, scaled);
+    return WidgetScale::scaleQSize(QSize(40, 40));
 }
 
 static int