diff --git a/crates/cxx-qt-lib/src/core/qline.rs b/crates/cxx-qt-lib/src/core/qline.rs index 4696cc096..88ff38e78 100644 --- a/crates/cxx-qt-lib/src/core/qline.rs +++ b/crates/cxx-qt-lib/src/core/qline.rs @@ -5,6 +5,7 @@ use crate::QPoint; use cxx::{type_id, ExternType}; +use std::fmt; #[cxx::bridge] mod ffi { @@ -13,6 +14,8 @@ mod ffi { type QLine = super::QLine; include!("cxx-qt-lib/qpoint.h"); type QPoint = crate::QPoint; + include!("cxx-qt-lib/qstring.h"); + type QString = crate::QString; /// Returns the line's start point. fn p1(self: &QLine) -> QPoint; @@ -79,6 +82,10 @@ mod ffi { #[doc(hidden)] #[rust_name = "qline_new"] fn construct(pt1: QPoint, pt2: QPoint) -> QLine; + + #[doc(hidden)] + #[rust_name = "qline_to_qstring"] + fn toQString(value: &QLine) -> QString; } } @@ -104,6 +111,12 @@ impl Default for QLine { } } +impl fmt::Display for QLine { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", ffi::qline_to_qstring(self)) + } +} + // Safety: // // Static checks on the C++ side ensure that QLine is trivial. diff --git a/crates/cxx-qt-lib/src/core/qlinef.rs b/crates/cxx-qt-lib/src/core/qlinef.rs index 80fbae9bb..9bad40878 100644 --- a/crates/cxx-qt-lib/src/core/qlinef.rs +++ b/crates/cxx-qt-lib/src/core/qlinef.rs @@ -6,6 +6,7 @@ use crate::QLine; use crate::QPointF; use cxx::{type_id, ExternType}; +use std::fmt; #[cxx::bridge] mod ffi { @@ -16,6 +17,8 @@ mod ffi { type QLine = crate::QLine; include!("cxx-qt-lib/qpointf.h"); type QPointF = crate::QPointF; + include!("cxx-qt-lib/qstring.h"); + type QString = crate::QString; /// Returns the angle of the line in degrees. fn angle(self: &QLineF) -> f64; @@ -121,6 +124,10 @@ mod ffi { #[doc(hidden)] #[rust_name = "qlinef_from_qline"] fn construct(line: &QLine) -> QLineF; + + #[doc(hidden)] + #[rust_name = "qlinef_to_qstring"] + fn toQString(value: &QLineF) -> QString; } } @@ -161,6 +168,12 @@ impl From for ffi::QLine { } } +impl fmt::Display for QLineF { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", ffi::qlinef_to_qstring(self)) + } +} + // Safety: // // Static checks on the C++ side ensure that QLineF is trivial. diff --git a/crates/cxx-qt-lib/src/gui/qpen.rs b/crates/cxx-qt-lib/src/gui/qpen.rs index 1ddc6fc8d..131707d8e 100644 --- a/crates/cxx-qt-lib/src/gui/qpen.rs +++ b/crates/cxx-qt-lib/src/gui/qpen.rs @@ -3,6 +3,7 @@ // // SPDX-License-Identifier: MIT OR Apache-2.0 use cxx::{type_id, ExternType}; +use std::fmt; use std::mem::MaybeUninit; #[cxx::bridge] @@ -20,6 +21,8 @@ mod ffi { type QPen = super::QPen; include!("cxx-qt-lib/qcolor.h"); type QColor = crate::QColor; + include!("cxx-qt-lib/qstring.h"); + type QString = crate::QString; /// Returns the pen's cap style. #[rust_name = "cap_style"] @@ -117,6 +120,10 @@ mod ffi { #[doc(hidden)] #[rust_name = "qpen_eq"] fn operatorEq(a: &QPen, b: &QPen) -> bool; + + #[doc(hidden)] + #[rust_name = "qpen_to_qstring"] + fn toQString(value: &QPen) -> QString; } } @@ -167,6 +174,12 @@ impl From<&ffi::PenStyle> for QPen { } } +impl fmt::Display for QPen { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", ffi::qpen_to_qstring(self)) + } +} + // Safety: // // Static checks on the C++ side to ensure the size is the same.