summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2018-01-16 06:45:10 +0100
committerStanislaw Halik <sthalik@misaki.pl>2018-01-16 06:45:53 +0100
commit801218074edef04f311f7fae5734bf2dc454f0bb (patch)
treef57db9a48076dc525bb4a7d4b71c337b09c1613c
parent43665c5f8c0219836cd94ea11bc14fd64e869e93 (diff)
spline: fix widget for hidpi displays
-rw-r--r--spline/spline-widget.cpp20
1 files changed, 8 insertions, 12 deletions
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();
}