Conversation
Co-authored-by: Joshua Goins <joshua.goins@kdab.com>
This comment was marked as outdated.
This comment was marked as outdated.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1430 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 75 75
Lines 13457 13455 -2
=========================================
- Hits 13457 13455 -2 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This comment was marked as outdated.
This comment was marked as outdated.
|
I have "working" implementation here https://github.com/dphaldes/compose/blob/master/src/bridge.rs. Not particularly fond of the solution since it uses an unchecked cast since I wasn't able to figure out how to cast Any ideas appreciated! |
|
How are you making your And generally things here are looking like they are heading in the right direction :-) https://docs.rs/cxx/latest/cxx/struct.UniquePtr.html#method.as_mut_ptr |
|
I didn't see that method. I will look into using that. It would work but it still wouldnt work as a safe cast will it? as in using the Upcast trait instead of |
|
Hmm right we don't have any safe API for casting pointers, there is I think for now just use an |
|
That works pretty well on the implementation side. https://github.com/dphaldes/compose/blob/38019867036cce5d156e786884567c565fdd7903/src/main.rs#L46-L51 Had to use |
| #[rust_name = "add_image_provider"] | ||
| unsafe fn addImageProvider( | ||
| self: Pin<&mut QQmlApplicationEngine>, | ||
| provider_id: &QString, | ||
| provider: *mut QQmlImageProviderBase, | ||
| ); | ||
|
|
||
| #[rust_name = "remove_image_provider"] | ||
| fn removeImageProvider(self: Pin<&mut QQmlApplicationEngine>, provider_id: &QString); |
There was a problem hiding this comment.
these should be on the QQmlEngine rather than the QQmlApplicationEngine (which inherits from the QQmlEngine)
| Pixmap, | ||
| Texture, | ||
| ImageResponse, | ||
| } |
There was a problem hiding this comment.
In Qt 5 these enums are slightly different either have a cfg like #[cfg(cxxqt_qt_version_major = "6")] and #[cfg(cxxqt_qt_version_major = "5")] to have different enums or disable all of this for Qt 5.
In Qt 5
- Image = 0
- Pixmap = 1
- Texture = 2
- ImageResponse = 4
https://doc.qt.io/archives/qt-5.15/qqmlimageproviderbase.html#ImageType-enum
In Qt 6
- Image = 1
- Pixmap = 2
- Texture = 3
- ImageResponse = 4
https://doc.qt.io/qt-6/qqmlimageproviderbase.html#ImageType-enum
Note in Qt 5 there is a gap of no 3 :-) And do we need the Invalid = 0 ? As that is not defined on the Qt side ?
| #[qobject] | ||
| type QQmlImageProviderBase; |
There was a problem hiding this comment.
In Qt 5, this is just a normal class and does no inherit from QObject, so again might need a cfg block to have two different types if we want to make it work with Qt 5
|
|
||
| #[cxx_qt::bridge] | ||
| mod ffi { | ||
|
|
There was a problem hiding this comment.
remove empty line :-)
|
Looking overall good, just need to either decide to fix the Qt 5 support or opt-out for these methods/types |

supercedes #1142