Fix printing source code

After qtbase/4a240bb67e72b34c80af448e0a74846609fa6975,
the scaling of the margins changed.

Fixes: QTBUG-81121
Change-Id: I6987fe8e25da1771dd2bcd36fff8558fefd3dee0
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
This commit is contained in:
Friedemann Kleint
2020-04-22 12:46:56 +02:00
parent d02f5664e5
commit 6cfe092301

View File

@@ -107,6 +107,7 @@
#include <QPropertyAnimation>
#include <QDrag>
#include <QSequentialAnimationGroup>
#include <QScreen>
#include <QScrollBar>
#include <QShortcut>
#include <QStyle>
@@ -1199,7 +1200,11 @@ void TextEditorWidgetPrivate::print(QPrinter *printer)
QAbstractTextDocumentLayout *layout = doc->documentLayout();
layout->setPaintDevice(p.device());
#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
int dpiy = p.device()->logicalDpiY();
#else
int dpiy = qRound(QGuiApplication::primaryScreen()->logicalDotsPerInchY());
#endif
int margin = int((2/2.54)*dpiy); // 2 cm margins
QTextFrameFormat fmt = doc->rootFrame()->frameFormat();