Prompts the user to edit the menu template with the given actions. \
        If no actions are supplied, then the actions from the parent will \
        be used.
        
        :param      parent   | <QWidget>
                    template | <str>
                    actions  | {<str> name: <QAction>, .. } || None
        
        :return     (<str> template, <bool> accepted)

def edit( parent, template, actions = None ):
        """
        Prompts the user to edit the menu template with the given actions. \
        If no actions are supplied, then the actions from the parent will \
        be used.
        
        :param      parent   | <QWidget>
                    template | <str>
                    actions  | {<str> name: <QAction>, .. } || None
        
        :return     (<str> template, <bool> accepted)
        """
        # collect the potential actions from the widget
        if ( actions is None ):
            actions = {}
            for action in parent.actions():
                key = nativestring(action.objectName())
                if ( not key ):
                    key = nativestring(action.text()).replace('&', '')
                
                if ( key ):
                    actions[key] = action
        
        if ( not actions ):
            return ('', False)
        
        dlg = QDialog(parent)
        dlg.setWindowTitle('Edit Menu')
        
        widget = XMenuTemplateWidget(dlg)
        widget.setActions(actions)
        widget.setMenuTemplate(template)
        widget.layout().setContentsMargins(0, 0, 0, 0)
        
        opts = QDialogButtonBox.Save | QDialogButtonBox.Cancel
        btns = QDialogButtonBox(opts, Qt.Horizontal, dlg)
        
        btns.accepted.connect( dlg.accept )
        btns.rejected.connect( dlg.reject )
        
        layout = QVBoxLayout()
        layout.addWidget(widget)
        layout.addWidget(btns)
        
        dlg.setLayout(layout)
        dlg.adjustSize()
        dlg.resize(650, 400)
        
        if ( dlg.exec_() ):
            return (widget.menuTemplate(), True)
        return ('', False)