Skip to content
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

Issue with Sudden Page Flickering/Reloading When Using RestoreFromFile in LayoutSaver (Compared to Smooth Behavior of addDockWidget) #576

Open
abbaslele opened this issue Jan 19, 2025 · 1 comment

Comments

@abbaslele
Copy link

abbaslele commented Jan 19, 2025

Issue with Page Flickering When Using LayoutSaver and Calling RestoreFromFile

Description:
When using the LayoutSaver functionality and calling the RestoreFromFile method to restore the layout, the application page flickers or appears to close and reopen abruptly. This behavior makes it seem as though the entire application is closing and reopening, which negatively impacts the user experience and does not provide a smooth transition.

Steps to Reproduce:

Use LayoutSaver to save the layout.

Call the RestoreFromFile method to restore the layout.

Observe the sudden flickering or closing/reopening of the application page.

Relevant Code:
The following QML code demonstrates the usage of LayoutSaver:

import QtQuick 2.15
import QtQuick.Window 2.15
import QtQuick.Controls 2.12
import QtQuick.Controls.Material 2.15
import com.kdab.dockwidgets 2.0 as KDDW
import QtQuick.Layouts

Item {
    id: item
    property ApplicationTheme mApplicationTheme
    property StackView mStackView

    ColumnLayout{
        id: l1
        spacing: mApplicationTheme.layoutSpacing
        anchors.fill: parent
        LayoutItemProxy { target: navBar }
        LayoutItemProxy { target: u_DockArea }

    }

    Pane{
        id: navBar
        ...

        RowLayout{
            spacing: mApplicationTheme.layoutSpacing
            anchors.fill: parent


...
            LayoutItemProxy { target: uLayout_MenuBar }
...
            LayoutItemProxy { target: uSweepMode_Button}
            LayoutItemProxy { target: uMapMode_Button }
            LayoutItemProxy { target: uMultiBandMode_Button }
            ToolSeparator{}
            LayoutItemProxy { target: uPlayPause_Button }
            LayoutItemProxy { target: uFiller_Rectangel }

        }


...

        MenuBar {
            id: uLayout_MenuBar
            Menu {
                title: qsTr("&File")

                Action {
                    text: qsTr("Save Sweep layout")
                    onTriggered: {
                        layoutSaver.saveToFile("SweepLayout.json");
                    }
                }

                Action {
                    text: qsTr("Save Map layout")
                    onTriggered: {
                        layoutSaver.saveToFile("MapLayout.json");
                    }
                }

                Action {
                    text: qsTr("Save Multiband layout")
                    onTriggered: {
                        layoutSaver.saveToFile("MultibandLayout.json");
                    }
                }


                Action {
                    text: qsTr("Restore Sweep layout")
                    onTriggered: {
                        layoutSaver.restoreFromFile("SweepLayout.json");
                    }
                }
                Action {
                    text: qsTr("Restore Map layout")
                    onTriggered: {
                        layoutSaver.restoreFromFile("MapLayout.json");
                    }
                }
                Action {
                    text: qsTr("Restore Multiband layout")
                    onTriggered: {
                        layoutSaver.restoreFromFile("MultibandLayout.json");
                    }
                }




                Action {
                    text: qsTr("Close All")
                    onTriggered: {
                        _kddwDockRegistry.clear();
                    }
                }

                MenuSeparator { }

                Menu{
                    title: qsTr("&View")
                    Action{
                        text: qsTr("Setting")
                        onTriggered: {
                            u_DockArea.addDockWidget(dock1, KDDW.KDDockWidgets.Location_OnLeft, null, Qt.size(500, 500));

                        }
                    }

                    Action{
                        text: qsTr("dock6")
                        onTriggered: {
                            u_DockArea.addDockWidget(uReciverSetting_DockWidget, KDDW.KDDockWidgets.Location_OnLeft, null, Qt.size(500, 500));

                        }
                    }
                }

                Action { text: qsTr("&Quit")
                    onTriggered: {
                        Qt.quit();
                    }
                }
            }
        }


...


    }

    KDDW.DockingArea {
        id: u_DockArea
        // Each main layout needs a unique id
        uniqueName: "MainLayout-1"
        Layout.fillWidth: true
        Layout.fillHeight: true
        anchors.fill: parent
        Component.onCompleted: {

            addDockWidget(dock1, KDDW.KDDockWidgets.Location_OnLeft, null, Qt.size(500, 500));

            addDockWidget(uReciverSetting_DockWidget, KDDW.KDDockWidgets.Location_OnLeft, null, Qt.size(200, 200));

        }

        KDDW.DockWidget {
            id: dock1
            uniqueName: "dock6"
            Pane {
                Material.background: mApplicationTheme.accent
                anchors.fill: parent
            }
        }

        KDDW.DockWidget{
            id: uReciverSetting_DockWidget
            uniqueName: "Reciver Settings"
            Material.background: mApplicationTheme.background
            ReceiverSettingControl{
                mApplicationTheme: item.mApplicationTheme
            }
        }

    }

    KDDW.LayoutSaver {
        id: layoutSaver
    }

}

Expected Behavior:
After calling the RestoreFromFile method, the layout should restore smoothly without any flickering or abrupt closing/reopening of the application page, similar to how the addDockWidget method works.

Current Behavior:
When using RestoreFromFile, the application page flickers or appears to close and reopen abruptly.

When using addDockWidget (or similar methods), the layout updates smoothly without any flickering or abrupt behavior.

Additional Information:

Qt Version: 6.6.2

Operating System: Windows 11

QML Version: 2.15

Suggestions:
If you have any suggestions or solutions to improve this behavior, we would greatly appreciate your input. Additionally, if more information is needed, please let us know.

@iamsergio
Copy link
Contributor

Hi, is this for an open-source application, if so, can you link it here ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants