alpqr / qrhiimgui2

New Dear ImGui - Qt Quick integration (Qt 6.4+ only)
23 stars 1 forks source link

QML FileDialog cannot be rendered normally while imgui node is running (linux only) #2

Open Sayter99 opened 1 month ago

Sayter99 commented 1 month ago

As title, while opening a filedialog, if there is a imgui quickitem set to "visible", the filedialog couldn't work normally. If set all imgui node to be invisible, filedialog can work again.

It only happens for native filedialog under linux. Windows works fine, so as non-native qml based filedialog.

Environment

Repro

Adding filedialog and a button to open it in simple/main.qml

import QtQuick
import QtQuick.Controls
import QtQuick.Dialogs
import QtQuick.Layouts
import ImguiExample

Item {
    Rectangle {
        color: "transparent"
        anchors.fill: parent
        Rectangle {
            id: imguiContainer
            property bool fullWin: true
            property bool useTex: false
            layer.enabled: useTex
            color: "transparent"
            width: fullWin ? parent.width : parent.width - 200
            height: fullWin ? parent.height : parent.height - 400
            x: fullWin ? 0 : 100
            y: fullWin ? 0 : 100
            z: ztimer.running ? 1 : 0
            Imgui {
                id: gui
                objectName: "gui"
                anchors.fill: parent
                SequentialAnimation on opacity {
                    id: opacityAnim
                    running: false
                    NumberAnimation { from: 1; to: 0; duration: 3000 }
                    NumberAnimation { from: 0; to: 1; duration: 3000 }
                }
            }
            Timer {
                id: ztimer
                repeat: false
                interval: 10000
            }
        }
        Rectangle {
            border.width: 2
            border.color: "black"
            y: 50
            width: 400
            height: 50
            clip: true
            TextEdit {
                id: textEdit
                anchors.fill: parent
                text: "TextEdit to test focus"
                font.pointSize: 20
                color: "blue"
            }
        }
        RowLayout {
            y: 20
            Button {
                text: "Toggle visibility"
                onClicked: gui.visible = !gui.visible
            }
            Button {
                text: "Toggle size"
                onClicked: imguiContainer.fullWin = !imguiContainer.fullWin
            }
            Button {
                text: "Animate opacity"
                onClicked: opacityAnim.running = true
            }
            Button {
                text: "Move to top for 10 sec"
                onClicked: ztimer.running = true
            }
            Button {
                text: "Toggle layer (full size only)"
                onClicked: imguiContainer.useTex = !imguiContainer.useTex
            }
            Button {
                text: "File Dialog"
                onClicked: fd.open()
            }
        }
    }
    Column {
        anchors.right: parent.right
        Text {
            text: "ImGui item visible: " + gui.visible
                  + "\ncovers entire window: " + imguiContainer.fullWin
                  + "\npart of an Item layer: " + imguiContainer.useTex
                  + "\nstacks on top of buttons/textedit: " + ztimer.running
            color: "white"
        }
    }
    FileDialog {
        id: fd
        fileMode: FileDialog.SaveFile
        nameFilters: ["proto (*.pbtxt *.pbjson *.pb)"]
        onAccepted: () => {
            console.log(selectedFile);
        }
    }
}