summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--spline/spline-widget.cpp15
-rw-r--r--spline/spline-widget.hpp6
2 files changed, 20 insertions, 1 deletions
diff --git a/spline/spline-widget.cpp b/spline/spline-widget.cpp
index d329d8e2..363720c8 100644
--- a/spline/spline-widget.cpp
+++ b/spline/spline-widget.cpp
@@ -260,6 +260,21 @@ void spline_widget::drawFunction()
}
}
+double spline_widget::screen_dpi() const
+{
+#ifdef _WIN32
+ return std::max(devicePixelRatioF, 1.);
+#else
+ return std::max(std::max(logicalDpiX()/(double)physicalDpiX(), devicePixelRatioF()), 1.);
+#endif
+}
+
+QSize spline_widget::minimumSizeHint() const
+{
+ const double dpi = screen_dpi();
+ return { iround(800 * dpi), iround(250 * dpi) };
+}
+
void spline_widget::paintEvent(QPaintEvent *e)
{
if (!config)
diff --git a/spline/spline-widget.hpp b/spline/spline-widget.hpp
index 178e5b23..ab0060f2 100644
--- a/spline/spline-widget.hpp
+++ b/spline/spline-widget.hpp
@@ -54,6 +54,8 @@ public:
void set_snap(double x, double y) { snap_x = x; snap_y = y; }
void get_snap(double& x, double& y) const { x = snap_x; y = snap_y; }
+
+ QSize minimumSizeHint() const override;
public slots:
void reload_spline();
protected slots:
@@ -79,6 +81,8 @@ private:
void update_range();
void changeEvent(QEvent* e) override;
+ double screen_dpi() const;
+
QPointF pixel_to_point(const QPointF& point);
QPointF point_to_pixel(const QPointF& point);
@@ -105,7 +109,7 @@ private:
// point's circle radius on the widget
static constexpr int point_size_in_pixels_ = 4;
- const double point_size_in_pixels = point_size_in_pixels_ * std::fmax(1, devicePixelRatioF() * .66);
+ const double point_size_in_pixels = point_size_in_pixels_ * screen_dpi();
};
} // ns spline_detail