File tree Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change @@ -65,24 +65,34 @@ qreal ScaledSizeProvider::scaleFactor()
65
65
qreal ScaledSizeProvider::getScaleFactor ()
66
66
{
67
67
#if defined(__linux__)
68
- if (isGnomeEnvironment ()) {
68
+ char env = getLinuxDesktopEnvironment ();
69
+ if (env == ' g' ) {
69
70
auto screen = QApplication::primaryScreen ();
70
71
auto logicalDotsPerInch = (int ) screen->logicalDotsPerInch ();
71
72
auto physicalDotsPerInch = (int ) screen->physicalDotsPerInch ();
72
73
return (qreal)logicalDotsPerInch / (qreal)physicalDotsPerInch;
74
+ } else if (env == ' k' ) {
75
+ auto screen = QApplication::primaryScreen ();
76
+ return screen->devicePixelRatio ();
73
77
}
74
78
#endif
75
79
76
80
return 1 ;
77
81
}
78
82
79
83
#if defined(__linux__)
80
- bool ScaledSizeProvider::isGnomeEnvironment ()
84
+ char ScaledSizeProvider::getLinuxDesktopEnvironment ()
81
85
{
82
86
auto currentDesktop = QString (qgetenv (" XDG_CURRENT_DESKTOP" ));
83
- return currentDesktop.contains (QLatin1String (" gnome" ), Qt::CaseInsensitive)
84
- || currentDesktop.contains (QLatin1String (" unity" ), Qt::CaseInsensitive);
87
+ if (currentDesktop.contains (QLatin1String (" gnome" ), Qt::CaseInsensitive)
88
+ || currentDesktop.contains (QLatin1String (" unity" ), Qt::CaseInsensitive)) {
89
+ return ' g' ;
90
+ } else if (currentDesktop.contains (QLatin1String (" kde" ), Qt::CaseInsensitive)) {
91
+ return ' k' ;
92
+ } else {
93
+ return ' ' ;
94
+ }
85
95
}
86
96
#endif
87
97
88
- } // namespace kImageAnnotator
98
+ } // namespace kImageAnnotator
Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ class ScaledSizeProvider
47
47
static qreal getScaleFactor ();
48
48
49
49
#if defined(__linux__)
50
- static bool isGnomeEnvironment ();
50
+ static char getLinuxDesktopEnvironment ();
51
51
#endif
52
52
53
53
ScaledSizeProvider () = default ;
You can’t perform that action at this time.
0 commit comments