If a submenu action has an icon set, make sure to also display it

Authored by ahiemstra on Aug 27 2019, 4:28 PM.

Description

If a submenu action has an icon set, make sure to also display it

Summary:
QQC2's Menu does not support icons, but the MenuItem that gets created
when it is used as a submenu does. Since we already have a reference to
that MenuItem, also update the MenuItem's icon property with those of
the Action. This way submenus will properly display icons if set.

Test Plan:
The following test code, ran through qmlscene, should produce a context menu
with icons for both entries, even though one of them is a menu.

Note that you will need D23499 for the context menu button to show up again.

import QtQuick 2.12
import QtQuick.Controls 2.12

import org.kde.kirigami 2.8 as Kirigami

Kirigami.ApplicationWindow {
    pageStack.initialPage: Kirigami.Page {
        actions.main: Kirigami.Action { text: "Main"; icon.name: "document-new" }
        actions.contextualActions: [
            Kirigami.Action { text: "Action 1"; icon.name: "document-new" },
            Kirigami.Action {
                text: "Action 2"
                icon.name: "document-new"
                Kirigami.Action { text: "Nested Action" }
            }
        ]
    }
}

Reviewers: Kirigami, mart

Reviewed By: Kirigami, mart

Subscribers: plasma-devel

Tags: Kirigami

Differential Revision: https://phabricator.kde.org/D23501