Make Kirigami.MenuDialog close automatically when selecting actions (like QQC2 menus do)

Is it possible to make Kirigami.MenuDialog automatically close after executing an action? The actions are also being used for buttons (and in future may be added to a QQC2 Menu), so it seems wrong to add menuDialog.close() to all the actions’ trigger functions.

This is the specific code: Draft: Converge desktop and mobile ListBrowserDelegate actions (!435) · Merge requests · Multimedia / Elisa · GitLab

Also, is it possible to have nested menus in Kirigami.MenuDialog? I’m thinking of adding something like this in the future (would be in a context menu for an audio track by two artists):

(menu items)
Go to Artist
    -> Artist1
    -> Artist2
(menu items)

Off the top of my head, submenus should be possible using Kirigami.Action :slight_smile: See Kirigami2 - org::kde::kirigami::Action Class Reference on how to do this.

1 Like

Doesn’t seem to be working for me. This is my test code:

Controls.Button {
    text: "Open Menu"
    onClicked: testMenu.open()
}

Kirigami.Action {
    id: mainAction
    text: "Top Level"
    Kirigami.Action {
        text: "Sub1"
    }
    Kirigami.Action {
        text: "Sub2"
    }
}

Kirigami.MenuDialog {
    id: testMenu
    actions: [mainAction]
}

Clicking “Top Level” doesn’t do anything.

Personally I dislike Kirigami.MenuDialog, on desktop please use a normal QQC2.Menu and on mobile a new component is getting created add BottomDrawer Component (!94) · Merge requests · Libraries / Kirigami Add-ons · GitLab which is already used in Audiotube

1 Like

Thanks, I think I’ll wait for that component to get merged

2 Likes