示例#1
0
 def test_dialog():
     timer.stop()
     dialog = next((w for w in qApp.topLevelWidgets() if isinstance(w, ProtocolLabelDialog)), None)
     self.assertIsNotNone(dialog)
     self.assertEqual(dialog.model.rowCount(), 1)
     dialog.close()
     sip.delete(dialog)
示例#2
0
def getGuiItem(objName):
    """Returns a QtWidget based on its objectName.
    """
    for qWidget in qApp.topLevelWidgets():
        if qWidget.objectName() == objName:
            return qWidget
    return None
示例#3
0
def get_main_window():
    """Get MainWindow object (root parent of all widgets)"""
    top_levels = qApp.topLevelWidgets()
    main = next((tl for tl in top_levels if (
        isinstance(tl, QMainWindow) and tl.objectName() == 'main_window')),
                None)
    return main
示例#4
0
    def _find_main_window():
        """
        Return the main window instance using Qt.

        :return: the main window
        """
        for widget in qApp.topLevelWidgets():
            if isinstance(widget, QMainWindow):
                return widget
示例#5
0
 def test_open_message_type_dialog(self):
     assert isinstance(self.cfc, CompareFrameController)
     self.cfc.ui.btnMessagetypeSettings.click()
     dialog = next((w for w in qApp.topLevelWidgets() if isinstance(w, MessageTypeDialog)), None)
     self.assertIsNotNone(dialog)
     self.assertEqual(dialog.windowTitle(), self.cfc.active_message_type.name)
     dialog.close()
     sip.delete(dialog)
     QTest.qSleep(1)
     QTest.qWait(10)
示例#6
0
def mainWindow():
    global MW
    if not MW:
        for i in qApp.topLevelWidgets():
            if i.objectName() == "MainWindow":
                MW = i
                return MW
        return None
    else:
        return MW
示例#7
0
def mainWindow():
    global MW
    if not MW:
        for i in qApp.topLevelWidgets():
            if i.objectName() == "MainWindow":
                MW = i
                return MW
        return None
    else:
        return MW
示例#8
0
def windowBelow ( w ):
	while w != None and not w.isWindow ():
		w = w.parentWidget ()
	if w is None:
		return None
	for topWindow in qApp.topLevelWidgets ():
		# if topWindow.isWindow () and topWindow.isVisible () and topWindow.winId () == w.winId () and topWindow.windowState () != QtCore.Qt.WindowMinimized:
		if topWindow.isWindow () and topWindow.isVisible () and topWindow != w and topWindow.windowState () != QtCore.Qt.WindowMinimized:
			if topWindow.geometry ().contains ( QCursor.pos () ):
				# qWarning ( "windowBelow return: %s below: %s" % ( topWindow, w ) )
				return topWindow
	return None
示例#9
0
    def init(self):
        if constants.create_general_config_file(
        ):  # if the Config file didnt exist, we want to ask for a server name.
            server = idc.AskStr("", "Server:")
            constants.set_data_to_config_file("server", server)

        shared.BASE_URL = constants.get_data_from_config_file("server")
        shared.LOG = constants.get_data_from_config_file("log")

        self._window_handler = create_hidden_window()
        self._id = insert_to_registery(self._window_handler)
        log("Created window")

        shared.INTEGRATOR_WINDOW_ID = self._id
        shared.COMMUNICATION_MANAGER_WINDOW_ID = struct.unpack(
            ">I", os.urandom(4))[0]
        si = subprocess.STARTUPINFO()
        si.dwFlags |= subprocess.STARTF_USESHOWWINDOW
        subprocess.Popen([
            "python",
            "{0}\communication_manager.py".format(idaapi.idadir("plugins")),
            str(shared.INTEGRATOR_WINDOW_ID),
            str(shared.COMMUNICATION_MANAGER_WINDOW_ID)
        ])
        time.sleep(1)

        shared.IS_COMMUNICATION_MANAGER_STARTED = True
        if shared.USERID != -1:  #started.
            communication_manager_window_handler = constants.get_window_handler_by_id(
                shared.COMMUNICATION_MANAGER_WINDOW_ID)
            constants.send_data_to_window(
                communication_manager_window_handler,
                constants.CHANGE_PROJECT_ID,
                json.dumps({"project-id": shared.PROJECT_ID}))
            constants.send_data_to_window(
                communication_manager_window_handler, constants.CHANGE_USER,
                json.dumps({
                    "username": shared.USERNAME,
                    "id": shared.USERID,
                    "token": shared.USER_TOKEN
                }))

        self.hook()
        for widget in qApp.topLevelWidgets():
            if isinstance(widget, QMainWindow):
                self._window = widget
                break
        return idaapi.PLUGIN_KEEP
示例#10
0
文件: ui.py 项目: Revether/Revether
    def __init__(self, plugin):
        plugin.logger.debug('Initating the plugin UI')

        # we need to find the ida main window in order to add
        # widgets to it
        for widget in qApp.topLevelWidgets():
            if isinstance(widget, QMainWindow):
                self._window = widget
                break

        self._status_widget = StatusWidget(plugin)
        self._status_widget.add_widget(self._window)

        self._save_action_handler = SaveMenuActionHandler(plugin)
        self._save_action = SaveMenuAction(plugin, self._save_action_handler)
        self._save_action.install()
示例#11
0
    def __init__(self, plugin):
        super(Interface, self).__init__(plugin)
        self._invites = []

        # Find the QMainWindow instance
        for widget in qApp.topLevelWidgets():
            if isinstance(widget, QMainWindow):
                self._window = widget
                break

        self._open_action = OpenAction(plugin)
        self._save_action = SaveAction(plugin)

        self._painter = Painter(plugin)
        self._filter = EventFilter(plugin)
        self._widget = StatusWidget(plugin)
示例#12
0
def exceptionHandler(exType, exValue, exTrace, testMode=False):
    """Function to catch unhandled global exceptions.
    """
    import nw
    import logging
    from traceback import print_tb
    from PyQt5.QtWidgets import qApp

    logger = logging.getLogger(__name__)
    logger.critical("%s: %s" % (exType.__name__, str(exValue)))
    print_tb(exTrace)

    try:
        nwGUI = None
        for qWin in qApp.topLevelWidgets():
            if qWin.objectName() == "GuiMain":
                nwGUI = qWin
                break

        if nwGUI is None:
            logger.warning("Could not find main GUI window so cannot open error dialog")
            return

        errMsg = NWErrorMessage(nwGUI)
        errMsg.setMessage(exType, exValue, exTrace)
        if nw.CONFIG.showGUI:
            errMsg.exec_()

        try:
            # Try a controlled shudown
            nwGUI.closeProject(isYes=True)
            nwGUI.closeMain()
            logger.info("Emergency shutdown successful")

        except Exception as e:
            logger.critical("Could not close the project before exiting")
            logger.critical(str(e))

        if testMode:
            return errMsg.msgBody.toPlainText()
        else:
            qApp.exit(1)

    except Exception as e:
        logger.critical(str(e))

    return
示例#13
0
    def __init__(self, plugin):
        super(Interface, self).__init__(plugin)
        self._invites = []
        self._followed = None

        # Find the QMainWindow instance
        self._plugin.logger.debug("Searching for the main window")
        for widget in qApp.topLevelWidgets():
            if isinstance(widget, QMainWindow):
                self._window = widget
                break

        self._open_action = OpenAction(plugin)
        self._save_action = SaveAction(plugin)

        self._painter = Painter(plugin)
        self._filter = EventFilter(plugin)
        self._widget = StatusWidget(plugin)
示例#14
0
def exceptionHandler(exType, exValue, exTrace):
    """Function to catch unhandled global exceptions.
    """
    from traceback import print_tb
    from PyQt5.QtWidgets import qApp

    logger.critical("%s: %s", exType.__name__, str(exValue))
    print_tb(exTrace)

    try:
        nwGUI = None
        for qWin in qApp.topLevelWidgets():
            if qWin.objectName() == "GuiMain":
                nwGUI = qWin
                break

        if nwGUI is None:
            logger.warning(
                "Could not find main GUI window so cannot open error dialog")
            return

        errMsg = NWErrorMessage(nwGUI)
        errMsg.setMessage(exType, exValue, exTrace)
        errMsg.exec_()

        try:
            # Try a controlled shutdown
            nwGUI.closeProject(isYes=True)
            nwGUI.closeMain()
            logger.info("Emergency shutdown successful")

        except Exception as exc:
            logger.critical("Could not close the project before exiting")
            logger.critical(formatException(exc))

        qApp.exit(1)

    except Exception as exc:
        logger.critical(formatException(exc))

    return
示例#15
0
 def __confirm_message_box(self):
     for w in qApp.topLevelWidgets():
         if type(w) == QMessageBox:
             QTest.keyClick(w, Qt.Key_Enter)
示例#16
0
 def accept_delete():
     timer.stop()
     message_box = next(w for w in qApp.topLevelWidgets()
                        if isinstance(w, QMessageBox))
     message_box.button(QMessageBox.Yes).click()
示例#17
0
 def set_save_name():
     timer.stop()
     input_dialog = next(w for w in qApp.topLevelWidgets()
                         if isinstance(w, QInputDialog))
     input_dialog.setTextValue("Test decoding")
     input_dialog.accept()
示例#18
0
 def set_save_name():
     timer.stop()
     input_dialog = next(w for w in qApp.topLevelWidgets() if isinstance(w, QInputDialog))
     input_dialog.setTextValue("Test decoding")
     input_dialog.accept()
示例#19
0
 def accept_delete():
     timer.stop()
     message_box = next(w for w in qApp.topLevelWidgets() if isinstance(w, QMessageBox))
     message_box.button(QMessageBox.Yes).click()