Mercurial > hg > easyhg
diff 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 |
line wrap: on
line diff
--- a/src/common.cpp Thu Dec 06 13:54:34 2018 +0000 +++ b/src/common.cpp Thu Dec 06 14:55:45 2018 +0000 @@ -23,6 +23,8 @@ #include <QStringList> #include <QDir> #include <QRegExp> +#include <QFont> +#include <QFontMetrics> #include <sys/types.h> @@ -352,3 +354,23 @@ return ba; } +int +scalePixelSize(int pixels) +{ + 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 scaled = int(pixels * ratio + 0.5); + if (pixels != 0 && scaled == 0) scaled = 1; + return scaled; +} +