comparison view/View.cpp @ 1607:52d4bfba5b3d

Reduce font size when pane is very thin
author Chris Cannam
date Wed, 06 May 2020 11:44:38 +0100
parents ae2d5f8ff005
children
comparison
equal deleted inserted replaced
1606:d6976d231efb 1607:52d4bfba5b3d
2197 scaleFactor = dpratio; 2197 scaleFactor = dpratio;
2198 } 2198 }
2199 } 2199 }
2200 2200
2201 QFont font(paint.font()); 2201 QFont font(paint.font());
2202 font.setPointSize(Preferences::getInstance()->getViewFontSize() 2202 int pointSize = Preferences::getInstance()->getViewFontSize() * scaleFactor;
2203 * scaleFactor); 2203 font.setPointSize(pointSize);
2204
2205 int h = height();
2206 int fh = QFontMetrics(font).height();
2207 if (pointSize > 6) {
2208 if (h < fh * 2.1) {
2209 font.setPointSize(pointSize - 2);
2210 } else if (h < fh * 3.1) {
2211 font.setPointSize(pointSize - 1);
2212 }
2213 }
2214
2204 paint.setFont(font); 2215 paint.setFont(font);
2205 } 2216 }
2206 2217
2207 QRect 2218 QRect
2208 View::getPaintRect() const 2219 View::getPaintRect() const