File tree Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Expand file tree Collapse file tree 2 files changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -55,21 +55,24 @@ qreal ScaledSizeProvider::scaleFactor()
5555qreal ScaledSizeProvider::getScaleFactor ()
5656{
5757#if defined(__linux__)
58- DesktopEnvironmentChecker desktopEnvironmentChecker;
59- auto environment = desktopEnvironmentChecker.getDesktopEnvironment ();
60-
61- if (environment == DesktopEnvironmentType::Gnome) {
58+ if (isGnomeEnvironment ()) {
6259 auto screen = QApplication::primaryScreen ();
6360 auto logicalDotsPerInch = (int ) screen->logicalDotsPerInch ();
6461 auto physicalDotsPerInch = (int ) screen->physicalDotsPerInch ();
6562 return (qreal)logicalDotsPerInch / (qreal)physicalDotsPerInch;
66- } else if (environment == DesktopEnvironmentType::Kde) {
67- auto screen = QApplication::primaryScreen ();
68- return screen->devicePixelRatio ();
6963 }
7064#endif
7165
7266 return 1 ;
7367}
7468
69+ #if defined(__linux__)
70+ bool ScaledSizeProvider::isGnomeEnvironment ()
71+ {
72+ auto currentDesktop = QString (qgetenv (" XDG_CURRENT_DESKTOP" ));
73+ return currentDesktop.contains (QLatin1String (" gnome" ), Qt::CaseInsensitive)
74+ || currentDesktop.contains (QLatin1String (" unity" ), Qt::CaseInsensitive);
75+ }
76+ #endif
77+
7578} // namespace kImageAnnotator
Original file line number Diff line number Diff line change @@ -46,6 +46,10 @@ class ScaledSizeProvider
4646 static qreal scaleFactor ();
4747 static qreal getScaleFactor ();
4848
49+ #if defined(__linux__)
50+ static bool isGnomeEnvironment ();
51+ #endif
52+
4953 ScaledSizeProvider () = default ;
5054 ~ScaledSizeProvider () = default ;
5155};
You can’t perform that action at this time.
0 commit comments