Mercurial > hg > easyhg
comparison src/common.cpp @ 678:c0b46d0514a7 scale
Incomplete scaling updates. Should do this differently
author | Chris Cannam |
---|---|
date | Thu, 06 Dec 2018 14:55:45 +0000 |
parents | f9b805d8cab4 |
children |
comparison
equal
deleted
inserted
replaced
677:0329bbd4b57c | 678:c0b46d0514a7 |
---|---|
21 #include <QFileInfo> | 21 #include <QFileInfo> |
22 #include <QProcessEnvironment> | 22 #include <QProcessEnvironment> |
23 #include <QStringList> | 23 #include <QStringList> |
24 #include <QDir> | 24 #include <QDir> |
25 #include <QRegExp> | 25 #include <QRegExp> |
26 #include <QFont> | |
27 #include <QFontMetrics> | |
26 | 28 |
27 #include <sys/types.h> | 29 #include <sys/types.h> |
28 | 30 |
29 #ifdef Q_OS_WIN32 | 31 #ifdef Q_OS_WIN32 |
30 #define _WIN32_WINNT 0x0500 | 32 #define _WIN32_WINNT 0x0500 |
350 #endif | 352 #endif |
351 | 353 |
352 return ba; | 354 return ba; |
353 } | 355 } |
354 | 356 |
357 int | |
358 scalePixelSize(int pixels) | |
359 { | |
360 static double ratio = 0.0; | |
361 if (ratio == 0.0) { | |
362 double baseEm; | |
363 #ifdef Q_OS_MAC | |
364 baseEm = 17.0; | |
365 #else | |
366 baseEm = 15.0; | |
367 #endif | |
368 double em = QFontMetrics(QFont()).height(); | |
369 ratio = em / baseEm; | |
370 } | |
371 | |
372 int scaled = int(pixels * ratio + 0.5); | |
373 if (pixels != 0 && scaled == 0) scaled = 1; | |
374 return scaled; | |
375 } | |
376 |