Skip to content

Commit 46a52ab

Browse files
author
kbay
committed
Apply QT_SCALE_FACTOR for MacOS for non retina only
1 parent 6758a4f commit 46a52ab

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

macos/changetitlebarcolor.mm

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,19 @@ void changeTitleBarColor(WId winId, double red, double green, double blue)
2727
window.appearance = [NSAppearance appearanceNamed:NSAppearanceNameVibrantDark];
2828
}
2929

30+
bool isRetinaDisplay() {
31+
32+
float displayScale = 1;
33+
if ([[NSScreen mainScreen] respondsToSelector:@selector(backingScaleFactor)]) {
34+
NSArray *screens = [NSScreen screens];
35+
NSUInteger screenCount = screens.count;
36+
for (int i = 0; i < screenCount; i++) {
37+
float s = [screens[i] backingScaleFactor];
38+
if (s > displayScale)
39+
displayScale = s;
40+
}
41+
}
42+
return displayScale>1.001;
43+
}
44+
3045
}

main.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@
5353
#include "tests/testPasswordAnalyser.h"
5454
#include "misk/DictionaryInit.h"
5555

56+
#ifdef Q_OS_DARWIN
57+
namespace Cocoa
58+
{
59+
bool isRetinaDisplay();
60+
}
61+
#endif
62+
5663
// Very first run - init everything
5764
bool deployWalletFilesFromResources() {
5865
QString confPath = ioutils::getAppDataPath();
@@ -221,7 +228,10 @@ int main(int argc, char *argv[])
221228
#else
222229
scale = 1.0; // Mac OS, not applicable, mean 1.0
223230
// But scale factor still needed to fix the non retina cases on mac OS
224-
qputenv( "QT_SCALE_FACTOR", "1.001" );
231+
232+
if (! Cocoa::isRetinaDisplay()) {
233+
qputenv("QT_SCALE_FACTOR", "1.001");
234+
}
225235
#endif
226236

227237
QApplication app(argc, argv);

0 commit comments

Comments
 (0)