From 801218074edef04f311f7fae5734bf2dc454f0bb Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Tue, 16 Jan 2018 06:45:10 +0100 Subject: spline: fix widget for hidpi displays --- spline/spline-widget.cpp | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'spline/spline-widget.cpp') diff --git a/spline/spline-widget.cpp b/spline/spline-widget.cpp index 960ba3aa..c2c2ed07 100644 --- a/spline/spline-widget.cpp +++ b/spline/spline-widget.cpp @@ -88,8 +88,6 @@ bool spline_widget::is_preview_only() const void spline_widget::drawBackground() { - _background = QPixmap(width(), height()); - QPainter painter(&_background); painter.fillRect(rect(), widget_bg_color); @@ -151,7 +149,6 @@ void spline_widget::drawBackground() void spline_widget::drawFunction() { - _function = _background; QPainter painter(&_function); painter.setRenderHint(QPainter::Antialiasing, true); @@ -272,16 +269,14 @@ void spline_widget::paintEvent(QPaintEvent *e) QPainter p(this); - if (!_background.isNull()) - { - if (_background.size() != size()) - { - _background = QPixmap(); - _function = QPixmap(); - } - } - else + const double dpr = devicePixelRatioF(); + const int W = int(width() * dpr + .75); + const int H = int(height() * dpr + .75); + + if (_background.size() != QSize(W, H)) { + _background = QPixmap(W, H); + _background.setDevicePixelRatio(dpr); _draw_function = true; drawBackground(); } @@ -289,6 +284,7 @@ void spline_widget::paintEvent(QPaintEvent *e) if (_draw_function) { _draw_function = false; + _function = _background; drawFunction(); } -- cgit v1.2.3