Exemple #1
0
def wrapInstance(widget):
    if isinstance(widget, basestring):
        widget = hou.ui.findPaneTab(widget)
    if USE_PYQT_MODULE:
        return sip.wrapinstance(long(widget), QObject)
    else:
        return shiboken.wrapInstance(long(widget), QWidget)
Exemple #2
0
def GetWindow(windowName):
    """
    get maya window
    :param windowName: window name
    :return:
    """
    ptr = mui.MQtUtil.findWindow(windowName)
    if ptr:
        return sip.wrapinstance(long(ptr))
Exemple #3
0
def GetMayaLayout(layoutString):
    """
    get maya layout
    :param layoutString: layout name
    :return:
    """
    ptr = mui.MQtUtil.findLayout(layoutString)
    if ptr:
        return sip.wrapinstance(long(ptr))
Exemple #4
0
def wrapInstance(widget):
    """
    change to Qt object
    :param widget:
    :return:
    """
    if isinstance(widget, basestring):
        widget = mui.MQtUtil.findWindow(widget)

    return sip.wrapinstance(long(widget), QObject)
Exemple #5
0
    def OnPopup(self, form, popup_handle):
        controller = self.controller

        #
        # so, i'm pretty picky about my UI / interactions. IDA puts items in
        # the right click context menus of custom (code) viewers.
        #
        # these items aren't really relevant (imo) to the microcode viewer,
        # so I do some dirty stuff here to filter them out and ensure only
        # my items will appear in the context menu.
        #
        # there's only one right click context item right now, but in the
        # future i'm sure there will be more.
        #

        class FilterMenu(QtCore.QObject):
            def __init__(self, qmenu):
                super(QtCore.QObject, self).__init__()
                self.qmenu = qmenu

            def eventFilter(self, obj, event):
                if event.type() != QtCore.QEvent.Polish:
                    return False
                for action in self.qmenu.actions():
                    if action.text() in ["&Font...",
                                         "&Synchronize with"]:  # lol..
                        qmenu.removeAction(action)
                self.qmenu.removeEventFilter(self)
                self.qmenu = None
                return True

        p_qmenu = ctypes.cast(int(popup_handle),
                              ctypes.POINTER(ctypes.c_void_p))[0]
        qmenu = sip.wrapinstance(int(p_qmenu), QtWidgets.QMenu)
        self.filter = FilterMenu(qmenu)
        qmenu.installEventFilter(self.filter)

        # only handle right clicks on lines containing micro instructions
        ins_token = self.model.mtext.get_ins_for_line(self.model.current_line)
        if not ins_token:
            return False

        class MyHandler(ida_kernwin.action_handler_t):
            def activate(self, ctx):
                controller.show_subtree(ins_token)

            def update(self, ctx):
                return ida_kernwin.AST_ENABLE_ALWAYS

        # inject the 'View subtree' action into the right click context menu
        desc = ida_kernwin.action_desc_t(None, 'View subtree', MyHandler())
        ida_kernwin.attach_dynamic_action_to_popup(form, popup_handle, desc,
                                                   None)

        return True
Exemple #6
0
    def __init__(self, controller):
        # create a dockable view
        self.twidget = idaapi.create_empty_widget(ControlPanelViewWrapper.NAME)
        self.widget = sip.wrapinstance(int(self.twidget), QWidget)
        self.widget.name = ControlPanelViewWrapper.NAME
        self.width_hint = 250

        self._controller = controller
        self._w = None

        self._init_widgets()
Exemple #7
0
    def OnPopup(self, form, popup_handle):
        """
        Context menu popup is about to be shown. Create items dynamically if you wish

        @return: Boolean. True if you handled the event
        """
        controller = self.controller

        class FilterMenu(QtCore.QObject):
            def __init__(self, qmenu):
                super(QtCore.QObject, self).__init__()
                self.qmenu = qmenu

            def eventFilter(self, obj, event):
                if event.type() != QtCore.QEvent.Polish:
                    return False
                for action in self.qmenu.actions():
                    if action.text() in ["&Font...",
                                         "&Synchronize with"]:  # lol..
                        qmenu.removeAction(action)
                self.qmenu.removeEventFilter(self)
                self.qmenu = None
                return True

        p_qmenu = ctypes.cast(int(popup_handle),
                              ctypes.POINTER(ctypes.c_void_p))[0]
        qmenu = sip.wrapinstance(int(p_qmenu), QtWidgets.QMenu)
        self.filter = FilterMenu(qmenu)
        qmenu.installEventFilter(self.filter)

        # only handle right clicks of instructions
        ins_token = self.model.mtext.get_ins_for_line(self.model.current_line)
        if not ins_token:
            return False

        class MyHandler(ida_kernwin.action_handler_t):
            def activate(self, ctx):
                controller.show_subtree(ins_token)

            def update(self, ctx):
                return ida_kernwin.AST_ENABLE_ALWAYS

        desc = ida_kernwin.action_desc_t(None, 'View subtree', MyHandler())
        ida_kernwin.attach_dynamic_action_to_popup(form, popup_handle, desc,
                                                   None)

        return True