Fixed the fonts size in HDPI mode.

This commit is contained in:
Shuai Lin 2017-05-09 16:39:31 +08:00
parent e74f448c67
commit a3f9b11029
3 changed files with 9 additions and 21 deletions

View file

@ -17,9 +17,3 @@ FileTableView QHeaderView::section:first {
SyncErrorsTableView::item {
padding-left: 2px;
}
AboutDialog QPushButton#mCheckUpdateBtn {
padding-left: 10px;
padding-right: 10px;
}

View file

@ -220,7 +220,7 @@ bool fixQtHDPINonIntegerScaling()
return false;
}
// Don't overwrite the user sepcified scaling factors
if (!qgetenv("QT_SCALE_FACTOR").isEmpty()) {
if (!qgetenv("QT_SCALE_FACTOR").isEmpty() || !qgetenv("QT_SCREEN_SCALE_FACTORS").isEmpty()) {
return true;
}
// Don't overwrite the user sepcified multi-screen scaling factors
@ -247,6 +247,7 @@ bool fixQtHDPINonIntegerScaling()
// Turn off system scaling, otherwise we'll always see a 96 DPI virtual screen.
if (!setProcessDPIAware()) {
return false;
}
QDpi dpi;
@ -266,7 +267,12 @@ bool fixQtHDPINonIntegerScaling()
// 192 DPI = 200% scaling
double scaling_factor = ((double)(dpi.first)) / 96.0;
QString factor = QString::number(scaling_factor);
g_setenv("QT_SCALE_FACTOR", factor.toUtf8().data(), 1);
// Use QT_SCREEN_SCALE_FACTORS instead of QT_SCALE_FACTOR. The latter would
// scale the font, which has already been scaled by the system.
//
// See also http://lists.qt-project.org/pipermail/interest/2015-October/019242.html
g_setenv("QT_SCREEN_SCALE_FACTORS", factor.toUtf8().data(), 1);
// printf("set QT_SCALE_FACTOR to %s\n", factor.toUtf8().data());
return true;
}

View file

@ -122,20 +122,8 @@
</property>
</spacer>
</item>
<item alignment="Qt::AlignHCenter">
<item>
<widget class="QPushButton" name="mCheckUpdateBtn">
<property name="sizePolicy">
<sizepolicy hsizetype="Minimum" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="minimumSize">
<size>
<width>92</width>
<height>23</height>
</size>
</property>
<property name="text">
<string>Check For Updates</string>
</property>