-
Notifications
You must be signed in to change notification settings - Fork 82
Support QFlags #1231
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support QFlags #1231
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1231 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 73 73
Lines 12612 12612
=========================================
Hits 12612 12612 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @jnbooth thank you for opening the PR on this.
I left some small comments, the approach itself is solid!
Co-authored-by: Leon Matthes <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent work, thank you for the contribution @jnbooth
This PR defines a
QFlags<T: QFlag>
type to address the non-codegen parts of #1123. It mimics the API of Qt's ownQFlags
, including operators. The one exception is that because Rust doesn't have the~
operator, the~
operator in Qt is mapped to!
in Rust, while the!
operator in Qt is mapped toQFlags::is_empty
in Rust.The backing
QFlag
trait provides two things: a function for converting from the FFI enum type to its underlying representation (i.e.value.repr
) and theTypeId
of the correspondingQFlags
type. For example:It's unsafe because it has the same safety contract as
cxx::ExternType::Id
. There's also an internal utility macro to replace the above impl block withSince
QFlags
can now be defined, this PR also addsQGuiApplication::keyboard_modifiers
,QGuiApplication::mouse_buttons
, andQGuiApplication::query_keyboard_modifiers
,Closes #1123