Exemplo n.º 1
0
class FirstAidPlugin:
    def __init__(self, iface):
        self.old_show_exception = None
        self.debugger_widget = None

    def initGui(self):
        # ReportPlugin also hooks exceptions and needs to be unloaded if active
        # so qgis.utils.showException is the QGIS native one
        report_plugin = "report"
        report_plugin_active = report_plugin in qgis.utils.active_plugins
        if report_plugin_active:
            qgis.utils.unloadPlugin(report_plugin)

        # hook to exception handling
        self.old_show_exception = qgis.utils.showException
        qgis.utils.showException = showException

        icon = QIcon(
            os.path.join(os.path.dirname(__file__), "icons", "bug.svg"))
        self.action_debugger = QAction(icon, "Debug (F12)",
                                       qgis.utils.iface.mainWindow())
        self.action_debugger.setShortcut("F12")
        self.action_debugger.triggered.connect(self.run_debugger)
        qgis.utils.iface.addToolBarIcon(self.action_debugger)

        # If ReportPlugin was activated, load and start it again to cooperate
        if report_plugin_active:
            qgis.utils.loadPlugin(report_plugin)
            qgis.utils.startPlugin(report_plugin)

    def unload(self):

        qgis.utils.iface.removeToolBarIcon(self.action_debugger)
        del self.action_debugger

        # unhook from exception handling
        qgis.utils.showException = self.old_show_exception

    def run_debugger(self):
        if self.debugger_widget is None:
            self.debugger_widget = DebuggerWidget()
        else:
            self.debugger_widget.start_tracing()
        self.debugger_widget.show()
Exemplo n.º 2
0
class FirstAidPlugin:
    def __init__(self, iface):
        self.old_show_exception = None
        self.debugger_widget = None

    def initGui(self):
        # ReportPlugin also hooks exceptions and needs to be unloaded if active
        # so qgis.utils.showException is the QGIS native one
        report_plugin = "report"
        report_plugin_active = report_plugin in qgis.utils.active_plugins
        if report_plugin_active:
            qgis.utils.unloadPlugin(report_plugin)

        # hook to exception handling
        self.old_show_exception = qgis.utils.showException
        qgis.utils.showException = showException

        icon = QIcon(os.path.join(os.path.dirname(__file__), "icons", "bug.svg"))
        self.action_debugger = QAction(icon, "Debug (F12)", qgis.utils.iface.mainWindow())
        self.action_debugger.setShortcut("F12")
        self.action_debugger.triggered.connect(self.run_debugger)
        qgis.utils.iface.addToolBarIcon(self.action_debugger)

        # If ReportPlugin was activated, load and start it again to cooperate
        if report_plugin_active:
            qgis.utils.loadPlugin(report_plugin)
            qgis.utils.startPlugin(report_plugin)

    def unload(self):

        qgis.utils.iface.removeToolBarIcon(self.action_debugger)
        del self.action_debugger

        # unhook from exception handling
        qgis.utils.showException = self.old_show_exception

    def run_debugger(self):
        if self.debugger_widget is None:
            self.debugger_widget = DebuggerWidget()
        else:
            self.debugger_widget.start_tracing()
        self.debugger_widget.show()
Exemplo n.º 3
0
 def run_debugger(self):
     if self.debugger_widget is None:
         self.debugger_widget = DebuggerWidget()
     else:
         self.debugger_widget.start_tracing()
     self.debugger_widget.show()
Exemplo n.º 4
0
 def run_debugger(self):
     if self.debugger_widget is None:
         self.debugger_widget = DebuggerWidget()
     else:
         self.debugger_widget.start_tracing()
     self.debugger_widget.show()