mirror of
https://github.com/slint-ui/slint.git
synced 2025-12-23 09:19:32 +00:00
Native style: Fix animations with the KDE's breeze style
The style use update() on an invisible widget so animations wouldn't work. As a workaround, capture the MetaCall event
This commit is contained in:
parent
5718b15899
commit
bcbe157712
1 changed files with 6 additions and 5 deletions
|
|
@ -192,12 +192,13 @@ cpp! {{
|
|||
struct SlintAnimatedWidget: public Base, public SlintTypeErasedWidget {
|
||||
void *animation_update_property_ptr;
|
||||
bool event(QEvent *event) override {
|
||||
if (event->type() == QEvent::StyleAnimationUpdate) {
|
||||
// QEvent::StyleAnimationUpdate is sent by QStyleAnimation used by Qt builtin styles
|
||||
// The Breeze style use QMetaObject::invokeMethod("update") on the widget to update the widget, so catch QEvent::MetaCall
|
||||
// (because the call to QWidget::update does nothing as the widget is not visible)
|
||||
if (event->type() == QEvent::StyleAnimationUpdate || event->type() == QEvent::MetaCall) {
|
||||
rust!(Slint_AnimatedWidget_update [animation_update_property_ptr: Pin<&Property<i32>> as "void*"] {
|
||||
animation_update_property_ptr.set(animation_update_property_ptr.get() + 1);
|
||||
});
|
||||
event->accept();
|
||||
return true;
|
||||
}
|
||||
return Base::event(event);
|
||||
}
|
||||
|
|
@ -209,9 +210,9 @@ cpp! {{
|
|||
std::unique_ptr<SlintTypeErasedWidget> make_unique_animated_widget(void *animation_update_property_ptr)
|
||||
{
|
||||
ensure_initialized();
|
||||
auto ptr = new SlintAnimatedWidget<Base>();
|
||||
auto ptr = std::make_unique<SlintAnimatedWidget<Base>>();
|
||||
ptr->animation_update_property_ptr = animation_update_property_ptr;
|
||||
return std::unique_ptr<SlintTypeErasedWidget>(ptr);
|
||||
return ptr;
|
||||
}
|
||||
}}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue