mirror of
https://github.com/Swordfish90/cool-retro-term.git
synced 2025-11-24 22:45:52 +00:00
Fix rendering on non HiDPI screens
This commit is contained in:
parent
dac2b4ff16
commit
08b217ab5f
@ -97,8 +97,6 @@ int main(int argc, char *argv[])
|
|||||||
engine.rootContext()->setContextProperty("fileIO", &fileIO);
|
engine.rootContext()->setContextProperty("fileIO", &fileIO);
|
||||||
engine.rootContext()->setContextProperty("monospaceSystemFonts", monospaceFontManager.retrieveMonospaceFonts());
|
engine.rootContext()->setContextProperty("monospaceSystemFonts", monospaceFontManager.retrieveMonospaceFonts());
|
||||||
|
|
||||||
engine.rootContext()->setContextProperty("devicePixelRatio", app.devicePixelRatio());
|
|
||||||
|
|
||||||
// Manage import paths for Linux and OSX.
|
// Manage import paths for Linux and OSX.
|
||||||
QStringList importPathList = engine.importPathList();
|
QStringList importPathList = engine.importPathList();
|
||||||
importPathList.prepend(QCoreApplication::applicationDirPath() + "/qmltermwidget");
|
importPathList.prepend(QCoreApplication::applicationDirPath() + "/qmltermwidget");
|
||||||
|
|||||||
@ -42,6 +42,7 @@ QtObject{
|
|||||||
property int y: 100
|
property int y: 100
|
||||||
property int width: 1024
|
property int width: 1024
|
||||||
property int height: 768
|
property int height: 768
|
||||||
|
property real pixelRatio: 1.0
|
||||||
|
|
||||||
property bool fullscreen: false
|
property bool fullscreen: false
|
||||||
property bool showMenubar: Qt.platform.os === "osx" ? true : false
|
property bool showMenubar: Qt.platform.os === "osx" ? true : false
|
||||||
|
|||||||
@ -28,7 +28,7 @@ QtObject{
|
|||||||
property bool lowResolutionFont: _font.lowResolutionFont
|
property bool lowResolutionFont: _font.lowResolutionFont
|
||||||
|
|
||||||
property int pixelSize: lowResolutionFont
|
property int pixelSize: lowResolutionFont
|
||||||
? _font.pixelSize
|
? _font.pixelSize * 2.0 / appSettings.pixelRatio
|
||||||
: _font.pixelSize * scaling
|
: _font.pixelSize * scaling
|
||||||
|
|
||||||
property int lineSpacing: lowResolutionFont
|
property int lineSpacing: lowResolutionFont
|
||||||
@ -36,7 +36,7 @@ QtObject{
|
|||||||
: pixelSize * _font.lineSpacing
|
: pixelSize * _font.lineSpacing
|
||||||
|
|
||||||
property real screenScaling: lowResolutionFont
|
property real screenScaling: lowResolutionFont
|
||||||
? _font.baseScaling * scaling
|
? _font.baseScaling * scaling / 2.0 / appSettings.pixelRatio
|
||||||
: 1.0
|
: 1.0
|
||||||
|
|
||||||
property real defaultFontWidth: fontlist.get(selectedFontIndex).fontWidth
|
property real defaultFontWidth: fontlist.get(selectedFontIndex).fontWidth
|
||||||
|
|||||||
@ -71,7 +71,7 @@ Item{
|
|||||||
QMLTermWidget {
|
QMLTermWidget {
|
||||||
id: kterminal
|
id: kterminal
|
||||||
|
|
||||||
property int textureResolutionScale: appSettings.lowResolutionFont ? devicePixelRatio : 1
|
property int textureResolutionScale: appSettings.lowResolutionFont ? appSettings.pixelRatio : 1
|
||||||
property int margin: appSettings.margin / screenScaling
|
property int margin: appSettings.margin / screenScaling
|
||||||
property int totalWidth: Math.floor(parent.width / (screenScaling * fontWidth))
|
property int totalWidth: Math.floor(parent.width / (screenScaling * fontWidth))
|
||||||
property int totalHeight: Math.floor(parent.height / screenScaling)
|
property int totalHeight: Math.floor(parent.height / screenScaling)
|
||||||
@ -81,8 +81,8 @@ Item{
|
|||||||
|
|
||||||
textureSize: Qt.size(width / textureResolutionScale, height / textureResolutionScale)
|
textureSize: Qt.size(width / textureResolutionScale, height / textureResolutionScale)
|
||||||
|
|
||||||
width: ensureMultiple(rawWidth, devicePixelRatio)
|
width: ensureMultiple(rawWidth, appSettings.pixelRatio)
|
||||||
height: ensureMultiple(rawHeight, devicePixelRatio)
|
height: ensureMultiple(rawHeight, appSettings.pixelRatio)
|
||||||
|
|
||||||
/** Ensure size is a multiple of factor. This is needed for pixel perfect scaling on highdpi screens. */
|
/** Ensure size is a multiple of factor. This is needed for pixel perfect scaling on highdpi screens. */
|
||||||
function ensureMultiple(size, factor) {
|
function ensureMultiple(size, factor) {
|
||||||
|
|||||||
@ -30,8 +30,14 @@ ApplicationWindow{
|
|||||||
height: 768
|
height: 768
|
||||||
|
|
||||||
// Save window properties automatically
|
// Save window properties automatically
|
||||||
onXChanged: appSettings.x = x
|
onXChanged: {
|
||||||
onYChanged: appSettings.y = y
|
appSettings.x = x
|
||||||
|
appSettings.pixelRatio = Window.devicePixelRatio
|
||||||
|
}
|
||||||
|
onYChanged: {
|
||||||
|
appSettings.y = y
|
||||||
|
appSettings.pixelRatio = Window.devicePixelRatio
|
||||||
|
}
|
||||||
onWidthChanged: appSettings.width = width
|
onWidthChanged: appSettings.width = width
|
||||||
onHeightChanged: appSettings.height = height
|
onHeightChanged: appSettings.height = height
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user