diff --git a/src/core/types.hpp b/src/core/types.hpp index 11474f3d..e2b43e59 100644 --- a/src/core/types.hpp +++ b/src/core/types.hpp @@ -13,11 +13,21 @@ class Box { Q_PROPERTY(qint32 h MEMBER h); Q_PROPERTY(qint32 width MEMBER w); Q_PROPERTY(qint32 height MEMBER h); + QML_CONSTRUCTIBLE_VALUE; QML_VALUE_TYPE(box); public: explicit Box() = default; Box(qint32 x, qint32 y, qint32 w, qint32 h): x(x), y(y), w(w), h(h) {} + + Q_INVOKABLE Box(const QRect& rect): x(rect.x()), y(rect.y()), w(rect.width()), h(rect.height()) {} + + Q_INVOKABLE Box(const QRectF& rect) + : x(static_cast(rect.x())) + , y(static_cast(rect.y())) + , w(static_cast(rect.width())) + , h(static_cast(rect.height())) {} + bool operator==(const Box& other) const; qint32 x = 0;