Fix HiDPI

pull/9/head
reionwong 5 years ago
parent e4225dc97b
commit 021decb433

@ -138,14 +138,7 @@ void Application::initEnvironments()
qputenv("QT_QPA_PLATFORMTHEME", "cutefish"); qputenv("QT_QPA_PLATFORMTHEME", "cutefish");
qputenv("QT_PLATFORM_PLUGIN", "cutefish"); qputenv("QT_PLATFORM_PLUGIN", "cutefish");
qunsetenv("QT_SCALE_FACTOR"); qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "0");
qunsetenv("QT_SCREEN_SCALE_FACTORS");
qunsetenv("QT_ENABLE_HIGHDPI_SCALING");
qunsetenv("QT_USE_PHYSICAL_DPI");
qunsetenv("QT_FONT_DPI");
qputenv("QT_SCALE_FACTOR_ROUNDING_POLICY", "PassThrough");
qputenv("QT_AUTO_SCREEN_SCALE_FACTOR", "1");
// IM Config // IM Config
qputenv("GTK_IM_MODULE", "fcitx5"); qputenv("GTK_IM_MODULE", "fcitx5");

@ -158,41 +158,18 @@ qreal ThemeManager::devicePixelRatio()
void ThemeManager::setDevicePixelRatio(qreal ratio) void ThemeManager::setDevicePixelRatio(qreal ratio)
{ {
m_settings->setValue(s_devicePixelRatio, ratio); int scaleDpi = qRound(ratio * 96.0);
QProcess process;
// Set font dpi process.start(QStringLiteral("xrdb"), {QStringLiteral("-quiet"), QStringLiteral("-merge"), QStringLiteral("-nocpp")});
// ref kscreen.
if (qFuzzyCompare(ratio, 1.0)) { if (process.waitForStarted()) {
const int scaleDpi = qRound(ratio * 96.0); process.write(QByteArray("Xft.dpi: " + QString::number(scaleDpi).toLatin1()));
QProcess proc; process.closeWriteChannel();
proc.start(QStringLiteral("xrdb"), {QStringLiteral("-quiet"), QStringLiteral("-merge"), QStringLiteral("-nocpp")}); process.waitForFinished();
if (proc.waitForStarted()) {
proc.write(QByteArray("Xft.dpi: " + QString::number(scaleDpi).toLatin1()));
proc.closeWriteChannel();
proc.waitForFinished();
}
// if dpi is the default (96) remove the entry rather than setting it
// QProcess proc;
// proc.start(QStringLiteral("xrdb"), {QStringLiteral("-quiet"), QStringLiteral("-remove"), QStringLiteral("-nocpp")});
// if (proc.waitForStarted()) {
// proc.write(QByteArray("Xft.dpi\n"));
// proc.closeWriteChannel();
// proc.waitForFinished();
// }
m_settings->setValue("forceFontDPI", 96);
} else {
const int scaleDpi = qRound(ratio * 96.0);
QProcess proc;
proc.start(QStringLiteral("xrdb"), {QStringLiteral("-quiet"), QStringLiteral("-merge"), QStringLiteral("-nocpp")});
if (proc.waitForStarted()) {
proc.write(QByteArray("Xft.dpi: " + QString::number(scaleDpi).toLatin1()));
proc.closeWriteChannel();
proc.waitForFinished();
}
m_settings->setValue("forceFontDPI", scaleDpi);
} }
m_settings->setValue(s_devicePixelRatio, ratio);
m_settings->setValue("forceFontDPI", scaleDpi);
} }
QString ThemeManager::wallpaper() QString ThemeManager::wallpaper()

Loading…
Cancel
Save