Repository: slint-ui/slint (language: rust)

Issue:
LineEdit cannot edit (when in a popup and we have transferred focus to it)
### Bug Description

I'm trying to make a listview edition more appealing. (having the LineEdit in the ListView is quite ugly in a window that contains mostly text).
So when I double click, I use a popup to overlay on the text (by the way I have trouble resizing it too), and I want to give it the focus immediately.
But when I do that, the LineEdit is not editable anymore.

Note : the bug does not happen with the winit backend, only with qt.
Note : I reused another bug report code to demonstrate this. Where I need it, it's not a table at all, it's really a bunch of components that are layed out like text (but hoverable and clickable).

### Reproducible Code (if applicable)

```slint
export component LineEditBlocked inherits Window {
    property <[GameHeader]> headers: [
        {name: "White", value: "toto"},
        {name: "Black", value: "titi"}
    ];

    VerticalBox {
        ListView {
            for header in headers : HorizontalLayout {
                width: 300px;
                spacing: 5px;
                Rectangle {
                    HorizontalLayout {
                        Text {
                            text: header.name;
                            width: 100px;
                        }
                        te := Text {
                            text: header.value;
                            width: 100px;
                        }
                    }
                    popup := PopupWindow {
                        //forward-focus: le; // no effect
                        init => {
                            le.focus(); // works : line edit now has the focus, but
                                        // BUG : the lineedit cannot be edited now
                        }
                        le := LineEdit {
                            height: 100%;
                            width:  100%;
                            text: header.value;
                            accepted(t) => {
                                popup.close();
                                header.value = t;
                            }
                        }
                        x: te.x;
                        y: te.y - te.height * 0.4;
                        height: te.height;
                        width: te.width;
                        close-policy: close-on-click-outside;
                    }
                    ta := TouchArea {
                        double-clicked => {
                            popup.show();
                        }
                    }
                }
            }
        }
    }
}
```

### Environment Details

- Slint Version: 1.9.1
- Platform/OS: Linux Fedora 41
- Programming Language: Rust
- Backend/Renderer: Qt


### Product Impact

_No response_


Discussion / hints:
The problem is that the Qt backend uses native popup that have their own Window, and the focus item of the popup window is not in sync with the one from the parent window

Fix patch:
diff --git a/internal/core/window.rs b/internal/core/window.rs
index f4f149acd0e..65644151de1 100644
--- a/internal/core/window.rs
+++ b/internal/core/window.rs
@@ -791,6 +791,16 @@ impl WindowInner {
             return;
         }
 
+        let popup_wa = self.active_popups.borrow().last().and_then(|p| match &p.location {
+            PopupWindowLocation::TopLevel(wa) => Some(wa.clone()),
+            PopupWindowLocation::ChildWindow(..) => None,
+        });
+        if let Some(popup_wa) = popup_wa {
+            // Set the focus item on the popup's Window instead
+            popup_wa.window().0.set_focus_item(new_focus_item, set_focus);
+            return;
+        }
+
         let current_focus_item = self.focus_item.borrow().clone();
         if let Some(current_focus_item_rc) = current_focus_item.upgrade() {
             if set_focus {
@@ -1205,7 +1215,9 @@ impl WindowInner {
         let maybe_index = active_popups.iter().position(|popup| popup.popup_id == popup_id);
 
         if let Some(popup_index) = maybe_index {
-            self.close_popup_impl(&active_popups.remove(popup_index));
+            let p = active_popups.remove(popup_index);
+            drop(active_popups);
+            self.close_popup_impl(&p);
         }
     }
 


Test patch: