Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert Custom Scaling Handling for KDE / QT #339

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 10 additions & 7 deletions src/common/provider/ScaledSizeProvider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,21 +55,24 @@ qreal ScaledSizeProvider::scaleFactor()
qreal ScaledSizeProvider::getScaleFactor()
{
#if defined(__linux__)
DesktopEnvironmentChecker desktopEnvironmentChecker;
auto environment = desktopEnvironmentChecker.getDesktopEnvironment();

if (environment == DesktopEnvironmentType::Gnome) {
if(isGnomeEnvironment()) {
auto screen = QApplication::primaryScreen();
auto logicalDotsPerInch = (int) screen->logicalDotsPerInch();
auto physicalDotsPerInch = (int) screen->physicalDotsPerInch();
return (qreal)logicalDotsPerInch / (qreal)physicalDotsPerInch;
} else if (environment == DesktopEnvironmentType::Kde) {
auto screen = QApplication::primaryScreen();
return screen->devicePixelRatio();
}
#endif

return 1;
}

#if defined(__linux__)
bool ScaledSizeProvider::isGnomeEnvironment()
{
auto currentDesktop = QString(qgetenv("XDG_CURRENT_DESKTOP"));
return currentDesktop.contains(QLatin1String("gnome"), Qt::CaseInsensitive)
|| currentDesktop.contains(QLatin1String("unity"), Qt::CaseInsensitive);
}
#endif

} // namespace kImageAnnotator
4 changes: 4 additions & 0 deletions src/common/provider/ScaledSizeProvider.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ class ScaledSizeProvider
static qreal scaleFactor();
static qreal getScaleFactor();

#if defined(__linux__)
static bool isGnomeEnvironment();
#endif

ScaledSizeProvider() = default;
~ScaledSizeProvider() = default;
};
Expand Down