Skip to content

Commit

Permalink
Add Display for QPolygon/QPolygonF
Browse files Browse the repository at this point in the history
  • Loading branch information
Montel authored and ahayzen-kdab committed Mar 15, 2024
1 parent dfb5675 commit ad31c4e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
12 changes: 12 additions & 0 deletions crates/cxx-qt-lib/src/gui/qpolygon.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ mod ffi {
type QPoint = crate::QPoint;
include!("cxx-qt-lib/qrect.h");
type QRect = crate::QRect;
include!("cxx-qt-lib/qstring.h");
type QString = crate::QString;

include!("cxx-qt-lib/qpolygon.h");
type QPolygon = super::QPolygon;
Expand Down Expand Up @@ -81,6 +83,10 @@ mod ffi {
#[doc(hidden)]
#[rust_name = "qpolygon_eq"]
fn operatorEq(a: &QPolygon, b: &QPolygon) -> bool;

#[doc(hidden)]
#[rust_name = "qpolygon_to_qstring"]
fn toQString(value: &QPolygon) -> QString;
}
}

Expand Down Expand Up @@ -131,6 +137,12 @@ impl PartialEq for QPolygon {
}
}

impl std::fmt::Display for QPolygon {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}", ffi::qpolygon_to_qstring(self))
}
}

impl Eq for QPolygon {}

// Safety:
Expand Down
12 changes: 12 additions & 0 deletions crates/cxx-qt-lib/src/gui/qpolygonf.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ mod ffi {
type QRectF = crate::QRectF;
include!("cxx-qt-lib/qpolygon.h");
type QPolygon = crate::QPolygon;
include!("cxx-qt-lib/qstring.h");
type QString = crate::QString;

include!("cxx-qt-lib/qpolygonf.h");
type QPolygonF = super::QPolygonF;
Expand Down Expand Up @@ -79,6 +81,10 @@ mod ffi {
#[doc(hidden)]
#[rust_name = "qpolygonf_eq"]
fn operatorEq(a: &QPolygonF, b: &QPolygonF) -> bool;

#[doc(hidden)]
#[rust_name = "qpolygonf_to_qstring"]
fn toQString(value: &QPolygonF) -> QString;
}
}

Expand Down Expand Up @@ -120,6 +126,12 @@ impl PartialEq for QPolygonF {
}
}

impl std::fmt::Display for QPolygonF {
fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
write!(f, "{}", ffi::qpolygonf_to_qstring(self))
}
}

impl Eq for QPolygonF {}

// Safety:
Expand Down

0 comments on commit ad31c4e

Please sign in to comment.