Skip to content

Conversation

@zccrs
Copy link
Member

@zccrs zccrs commented Apr 2, 2019

Qt应用支持实时设置屏幕缩放比且生效

@zccrs
Copy link
Member Author

zccrs commented Apr 2, 2019

更新缩放比后,窗口需要自行根据新的缩放比例更新自己的geometry,目前需要适配的项目:

使用方式:
由配置文件 ~/.config/deepin/qt-theme.ini 控制,与屏幕缩放相关的配置项共有三个:

  • ScreenScaleFactors:多屏幕设置不同缩放比,值格式和环境变量QT_SCREEN_SCALE_FACTORS一致
  • ScaleFactor: 强制设置缩放比,值格式和环境变量QT_SCALE_FACTOR一致
  • ScaleLogcailDpi:指定屏幕逻辑dpi,可影响仅设置了 point size 的 QFont 的绘制大小。未设置此值时,默认会在 ScreenScaleFactors 值改变后将屏幕逻辑dpi更改为主屏默认值,一般情况下,不需要设置此值。

在Deepin桌面环境中,默认对所有Qt5应用生效,可以在QCoreApplication对象创建之前设置 Qt::AA_DisableHighDpiScaling 为 true,或添加环境变量 D_DISABLE_RT_SCREEN_SCALE 关闭此功能。

@electricface

@zccrs zccrs force-pushed the RT_SCALE branch 2 times, most recently from 553d803 to 6b4c7b7 Compare April 2, 2019 07:51
zccrs added a commit to zccrs/dtkwidget that referenced this pull request Apr 2, 2019
Screen scale real-time effect implemented in the Adaptation Platform theme plugin
linuxdeepin/qt5integration#11
@zccrs
Copy link
Member Author

zccrs commented Apr 2, 2019

linuxdeepin/dtkwidget#19

return value(SCREEN_SCALE_FACTORS).toByteArray();
}

static QPair<qreal, qreal> takePair(const QVariant &value)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

加一点注释:例如使用的一种情况。


static bool enabledRTScreenScale()
{
static bool env_is_set = qEnvironmentVariableIsSet("D_DISABLE_RT_SCREEN_SCALE");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

如果应用设置了缩放相关的环境变量,则不开启自动缩放。

Change-Id: Ib1441c474af56cf8641f15a20d1069e419539ef7
zccrs added a commit to linuxdeepin/dtkwidget that referenced this pull request Apr 2, 2019
Screen scale real-time effect implemented in the Adaptation Platform theme plugin
linuxdeepin/qt5integration#11
@zccrs zccrs merged commit 1e9c855 into linuxdeepin:master Apr 2, 2019
@zccrs zccrs deleted the RT_SCALE branch April 7, 2019 09:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants