def __init__(self, parent=None): """ init UI """ QMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.dockToolBarManager = DockToolBarManager(self) self.dockToolBar(Qt.TopToolBarArea) self.__bottomDockBar = self.dockToolBar(Qt.BottomToolBarArea) self.dockToolBar(Qt.LeftToolBarArea) self.dockToolBar(Qt.RightToolBarArea) self.ui.actionSaveSession.setEnabled(False) self.do = DistributedObjects(self) self.act = self.do.actions self.debugController = self.do.debugController self.settings = self.do.settings self.signalproxy = self.do.signalProxy self.pluginloader = PluginLoader(self.do) self.act = self.do.actions # init RecentFileHandler self.recentFileHandler = RecentFileHandler( self, self.ui.menuRecentlyUsedFiles, self.do) self.debugController.executableOpened.connect( self.recentFileHandler.addToRecentFiles) self.debugController.executableOpened.connect(self.showExecutableName) self.debugController.executableOpened.connect(self.disableButtons) # signal proxy self.signalproxy.inferiorIsRunning.connect(self.targetStartedRunning) self.signalproxy.inferiorStoppedNormally.connect(self.targetStopped) self.signalproxy.inferiorReceivedSignal.connect(self.targetStopped) self.signalproxy.inferiorHasExited.connect(self.targetExited) self.signalproxy.recordStateChanged.connect( self.setReverseDebugButtonsState) # Plugin Loader self.pluginloader.insertPluginAction.connect(self.addPluginAction) self.ui.actionSavePlugins.triggered.connect(self.showSavePluginsDialog) self.ui.actionLoadPlugins.triggered.connect(self.showLoadPluginsDialog) # Add editor to main window. self.ui.verticalLayout.addWidget(self.do.editorController.editor_view) dw = self.newDockWidget("Log View", Qt.BottomDockWidgetArea, True) self.logviewhandler = LogViewHandler(dw) dw.setWidget(self.logviewhandler) self.notificationFrameHandler = NotificationFrameHandler( self.ui.notificationArea) self.pluginloader.addAvailablePlugins() self.setWindowFilePath("<none>") self.setupUi() self.readSettings() self.quickwatch = QuickWatch(self, self.do)
def __init__(self, parent=None): """ init UI """ QMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.actionSaveSession.setEnabled(False) self.distributedObjects = DistributedObjects() self.act = self.distributedObjects.actions self.debugController = self.distributedObjects.debugController self.settings = self.debugController.settings self.signalproxy = self.distributedObjects.signalProxy self.pluginloader = PluginLoader(self.distributedObjects) self.editorController = self.distributedObjects.editorController self.act = self.distributedObjects.actions # init RecentFileHandler self.recentFileHandler = RecentFileHandler(self, self.ui.menuRecentlyUsedFiles, self.distributedObjects) self.debugController.executableOpened.connect(self.recentFileHandler.addToRecentFiles) self.debugController.executableOpened.connect(self.__observeWorkingBinary) self.debugController.executableOpened.connect(self.showExecutableName) self.debugController.executableOpened.connect(self.disableButtons) # signal proxy self.signalproxy.inferiorIsRunning.connect(self.targetStartedRunning, Qt.QueuedConnection) self.signalproxy.inferiorStoppedNormally.connect(self.targetStopped, Qt.QueuedConnection) self.signalproxy.inferiorReceivedSignal.connect(self.targetStopped, Qt.QueuedConnection) self.signalproxy.inferiorHasExited.connect(self.targetExited, Qt.QueuedConnection) self.signalproxy.addDockWidget.connect(self.addPluginDockWidget) self.signalproxy.removeDockWidget.connect(self.removeDockWidget) # Plugin Loader self.pluginloader.insertPluginAction.connect(self.addPluginAction) self.ui.actionSavePlugins.triggered.connect(self.showSavePluginsDialog) self.ui.actionLoadPlugins.triggered.connect(self.showLoadPluginsDialog) # Add editor to main window. self.ui.gridLayout.addWidget(self.distributedObjects.editorController.editor_view, 0, 0, 1, 1) self.pluginloader.addAvailablePlugins() # Tell everyone to insert their dock widgets into the main window self.signalproxy.emitInsertDockWidgets() # get filelist dockwidget self.filelist_dockwidget = self.findChild(QDockWidget, "FileListView") self.setWindowFilePath("<none>") self.setupUi() self.createInitialWindowPlacement() self.readSettings() self.quickwatch = QuickWatch(self, self.distributedObjects) self.binaryName = None self.fileWatcher = QFileSystemWatcher() self.fileWatcher.fileChanged.connect(self.__binaryChanged)
def __init__(self, parent=None): """ init UI """ QMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.dockToolBarManager = DockToolBarManager(self) self.dockToolBar(Qt.TopToolBarArea) self.__bottomDockBar = self.dockToolBar(Qt.BottomToolBarArea) self.dockToolBar(Qt.LeftToolBarArea) self.dockToolBar(Qt.RightToolBarArea) self.ui.actionSaveSession.setEnabled(False) self.do = DistributedObjects(self) self.act = self.do.actions self.debugController = self.do.debugController self.settings = self.do.settings self.signalproxy = self.do.signalProxy self.pluginloader = PluginLoader(self.do) self.act = self.do.actions # init RecentFileHandler self.recentFileHandler = RecentFileHandler(self, self.ui.menuRecentlyUsedFiles, self.do) self.debugController.executableOpened.connect(self.recentFileHandler.addToRecentFiles) self.debugController.executableOpened.connect(self.showExecutableName) self.debugController.executableOpened.connect(self.disableButtons) # signal proxy self.signalproxy.inferiorIsRunning.connect(self.targetStartedRunning) self.signalproxy.inferiorStoppedNormally.connect(self.targetStopped) self.signalproxy.inferiorReceivedSignal.connect(self.targetStopped) self.signalproxy.inferiorHasExited.connect(self.targetExited) self.signalproxy.recordStateChanged.connect(self.setReverseDebugButtonsState) # Plugin Loader self.pluginloader.insertPluginAction.connect(self.addPluginAction) self.ui.actionSavePlugins.triggered.connect(self.showSavePluginsDialog) self.ui.actionLoadPlugins.triggered.connect(self.showLoadPluginsDialog) # Add editor to main window. self.ui.verticalLayout.addWidget(self.do.editorController.editor_view) dw = self.newDockWidget("Log View", Qt.BottomDockWidgetArea, True) self.logviewhandler = LogViewHandler(dw) dw.setWidget(self.logviewhandler) self.notificationFrameHandler = NotificationFrameHandler(self.ui.notificationArea) self.pluginloader.addAvailablePlugins() self.setWindowFilePath("<none>") self.setupUi() self.readSettings() self.quickwatch = QuickWatch(self, self.do)
def __init__(self, parent=None): """ init UI """ QMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.actionSaveSession.setEnabled(False) self.distributedObjects = DistributedObjects(self) self.act = self.distributedObjects.actions self.debugController = self.distributedObjects.debugController self.settings = self.distributedObjects.settings self.signalproxy = self.distributedObjects.signalProxy self.pluginloader = PluginLoader(self.distributedObjects) self.editorController = self.distributedObjects.editorController self.act = self.distributedObjects.actions # init RecentFileHandler self.recentFileHandler = RecentFileHandler(self, self.ui.menuRecentlyUsedFiles, self.distributedObjects) self.debugController.executableOpened.connect(self.recentFileHandler.addToRecentFiles) self.debugController.executableOpened.connect(self.__observeWorkingBinary) self.debugController.executableOpened.connect(self.showExecutableName) self.debugController.executableOpened.connect(self.disableButtons) # signal proxy self.signalproxy.inferiorIsRunning.connect(self.targetStartedRunning) self.signalproxy.inferiorStoppedNormally.connect(self.targetStopped) self.signalproxy.inferiorReceivedSignal.connect(self.targetStopped) self.signalproxy.inferiorHasExited.connect(self.targetExited) # Plugin Loader self.pluginloader.insertPluginAction.connect(self.addPluginAction) self.ui.actionSavePlugins.triggered.connect(self.showSavePluginsDialog) self.ui.actionLoadPlugins.triggered.connect(self.showLoadPluginsDialog) # Add editor to main window. self.ui.gridLayout.addWidget(self.distributedObjects.editorController.editor_view, 0, 0, 1, 1) self.pluginloader.addAvailablePlugins() self.setWindowFilePath("<none>") self.setupUi() self.readSettings() self.quickwatch = QuickWatch(self, self.distributedObjects) self.binaryName = None self.fileWatcher = QFileSystemWatcher() self.fileWatcher.fileChanged.connect(self.__binaryChanged) self.__runWithArgumentsMenu = None self.__argumentsEdit = None self.__makeRunWithArgumentsMenu()
def __init__(self, parent=None): """ init UI """ QMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.actionSaveSession.setEnabled(False) self.distributedObjects = DistributedObjects() self.debugController = self.distributedObjects.debugController self.settings = self.debugController.settings self.signalproxy = self.distributedObjects.signalProxy self.pluginloader = PluginLoader(self.distributedObjects) #init RecentFileHandler nrRecentFiles = 5 self.initRecentFileHandler(nrRecentFiles) QObject.connect(self.debugController, SIGNAL('executableOpened'), self.showExecutableName) # signal proxy QObject.connect(self.signalproxy, SIGNAL('inferiorIsRunning(PyQt_PyObject)'), self.targetStartedRunning, Qt.QueuedConnection) QObject.connect(self.signalproxy, SIGNAL('inferiorStoppedNormally(PyQt_PyObject)'), self.targetStopped, Qt.QueuedConnection) QObject.connect(self.signalproxy, SIGNAL('inferiorReceivedSignal(PyQt_PyObject)'), self.targetStopped, Qt.QueuedConnection) QObject.connect(self.signalproxy, SIGNAL('inferiorHasExited(PyQt_PyObject)'), self.targetExited, Qt.QueuedConnection) QObject.connect(self.signalproxy, SIGNAL('addDockWidget(PyQt_PyObject, QDockWidget, PyQt_PyObject)'), self.addPluginDockWidget) QObject.connect(self.signalproxy, SIGNAL('removeDockWidget(QDockWidget)'), self.removeDockWidget) QObject.connect(self.pluginloader, SIGNAL('insertPluginAction(PyQt_PyObject)'), self.addPluginAction) QObject.connect(self.ui.actionSavePlugins, SIGNAL('activated()'), self.showSavePluginsDialog) QObject.connect(self.ui.actionLoadPlugins, SIGNAL('activated()'), self.showLoadPluginsDialog) # Add editor to main window. self.ui.gridLayout.addWidget(self.distributedObjects.editorController.editor_view, 0, 0, 1, 1) self.pluginloader.addAvailablePlugins() # Tell everyone to insert their dock widgets into the main window self.distributedObjects.signalProxy.insertDockWidgets() # get filelist dockwidget self.filelist_dockwidget = self.findChild(QDockWidget, "FileListView") self.setWindowFilePath("<none>") self.setupUi() self.createInitialWindowPlacement() self.readSettings() self.quickwatch = QuickWatch(self, self.distributedObjects)
class MainWindow(QMainWindow): def setupUi(self): self.__initActions() self.ui.statusLabel = QLabel() self.ui.statusLabel.setText("Not running") self.ui.statusbar.addPermanentWidget(self.ui.statusLabel) self.ui.statusIcon = QLabel() self.ui.statusIcon.setPixmap(QPixmap(":/icons/images/inferior_not_running.png")) self.ui.statusbar.addPermanentWidget(self.ui.statusIcon) #def setupGraph(self): #self.scene = QGraphicsScene() #self.c2 = Composite() #self.c1 = Composite() #self.c1.addItem(LeafEntry("exp1", "val11")) #self.c1.addItem(LeafEntry("exp2 long", "val22")) #self.c2.addItem(LeafEntry("exp2 even longer", "val22")) #self.c2.addItem(CompositeEntry("subcomp", self.c1)) #self.c2.setFlags(QGraphicsItem.ItemIsSelectable | QGraphicsItem.ItemIsMovable) #self.scene.addItem(self.c2) def __initActions(self): self.act = Actions(self) # debug actions self.ui.menuDebug.addAction(self.act.actions[Actions.Run]) self.ui.menuDebug.addAction(self.act.actions[Actions.Continue]) self.ui.menuDebug.addAction(self.act.actions[Actions.Interrupt]) self.ui.menuDebug.addAction(self.act.actions[Actions.Next]) self.ui.menuDebug.addAction(self.act.actions[Actions.Step]) self.ui.menuDebug.addAction(self.act.actions[Actions.Finish]) self.ui.menuDebug.addAction(self.act.actions[Actions.RunToCursor]) # file actions self.ui.menuFile.insertAction(self.ui.actionSaveSession, self.act.actions[Actions.Open]) self.ui.menuFile.addAction(self.act.actions[Actions.SaveFile]) self.ui.menuFile.addAction(self.act.actions[Actions.Exit]) # add them to menubar and also menuView to respect order self.ui.menubar.addAction(self.ui.menuFile.menuAction()) self.ui.menubar.addAction(self.ui.menuView.menuAction()) self.ui.menubar.addAction(self.ui.menuDebug.menuAction()) self.ui.menubar.addAction(self.ui.menuHelp.menuAction()) # now make toolbar actions self.ui.Main.addAction(self.act.actions[Actions.Open]) self.ui.Main.addAction(self.act.actions[Actions.SaveFile]) self.ui.Main.addSeparator() self.ui.Main.addAction(self.act.actions[Actions.Run]) self.ui.Main.addAction(self.act.actions[Actions.Continue]) self.ui.Main.addAction(self.act.actions[Actions.Interrupt]) self.ui.Main.addAction(self.act.actions[Actions.Next]) self.ui.Main.addAction(self.act.actions[Actions.Step]) self.ui.Main.addAction(self.act.actions[Actions.Finish]) self.ui.Main.addAction(self.act.actions[Actions.RunToCursor]) self.ui.Main.addSeparator() self.ui.Main.addAction(self.act.actions[Actions.Exit]) # connect actions self.__connectActions() def __connectActions(self): # file menu self.connect(self.act.actions[Actions.Open], SIGNAL('activated()'), self.showOpenExecutableDialog) self.connect(self.act.actions[Actions.Exit], SIGNAL('activated()'), self.close) self.connect(self.act.actions[Actions.SaveFile], SIGNAL('activated()'), self.signalproxy.emitSaveCurrentFile) # debug menu self.connect(self.act.actions[Actions.Run], SIGNAL('activated()'), self.debugController.run) self.connect(self.act.actions[Actions.Next], SIGNAL('activated()'), self.debugController.next_) self.connect(self.act.actions[Actions.Step], SIGNAL('activated()'), self.debugController.step) self.connect(self.act.actions[Actions.Continue], SIGNAL('activated()'), self.debugController.cont) self.connect(self.act.actions[Actions.Interrupt], SIGNAL('activated()'), self.debugController.interrupt) self.connect(self.act.actions[Actions.Finish], SIGNAL('activated()'), self.debugController.finish) self.connect(self.act.actions[Actions.RunToCursor], SIGNAL('activated()'), self.debugController.inferiorUntil) QObject.connect(self.ui.actionRestoreSession, SIGNAL('activated()'), self.distributedObjects.sessionManager.showRestoreSessionDialog) QObject.connect(self.ui.actionSaveSession, SIGNAL('activated()'), self.distributedObjects.sessionManager.showSaveSessionDialog) def __init__(self, parent=None): """ init UI """ QMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.actionSaveSession.setEnabled(False) self.distributedObjects = DistributedObjects() self.debugController = self.distributedObjects.debugController self.settings = self.debugController.settings self.signalproxy = self.distributedObjects.signalProxy self.pluginloader = PluginLoader(self.distributedObjects) #init RecentFileHandler nrRecentFiles = 5 self.initRecentFileHandler(nrRecentFiles) QObject.connect(self.debugController, SIGNAL('executableOpened'), self.showExecutableName) # signal proxy QObject.connect(self.signalproxy, SIGNAL('inferiorIsRunning(PyQt_PyObject)'), self.targetStartedRunning, Qt.QueuedConnection) QObject.connect(self.signalproxy, SIGNAL('inferiorStoppedNormally(PyQt_PyObject)'), self.targetStopped, Qt.QueuedConnection) QObject.connect(self.signalproxy, SIGNAL('inferiorReceivedSignal(PyQt_PyObject)'), self.targetStopped, Qt.QueuedConnection) QObject.connect(self.signalproxy, SIGNAL('inferiorHasExited(PyQt_PyObject)'), self.targetExited, Qt.QueuedConnection) QObject.connect(self.signalproxy, SIGNAL('addDockWidget(PyQt_PyObject, QDockWidget, PyQt_PyObject)'), self.addPluginDockWidget) QObject.connect(self.signalproxy, SIGNAL('removeDockWidget(QDockWidget)'), self.removeDockWidget) QObject.connect(self.pluginloader, SIGNAL('insertPluginAction(PyQt_PyObject)'), self.addPluginAction) QObject.connect(self.ui.actionSavePlugins, SIGNAL('activated()'), self.showSavePluginsDialog) QObject.connect(self.ui.actionLoadPlugins, SIGNAL('activated()'), self.showLoadPluginsDialog) # Add editor to main window. self.ui.gridLayout.addWidget(self.distributedObjects.editorController.editor_view, 0, 0, 1, 1) self.pluginloader.addAvailablePlugins() # Tell everyone to insert their dock widgets into the main window self.distributedObjects.signalProxy.insertDockWidgets() # get filelist dockwidget self.filelist_dockwidget = self.findChild(QDockWidget, "FileListView") self.setWindowFilePath("<none>") self.setupUi() self.createInitialWindowPlacement() self.readSettings() self.quickwatch = QuickWatch(self, self.distributedObjects) def addPluginDockWidget(self, area, widget, addToggleViewAction): self.addDockWidget(area, widget) if addToggleViewAction: self.ui.menuShow_View.addAction(widget.toggleViewAction()) def addPluginAction(self, Action): """ show plugin as menu entry """ self.ui.menuPlugins.addAction(Action) def createInitialWindowPlacement(self): """ Saves the window and widget placement after first start of program. """ #check if settings do not exist initExists = self.settings.contains("InitialWindowPlacement/geometry") if not initExists: self.breakpointWidget = self.findChild(QDockWidget, "BreakpointView") self.fileListWidget = self.findChild(QDockWidget, "FileListView") self.dataGraphWidget = self.findChild(QDockWidget, "DataGraphView") self.watchWidget = self.findChild(QDockWidget, "WatchView") self.localsWidget = self.findChild(QDockWidget, "LocalsView") self.stackWidget = self.findChild(QDockWidget, "StackView") self.tracepointWidget = self.findChild(QDockWidget, "TracepointView") self.gdbIoWidget = self.findChild(QDockWidget, "GdbIoView") self.pyIoWidget = self.findChild(QDockWidget, "PyIoView") self.inferiorIoWidget = self.findChild(QDockWidget, "InferiorIoView") #tabify widgets to initial state and save settings self.tabifyDockWidget(self.fileListWidget, self.dataGraphWidget) self.tabifyDockWidget(self.watchWidget, self.localsWidget) self.tabifyDockWidget(self.localsWidget, self.stackWidget) self.tabifyDockWidget(self.stackWidget, self.breakpointWidget) self.tabifyDockWidget(self.breakpointWidget, self.tracepointWidget) self.tabifyDockWidget(self.gdbIoWidget, self.pyIoWidget) self.tabifyDockWidget(self.pyIoWidget, self.inferiorIoWidget) self.settings.setValue("InitialWindowPlacement/geometry", self.saveGeometry()) self.settings.setValue("InitialWindowPlacement/windowState", self.saveState()) def initRecentFileHandler(self, nrRecentFiles): """ Create menu entries for recently used files and connect them to the RecentFileHandler """ # create menu entries and connect the actions to the debug controller recentFileActions = [0] * nrRecentFiles for i in range(nrRecentFiles): recentFileActions[i] = OpenRecentFileAction(self) recentFileActions[i].setVisible(False) self.ui.menuRecentlyUsedFiles.addAction(recentFileActions[i]) QObject.connect(recentFileActions[i], SIGNAL('executableOpened'), self.distributedObjects.debugController.openExecutable) self.RecentFileHandler = RecentFileHandler(recentFileActions, nrRecentFiles, self.distributedObjects) QObject.connect(self.debugController, SIGNAL('executableOpened'), self.RecentFileHandler.addToRecentFiles) def restoreInitialWindowPlacement(self): """ Restores the window placement created by createInitialWindowPlacement(). """ self.restoreGeometry(self.settings.value("InitialWindowPlacement/geometry").toByteArray()) self.restoreState(self.settings.value("InitialWindowPlacement/windowState").toByteArray()) def showOpenExecutableDialog(self): filename = str(QFileDialog.getOpenFileName(self, "Open Executable")) if (filename != ""): self.debugController.openExecutable(filename) def showLoadPluginsDialog(self): dialog = QFileDialog() dialog.setNameFilter("*.xml") filename = str(dialog.getOpenFileName(self, "Load plugin configuration")) if (filename != ""): self.pluginloader.getActivePlugins(filename) def showSavePluginsDialog(self): dialog = QFileDialog() dialog.setNameFilter("*.xml") filename = str(dialog.getSaveFileName(self, "Save plugin configuration")) if (filename != ""): self.pluginloader.savePluginInfo(filename) def showExecutableName(self, filename): self.ui.actionSaveSession.setEnabled(True) # enable saving session self.setWindowFilePath(filename) def targetStartedRunning(self): self.ui.statusLabel.setText("Running") self.ui.statusIcon.setPixmap(QPixmap(":/icons/images/inferior_running.png")) def targetStopped(self, rec): self.ui.statusLabel.setText("Stopped") self.ui.statusIcon.setPixmap(QPixmap(":/icons/images/inferior_stopped.png")) def targetExited(self): self.ui.statusLabel.setText("Not running") self.ui.statusIcon.setPixmap(QPixmap(":/icons/images/inferior_not_running.png")) def closeEvent(self, event): if not self.distributedObjects.editorController.closeOpenedFiles(): event.ignore() # closing source files may be canceled by user else: self.settings.setValue("geometry", self.saveGeometry()) self.settings.setValue("windowState", self.saveState()) QMainWindow.closeEvent(self, event) self.pluginloader.savePluginInfo() def readSettings(self): self.restoreGeometry(self.settings.value("geometry").toByteArray()) self.restoreState(self.settings.value("windowState").toByteArray())
class MainWindow(QMainWindow): def __init__(self, parent=None): """ init UI """ QMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.dockToolBarManager = DockToolBarManager(self) self.dockToolBar(Qt.TopToolBarArea) self.__bottomDockBar = self.dockToolBar(Qt.BottomToolBarArea) self.dockToolBar(Qt.LeftToolBarArea) self.dockToolBar(Qt.RightToolBarArea) self.ui.actionSaveSession.setEnabled(False) self.do = DistributedObjects(self) self.act = self.do.actions self.debugController = self.do.debugController self.settings = self.do.settings self.signalproxy = self.do.signalProxy self.pluginloader = PluginLoader(self.do) self.act = self.do.actions # init RecentFileHandler self.recentFileHandler = RecentFileHandler(self, self.ui.menuRecentlyUsedFiles, self.do) self.debugController.executableOpened.connect(self.recentFileHandler.addToRecentFiles) self.debugController.executableOpened.connect(self.showExecutableName) self.debugController.executableOpened.connect(self.disableButtons) # signal proxy self.signalproxy.inferiorIsRunning.connect(self.targetStartedRunning) self.signalproxy.inferiorStoppedNormally.connect(self.targetStopped) self.signalproxy.inferiorReceivedSignal.connect(self.targetStopped) self.signalproxy.inferiorHasExited.connect(self.targetExited) self.signalproxy.recordStateChanged.connect(self.setReverseDebugButtonsState) # Plugin Loader self.pluginloader.insertPluginAction.connect(self.addPluginAction) self.ui.actionSavePlugins.triggered.connect(self.showSavePluginsDialog) self.ui.actionLoadPlugins.triggered.connect(self.showLoadPluginsDialog) dw = self.insertDockWidget(None, "Log View", Qt.BottomDockWidgetArea, True) self.logviewhandler = LogViewHandler(dw) dw.setWidget(self.logviewhandler) self.notificationFrameHandler = NotificationFrameHandler(self.ui.notificationArea) self.pluginloader.addAvailablePlugins() self.setWindowFilePath("<none>") self.setupUi() self.readSettings() self.quickwatch = QuickWatch(self, self.do) def __makeRunWithArgumentsMenu(self): self.__runWithArgumentsMenu = QMenu(self) self.__argumentsEdit = QLineEdit() self.__argumentsEdit.returnPressed.connect(self.__runWithArgumentsTriggered) hl = QHBoxLayout(self.__runWithArgumentsMenu) hl.addWidget(QLabel("Run with arguments:")) hl.addWidget(self.__argumentsEdit) w = QWidget(self.__runWithArgumentsMenu) w.setLayout(hl) wa = QWidgetAction(self.__runWithArgumentsMenu) wa.setDefaultWidget(w) self.__runWithArgumentsMenu.addAction(wa) self.act.Run.setMenu(self.__runWithArgumentsMenu) def __runWithArgumentsTriggered(self): self.__runWithArgumentsMenu.close() self.debugController.run(str(self.__argumentsEdit.text())) def setupUi(self): self.__initActions() self.ui.statusLabel = QLabel() self.ui.statusLabel.setText("Not running") self.ui.statusbar.addPermanentWidget(self.ui.statusLabel) self.ui.statusIcon = QLabel() self.ui.statusIcon.setPixmap(QPixmap(":/icons/images/22x22/not_running.png")) self.ui.statusbar.addPermanentWidget(self.ui.statusIcon) def __initActions(self): self.disableButtons() self.act.Record.setCheckable(True) self.act.ReverseNext.setEnabled(False) self.act.ReverseStep.setEnabled(False) self.act.ReverseFinish.setEnabled(False) self.act.SaveFile.setEnabled(False) # debug actions self.ui.menuDebug.addAction(self.act.Run) self.ui.menuDebug.addAction(self.act.Continue) self.ui.menuDebug.addAction(self.act.Interrupt) self.ui.menuDebug.addAction(self.act.Next) self.ui.menuDebug.addAction(self.act.Step) self.ui.menuDebug.addAction(self.act.Finish) self.ui.menuDebug.addAction(self.act.RunToCursor) self.ui.menuDebug.addAction(self.act.Record) self.ui.menuDebug.addAction(self.act.ReverseNext) self.ui.menuDebug.addAction(self.act.ReverseStep) # file actions self.ui.menuFile.insertAction(self.ui.actionSaveSession, self.act.OpenMenu) self.ui.menuFile.addAction(self.act.SaveFile) self.ui.menuFile.addAction(self.act.Exit) # add them to menubar and also menuView to respect order self.ui.menubar.addAction(self.ui.menuFile.menuAction()) self.ui.menubar.addAction(self.ui.menuView.menuAction()) self.ui.menubar.addAction(self.ui.menuDebug.menuAction()) self.ui.menubar.addAction(self.ui.menuHelp.menuAction()) # now make toolbar actions self.act.Open.setMenu(self.ui.menuRecentlyUsedFiles) self.ui.Main.addAction(self.act.Open) self.ui.Main.addAction(self.act.SaveFile) self.ui.Main.addSeparator() self.__makeRunWithArgumentsMenu() self.ui.Main.addAction(self.act.Run) self.ui.Main.addAction(self.act.Continue) self.ui.Main.addAction(self.act.Interrupt) self.ui.Main.addAction(self.act.Next) self.ui.Main.addAction(self.act.Step) self.ui.reverseBar.addAction(self.act.Record) self.ui.reverseBar.addAction(self.act.ReverseNext) self.ui.reverseBar.addAction(self.act.ReverseStep) self.ui.reverseBar.addAction(self.act.ReverseFinish) self.ui.Main.addAction(self.act.Finish) self.ui.Main.addAction(self.act.RunToCursor) self.ui.Main.addSeparator() self.ui.Main.addAction(self.act.Exit) # connect actions self.__connectActions() def __connectActions(self): self.ui.actionRestoreSession.triggered.connect( self.do.sessionManager.showRestoreSessionDialog) self.ui.actionSaveSession.triggered.connect( self.do.sessionManager.showSaveSessionDialog) self.ui.actionConfigure.triggered.connect(self.do.configStore.edit) def insertDockWidget(self, widget, name, area, addToggleViewAction, icon=None): d = AlertableDockWidget(name, self) d.setObjectName(name) if widget: d.setWidget(widget) if icon: d.setWindowIcon(icon) self.dockToolBar(self.dockToolBarManager.dockWidgetAreaToToolBarArea(area)).addDock(d) if addToggleViewAction: self.ui.menuShow_View.addAction(d.toggleViewAction()) return d def insertStatusbarWidget(self, widget): w = QFrame() w.setLayout(QHBoxLayout()) w.layout().addWidget(widget) f = QFrame() f.setFrameStyle(QFrame.Plain | QFrame.VLine) w.layout().addWidget(f) self.ui.statusbar.insertPermanentWidget(0, w) return w def removeStatusbarWidget(self, widget): self.ui.statusbar.removeWidget(widget) def addPluginAction(self, Action): """ show plugin as menu entry """ self.ui.menuPlugins.addAction(Action) def showOpenExecutableDialog(self): filename = str(QFileDialog.getOpenFileName(self, "Open Executable", self.recentFileHandler.getDirOfLastFile())) if filename != "": self.debugController.openExecutable(filename) def showLoadPluginsDialog(self): dialog = QFileDialog() dialog.setNameFilter("*.xml") filename = str(dialog.getOpenFileName(self, "Load plugin configuration")) if filename != "": self.pluginloader.getActivePlugins(filename) def showSavePluginsDialog(self): dialog = QFileDialog() dialog.setNameFilter("*.xml") filename = str(dialog.getSaveFileName(self, "Save plugin configuration")) if filename != "": self.pluginloader.savePluginInfo(filename) def showExecutableName(self, filename): self.ui.actionSaveSession.setEnabled(True) # enable saving session self.setWindowFilePath(filename) def targetStartedRunning(self): self.ui.statusLabel.setText("Running") self.ui.statusIcon.setPixmap(QPixmap(":/icons/images/22x22/running.png")) self.disableButtons() self.act.Interrupt.setEnabled(True) def targetStopped(self, _): self.ui.statusLabel.setText("Stopped") self.ui.statusIcon.setPixmap(QPixmap(":/icons/images/22x22/stopped.png")) self.enableButtons() self.act.Interrupt.setEnabled(False) def targetExited(self): self.ui.statusLabel.setText("Not running") self.disableButtons() self.ui.statusIcon.setPixmap(QPixmap(":/icons/images/22x22/not_running.png")) logging.info("Inferior exited.") def closeEvent(self, event): if not self.do.editorController.closeOpenedFiles(): event.ignore() # closing source files may be canceled by user else: self.settings.setValue("geometry", self.saveGeometry()) self.settings.setValue("windowState", self.saveState()) self.dockToolBarManager.saveState(self.settings) QMainWindow.closeEvent(self, event) self.pluginloader.savePluginInfo() def readSettings(self): self.restoreGeometry(self.settings.value("geometry")) self.restoreState(self.settings.value("windowState")) self.dockToolBarManager.restoreState(self.settings) def setReverseDebugButtonsState(self, check): self.act.ReverseNext.setEnabled(check) self.act.ReverseStep.setEnabled(check) self.act.ReverseFinish.setEnabled(check) def enableButtons(self): self.act.Continue.setEnabled(True) self.act.Interrupt.setEnabled(True) self.act.Next.setEnabled(True) self.act.Step.setEnabled(True) self.act.Finish.setEnabled(True) self.act.RunToCursor.setEnabled(True) self.act.Record.setEnabled(True) def disableButtons(self): self.act.Continue.setEnabled(False) self.act.Interrupt.setEnabled(False) self.act.Next.setEnabled(False) self.act.Step.setEnabled(False) self.act.Finish.setEnabled(False) self.act.RunToCursor.setEnabled(False) self.act.Record.setChecked(False) self.act.Record.setEnabled(False) def dockToolBar(self, area): return self.dockToolBarManager.bar(area)
class MainWindow(QMainWindow): def __init__(self, parent=None): """ init UI """ QMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.actionSaveSession.setEnabled(False) self.distributedObjects = DistributedObjects(self) self.act = self.distributedObjects.actions self.debugController = self.distributedObjects.debugController self.settings = self.distributedObjects.settings self.signalproxy = self.distributedObjects.signalProxy self.pluginloader = PluginLoader(self.distributedObjects) self.editorController = self.distributedObjects.editorController self.act = self.distributedObjects.actions # init RecentFileHandler self.recentFileHandler = RecentFileHandler(self, self.ui.menuRecentlyUsedFiles, self.distributedObjects) self.debugController.executableOpened.connect(self.recentFileHandler.addToRecentFiles) self.debugController.executableOpened.connect(self.__observeWorkingBinary) self.debugController.executableOpened.connect(self.showExecutableName) self.debugController.executableOpened.connect(self.disableButtons) # signal proxy self.signalproxy.inferiorIsRunning.connect(self.targetStartedRunning) self.signalproxy.inferiorStoppedNormally.connect(self.targetStopped) self.signalproxy.inferiorReceivedSignal.connect(self.targetStopped) self.signalproxy.inferiorHasExited.connect(self.targetExited) # Plugin Loader self.pluginloader.insertPluginAction.connect(self.addPluginAction) self.ui.actionSavePlugins.triggered.connect(self.showSavePluginsDialog) self.ui.actionLoadPlugins.triggered.connect(self.showLoadPluginsDialog) # Add editor to main window. self.ui.gridLayout.addWidget(self.distributedObjects.editorController.editor_view, 0, 0, 1, 1) self.pluginloader.addAvailablePlugins() self.setWindowFilePath("<none>") self.setupUi() self.readSettings() self.quickwatch = QuickWatch(self, self.distributedObjects) self.binaryName = None self.fileWatcher = QFileSystemWatcher() self.fileWatcher.fileChanged.connect(self.__binaryChanged) self.__runWithArgumentsMenu = None self.__argumentsEdit = None self.__makeRunWithArgumentsMenu() def __makeRunWithArgumentsMenu(self): self.__runWithArgumentsMenu = QMenu(self) self.__argumentsEdit = QLineEdit() self.__argumentsEdit.returnPressed.connect(self.__runWithArgumentsTriggered) hl = QHBoxLayout(self.__runWithArgumentsMenu) hl.addWidget(QLabel("Run with arguments:")) hl.addWidget(self.__argumentsEdit) w = QWidget(self.__runWithArgumentsMenu) w.setLayout(hl) wa = QWidgetAction(self.__runWithArgumentsMenu) wa.setDefaultWidget(w) self.__runWithArgumentsMenu.addAction(wa) self.act.Run.setMenu(self.__runWithArgumentsMenu) def __runTriggered(self): self.debugController.run() def __runWithArgumentsTriggered(self): self.__runWithArgumentsMenu.close() self.debugController.run(str(self.__argumentsEdit.text())) def setupUi(self): self.__initActions() self.ui.statusLabel = QLabel() self.ui.statusLabel.setText("Not running") self.ui.statusbar.addPermanentWidget(self.ui.statusLabel) self.ui.statusIcon = QLabel() self.ui.statusIcon.setPixmap(QPixmap(":/icons/images/22x22/not_running.png")) self.ui.statusbar.addPermanentWidget(self.ui.statusIcon) def __initActions(self): self.disableButtons() self.act.Record.setCheckable(True) self.act.ReverseNext.setEnabled(False) self.act.ReverseStep.setEnabled(False) self.act.SaveFile.setEnabled(False) self.act.Beautify.setCheckable(True) self.act.Beautify.setChecked(True) # debug actions self.ui.menuDebug.addAction(self.act.Run) self.ui.menuDebug.addAction(self.act.Continue) self.ui.menuDebug.addAction(self.act.Interrupt) self.ui.menuDebug.addAction(self.act.Next) self.ui.menuDebug.addAction(self.act.Step) self.ui.menuDebug.addAction(self.act.Finish) self.ui.menuDebug.addAction(self.act.RunToCursor) self.ui.menuDebug.addAction(self.act.Record) self.ui.menuDebug.addAction(self.act.ReverseNext) self.ui.menuDebug.addAction(self.act.ReverseStep) self.ui.menuDebug.addAction(self.act.Beautify) # file actions self.ui.menuFile.insertAction(self.ui.actionSaveSession, self.act.OpenMenu) self.ui.menuFile.addAction(self.act.SaveFile) self.ui.menuFile.addAction(self.act.Exit) # add them to menubar and also menuView to respect order self.ui.menubar.addAction(self.ui.menuFile.menuAction()) self.ui.menubar.addAction(self.ui.menuView.menuAction()) self.ui.menubar.addAction(self.ui.menuDebug.menuAction()) self.ui.menubar.addAction(self.ui.menuHelp.menuAction()) # now make toolbar actions self.act.Open.setMenu(self.ui.menuRecentlyUsedFiles) self.ui.Main.addAction(self.act.Open) self.ui.Main.addAction(self.act.SaveFile) self.ui.Main.addSeparator() self.ui.Main.addAction(self.act.Run) self.ui.Main.addAction(self.act.Continue) self.ui.Main.addAction(self.act.Interrupt) self.ui.Main.addAction(self.act.Next) self.ui.Main.addAction(self.act.Step) self.ui.Main.addAction(self.act.Record) self.ui.Main.addAction(self.act.ReverseNext) self.ui.Main.addAction(self.act.ReverseStep) self.ui.Main.addAction(self.act.Finish) self.ui.Main.addAction(self.act.RunToCursor) self.ui.Main.addAction(self.act.Beautify) self.ui.Main.addSeparator() self.ui.Main.addAction(self.act.Exit) # connect actions self.__connectActions() def __connectActions(self): # file menu self.act.Open.triggered.connect(self.showOpenExecutableDialog) self.act.OpenMenu.triggered.connect(self.showOpenExecutableDialog) self.act.Exit.triggered.connect(self.close) self.act.SaveFile.triggered.connect(self.signalproxy.emitSaveCurrentFile) # debug menu self.act.Run.triggered.connect(self.__runTriggered) self.act.Next.triggered.connect(self.debugController.next_) self.act.Step.triggered.connect(self.debugController.step) self.act.Continue.triggered.connect(self.debugController.cont) self.act.Record.triggered.connect(self.toggleRecord) self.act.ReverseStep.triggered.connect(self.debugController.reverse_step) self.act.ReverseNext.triggered.connect(self.debugController.reverse_next) self.act.Beautify.triggered.connect(self.__askBeautify) self.act.Interrupt.triggered.connect(self.debugController.interrupt) self.act.Finish.triggered.connect(self.debugController.finish) self.act.RunToCursor.triggered.connect(self.debugController.inferiorUntil) self.ui.actionRestoreSession.triggered.connect(self.distributedObjects.sessionManager.showRestoreSessionDialog) self.ui.actionSaveSession.triggered.connect(self.distributedObjects.sessionManager.showSaveSessionDialog) self.ui.actionConfigure.triggered.connect(self.distributedObjects.configStore.edit) def insertDockWidget(self, widget, name, area, addToggleViewAction): d = AlertableDockWidget(name, self) d.setObjectName(name) d.setWidget(widget) self.addDockWidget(area, d) if addToggleViewAction: self.ui.menuShow_View.addAction(d.toggleViewAction()) return d def insertStatusbarWidget(self, widget): w = QFrame() w.setLayout(QHBoxLayout()) w.layout().addWidget(widget) f = QFrame() f.setFrameStyle(QFrame.Plain | QFrame.VLine) w.layout().addWidget(f) self.ui.statusbar.insertPermanentWidget(0, w) return w def removeStatusbarWidget(self, widget): self.ui.statusbar.removeWidget(widget) def addPluginAction(self, Action): """ show plugin as menu entry """ self.ui.menuPlugins.addAction(Action) def showOpenExecutableDialog(self): filename = str(QFileDialog.getOpenFileName(self, "Open Executable", self.recentFileHandler.getDirOfLastFile())) if filename != "": self.debugController.openExecutable(filename) def showLoadPluginsDialog(self): dialog = QFileDialog() dialog.setNameFilter("*.xml") filename = str(dialog.getOpenFileName(self, "Load plugin configuration")) if filename != "": self.pluginloader.getActivePlugins(filename) def showSavePluginsDialog(self): dialog = QFileDialog() dialog.setNameFilter("*.xml") filename = str(dialog.getSaveFileName(self, "Save plugin configuration")) if filename != "": self.pluginloader.savePluginInfo(filename) def showExecutableName(self, filename): self.ui.actionSaveSession.setEnabled(True) # enable saving session self.setWindowFilePath(filename) def targetStartedRunning(self): self.ui.statusLabel.setText("Running") self.ui.statusIcon.setPixmap(QPixmap(":/icons/images/22x22/running.png")) self.disableButtons() self.act.Interrupt.setEnabled(True) def targetStopped(self, rec): self.ui.statusLabel.setText("Stopped") self.ui.statusIcon.setPixmap(QPixmap(":/icons/images/22x22/stopped.png")) self.enableButtons() self.act.Interrupt.setEnabled(False) def targetExited(self): self.ui.statusLabel.setText("Not running") self.disableButtons() self.ui.statusIcon.setPixmap(QPixmap(":/icons/images/22x22/not_running.png")) def closeEvent(self, event): if not self.distributedObjects.editorController.closeOpenedFiles(): event.ignore() # closing source files may be canceled by user else: self.settings.setValue("geometry", self.saveGeometry()) self.settings.setValue("windowState", self.saveState()) QMainWindow.closeEvent(self, event) self.pluginloader.savePluginInfo() def readSettings(self): self.restoreGeometry(self.settings.value("geometry").toByteArray()) self.restoreState(self.settings.value("windowState").toByteArray()) def toggleRecord(self, check): if check: self.debugController.record_start() self.act.ReverseNext.setEnabled(True) self.act.ReverseStep.setEnabled(True) else: self.debugController.record_stop() self.act.ReverseNext.setEnabled(False) self.act.ReverseStep.setEnabled(False) def enableButtons(self): self.act.Continue.setEnabled(True) self.act.Interrupt.setEnabled(True) self.act.Next.setEnabled(True) self.act.Step.setEnabled(True) self.act.Finish.setEnabled(True) self.act.RunToCursor.setEnabled(True) self.act.Record.setEnabled(True) self.act.Beautify.setEnabled(True) def disableButtons(self): self.act.Continue.setEnabled(False) self.act.Interrupt.setEnabled(False) self.act.Next.setEnabled(False) self.act.Step.setEnabled(False) self.act.Finish.setEnabled(False) self.act.RunToCursor.setEnabled(False) self.act.Record.setChecked(False) self.act.Record.setEnabled(False) self.act.Beautify.setEnabled(False) def __observeWorkingBinary(self, filename): """ Private Method to Observe Debugged Binary """ if self.binaryName != None: self.fileWatcher.removePath(self.binaryName) self.fileWatcher.addPath(filename) self.binaryName = filename def __binaryChanged(self): """ Slot for FileWatcher - Using QtMessagebox for interaction""" box = QtGui.QMessageBox() if ( box.question(self, "Binary Changed!", "Reload File?", QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) == QtGui.QMessageBox.Yes ): self.debugController.openExecutable(self.binaryName) else: self.fileWatcher.removePath(self.binaryName) self.fileWatcher.addPath(self.binaryName) def __askBeautify(self): """ Warn user before Beautify - Using QtMessagebox for interaction""" box = QtGui.QMessageBox() if ( box.question( self, "Warning!", "This deletes the objects in watch and datagraphview.", QtGui.QMessageBox.Ok, QtGui.QMessageBox.Cancel, ) == QtGui.QMessageBox.Ok ): self.debugController.beautify() else: self.act.Beautify.toggle()
class MainWindow(QMainWindow): def __init__(self, parent=None): """ init UI """ QMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.ui.actionSaveSession.setEnabled(False) self.distributedObjects = DistributedObjects() self.act = self.distributedObjects.actions self.debugController = self.distributedObjects.debugController self.settings = self.debugController.settings self.signalproxy = self.distributedObjects.signalProxy self.pluginloader = PluginLoader(self.distributedObjects) self.editorController = self.distributedObjects.editorController self.act = self.distributedObjects.actions # init RecentFileHandler self.recentFileHandler = RecentFileHandler(self, self.ui.menuRecentlyUsedFiles, self.distributedObjects) self.debugController.executableOpened.connect(self.recentFileHandler.addToRecentFiles) self.debugController.executableOpened.connect(self.__observeWorkingBinary) self.debugController.executableOpened.connect(self.showExecutableName) self.debugController.executableOpened.connect(self.disableButtons) # signal proxy self.signalproxy.inferiorIsRunning.connect(self.targetStartedRunning, Qt.QueuedConnection) self.signalproxy.inferiorStoppedNormally.connect(self.targetStopped, Qt.QueuedConnection) self.signalproxy.inferiorReceivedSignal.connect(self.targetStopped, Qt.QueuedConnection) self.signalproxy.inferiorHasExited.connect(self.targetExited, Qt.QueuedConnection) self.signalproxy.addDockWidget.connect(self.addPluginDockWidget) self.signalproxy.removeDockWidget.connect(self.removeDockWidget) # Plugin Loader self.pluginloader.insertPluginAction.connect(self.addPluginAction) self.ui.actionSavePlugins.triggered.connect(self.showSavePluginsDialog) self.ui.actionLoadPlugins.triggered.connect(self.showLoadPluginsDialog) # Add editor to main window. self.ui.gridLayout.addWidget(self.distributedObjects.editorController.editor_view, 0, 0, 1, 1) self.pluginloader.addAvailablePlugins() # Tell everyone to insert their dock widgets into the main window self.signalproxy.emitInsertDockWidgets() # get filelist dockwidget self.filelist_dockwidget = self.findChild(QDockWidget, "FileListView") self.setWindowFilePath("<none>") self.setupUi() self.createInitialWindowPlacement() self.readSettings() self.quickwatch = QuickWatch(self, self.distributedObjects) self.binaryName = None self.fileWatcher = QFileSystemWatcher() self.fileWatcher.fileChanged.connect(self.__binaryChanged) def setupUi(self): self.__initActions() self.ui.statusLabel = QLabel() self.ui.statusLabel.setText("Not running") self.ui.statusbar.addPermanentWidget(self.ui.statusLabel) self.ui.statusIcon = QLabel() self.ui.statusIcon.setPixmap(QPixmap(":/icons/images/inferior_not_running.png")) self.ui.statusbar.addPermanentWidget(self.ui.statusIcon) def __initActions(self): self.disableButtons() self.act.Record.setCheckable(True) self.act.ReverseNext.setEnabled(False) self.act.ReverseStep.setEnabled(False) self.act.SaveFile.setEnabled(False) # debug actions self.ui.menuDebug.addAction(self.act.Run) self.ui.menuDebug.addAction(self.act.Continue) self.ui.menuDebug.addAction(self.act.Interrupt) self.ui.menuDebug.addAction(self.act.Next) self.ui.menuDebug.addAction(self.act.Step) self.ui.menuDebug.addAction(self.act.Finish) self.ui.menuDebug.addAction(self.act.RunToCursor) self.ui.menuDebug.addAction(self.act.Record) self.ui.menuDebug.addAction(self.act.ReverseNext) self.ui.menuDebug.addAction(self.act.ReverseStep) # file actions self.ui.menuFile.insertAction(self.ui.actionSaveSession, self.act.OpenMenu) self.ui.menuFile.addAction(self.act.SaveFile) self.ui.menuFile.addAction(self.act.Exit) # add them to menubar and also menuView to respect order self.ui.menubar.addAction(self.ui.menuFile.menuAction()) self.ui.menubar.addAction(self.ui.menuView.menuAction()) self.ui.menubar.addAction(self.ui.menuDebug.menuAction()) self.ui.menubar.addAction(self.ui.menuHelp.menuAction()) # now make toolbar actions self.act.Open.setMenu(self.ui.menuRecentlyUsedFiles) self.ui.Main.addAction(self.act.Open) self.ui.Main.addAction(self.act.SaveFile) self.ui.Main.addSeparator() self.ui.Main.addAction(self.act.Run) self.ui.Main.addAction(self.act.Continue) self.ui.Main.addAction(self.act.Interrupt) self.ui.Main.addAction(self.act.Next) self.ui.Main.addAction(self.act.Step) self.ui.Main.addAction(self.act.Record) self.ui.Main.addAction(self.act.ReverseNext) self.ui.Main.addAction(self.act.ReverseStep) self.ui.Main.addAction(self.act.Finish) self.ui.Main.addAction(self.act.RunToCursor) self.ui.Main.addSeparator() self.ui.Main.addAction(self.act.Exit) # connect actions self.__connectActions() def __connectActions(self): # file menu self.act.Open.triggered.connect(self.showOpenExecutableDialog) self.act.OpenMenu.triggered.connect(self.showOpenExecutableDialog) self.act.Exit.triggered.connect(self.close) self.act.SaveFile.triggered.connect(self.signalproxy.emitSaveCurrentFile) # debug menu self.act.Run.triggered.connect(self.debugController.run) self.act.Next.triggered.connect(self.debugController.next_) self.act.Step.triggered.connect(self.debugController.step) self.act.Continue.triggered.connect(self.debugController.cont) self.act.Record.triggered.connect(self.toggleRecord) self.act.ReverseStep.triggered.connect(self.debugController.reverse_step) self.act.ReverseNext.triggered.connect(self.debugController.reverse_next) self.act.Interrupt.triggered.connect(self.debugController.interrupt) self.act.Finish.triggered.connect(self.debugController.finish) self.act.RunToCursor.triggered.connect(self.debugController.inferiorUntil) self.ui.actionRestoreSession.triggered.connect(self.distributedObjects.sessionManager.showRestoreSessionDialog) self.ui.actionSaveSession.triggered.connect(self.distributedObjects.sessionManager.showSaveSessionDialog) def addPluginDockWidget(self, area, widget, addToggleViewAction): self.addDockWidget(area, widget) if addToggleViewAction: self.ui.menuShow_View.addAction(widget.toggleViewAction()) def addPluginAction(self, Action): """ show plugin as menu entry """ self.ui.menuPlugins.addAction(Action) def createInitialWindowPlacement(self): """ Saves the window and widget placement after first start of program. """ # check if settings do not exist initExists = self.settings.contains("InitialWindowPlacement/geometry") if not initExists: self.breakpointWidget = self.findChild(QDockWidget, "BreakpointView") self.fileListWidget = self.findChild(QDockWidget, "FileListView") self.dataGraphWidget = self.findChild(QDockWidget, "DataGraphView") self.watchWidget = self.findChild(QDockWidget, "WatchView") self.localsWidget = self.findChild(QDockWidget, "LocalsView") self.stackWidget = self.findChild(QDockWidget, "StackView") self.tracepointWidget = self.findChild(QDockWidget, "TracepointView") self.gdbIoWidget = self.findChild(QDockWidget, "GdbIoView") self.pyIoWidget = self.findChild(QDockWidget, "PyIoView") self.inferiorIoWidget = self.findChild(QDockWidget, "InferiorIoView") # tabify widgets to initial state and save settings self.tabifyDockWidget(self.fileListWidget, self.dataGraphWidget) self.tabifyDockWidget(self.watchWidget, self.localsWidget) self.tabifyDockWidget(self.localsWidget, self.stackWidget) self.tabifyDockWidget(self.stackWidget, self.breakpointWidget) self.tabifyDockWidget(self.breakpointWidget, self.tracepointWidget) self.tabifyDockWidget(self.gdbIoWidget, self.pyIoWidget) self.tabifyDockWidget(self.pyIoWidget, self.inferiorIoWidget) self.settings.setValue("InitialWindowPlacement/geometry", self.saveGeometry()) self.settings.setValue("InitialWindowPlacement/windowState", self.saveState()) def restoreInitialWindowPlacement(self): """ Restores the window placement created by createInitialWindowPlacement(). """ self.restoreGeometry(self.settings.value("InitialWindowPlacement/geometry").toByteArray()) self.restoreState(self.settings.value("InitialWindowPlacement/windowState").toByteArray()) def showOpenExecutableDialog(self): filename = str(QFileDialog.getOpenFileName(self, "Open Executable", self.recentFileHandler.getDirOfLastFile())) if filename != "": self.debugController.openExecutable(filename) def showLoadPluginsDialog(self): dialog = QFileDialog() dialog.setNameFilter("*.xml") filename = str(dialog.getOpenFileName(self, "Load plugin configuration")) if filename != "": self.pluginloader.getActivePlugins(filename) def showSavePluginsDialog(self): dialog = QFileDialog() dialog.setNameFilter("*.xml") filename = str(dialog.getSaveFileName(self, "Save plugin configuration")) if filename != "": self.pluginloader.savePluginInfo(filename) def showExecutableName(self, filename): self.ui.actionSaveSession.setEnabled(True) # enable saving session self.setWindowFilePath(filename) def targetStartedRunning(self): self.ui.statusLabel.setText("Running") self.ui.statusIcon.setPixmap(QPixmap(":/icons/images/inferior_running.png")) self.enableButtons() def targetStopped(self, rec): self.ui.statusLabel.setText("Stopped") self.ui.statusIcon.setPixmap(QPixmap(":/icons/images/inferior_stopped.png")) def targetExited(self): self.ui.statusLabel.setText("Not running") self.disableButtons() self.ui.statusIcon.setPixmap(QPixmap(":/icons/images/inferior_not_running.png")) def closeEvent(self, event): if not self.distributedObjects.editorController.closeOpenedFiles(): event.ignore() # closing source files may be canceled by user else: self.settings.setValue("geometry", self.saveGeometry()) self.settings.setValue("windowState", self.saveState()) QMainWindow.closeEvent(self, event) self.pluginloader.savePluginInfo() def readSettings(self): self.restoreGeometry(self.settings.value("geometry").toByteArray()) self.restoreState(self.settings.value("windowState").toByteArray()) def toggleRecord(self, check): if check: self.debugController.record_start() self.act.ReverseNext.setEnabled(True) self.act.ReverseStep.setEnabled(True) else: self.debugController.record_stop() self.act.ReverseNext.setEnabled(False) self.act.ReverseStep.setEnabled(False) def enableButtons(self): self.act.Continue.setEnabled(True) self.act.Interrupt.setEnabled(True) self.act.Next.setEnabled(True) self.act.Step.setEnabled(True) self.act.Finish.setEnabled(True) self.act.RunToCursor.setEnabled(True) self.act.Record.setEnabled(True) def disableButtons(self): self.act.Continue.setEnabled(False) self.act.Interrupt.setEnabled(False) self.act.Next.setEnabled(False) self.act.Step.setEnabled(False) self.act.Finish.setEnabled(False) self.act.RunToCursor.setEnabled(False) self.act.Record.setChecked(False) self.act.Record.setEnabled(False) def __observeWorkingBinary(self, filename): """ Private Method to Observe Debugged Binary """ if self.binaryName != None: self.fileWatcher.removePath(self.binaryName) self.fileWatcher.addPath(filename) self.binaryName = filename def __binaryChanged(self): """ Slot for FileWatcher - Using QtMessagebox for interaction""" box = QtGui.QMessageBox() if ( box.question(self, "Binary Changed!", "Reload File?", QtGui.QMessageBox.Yes, QtGui.QMessageBox.No) == QtGui.QMessageBox.Yes ): self.debugController.openExecutable(self.binaryName) else: self.fileWatcher.removePath(self.binaryName) self.fileWatcher.addPath(self.binaryName)
class MainWindow(QMainWindow): def __init__(self, parent=None): """ init UI """ QMainWindow.__init__(self, parent) self.ui = Ui_MainWindow() self.ui.setupUi(self) self.dockToolBarManager = DockToolBarManager(self) self.dockToolBar(Qt.TopToolBarArea) self.__bottomDockBar = self.dockToolBar(Qt.BottomToolBarArea) self.dockToolBar(Qt.LeftToolBarArea) self.dockToolBar(Qt.RightToolBarArea) self.ui.actionSaveSession.setEnabled(False) self.do = DistributedObjects(self) self.act = self.do.actions self.debugController = self.do.debugController self.settings = self.do.settings self.signalproxy = self.do.signalProxy self.pluginloader = PluginLoader(self.do) self.act = self.do.actions # init RecentFileHandler self.recentFileHandler = RecentFileHandler(self, self.ui.menuRecentlyUsedFiles, self.do) self.debugController.executableOpened.connect(self.recentFileHandler.addToRecentFiles) self.debugController.executableOpened.connect(self.showExecutableName) self.debugController.executableOpened.connect(self.disableButtons) # signal proxy self.signalproxy.inferiorIsRunning.connect(self.targetStartedRunning) self.signalproxy.inferiorStoppedNormally.connect(self.targetStopped) self.signalproxy.inferiorReceivedSignal.connect(self.targetStopped) self.signalproxy.inferiorHasExited.connect(self.targetExited) self.signalproxy.recordStateChanged.connect(self.setReverseDebugButtonsState) # Plugin Loader self.pluginloader.insertPluginAction.connect(self.addPluginAction) self.ui.actionSavePlugins.triggered.connect(self.showSavePluginsDialog) self.ui.actionLoadPlugins.triggered.connect(self.showLoadPluginsDialog) dw = self.insertDockWidget(None, "Log View", Qt.BottomDockWidgetArea, True) self.logviewhandler = LogViewHandler(dw) dw.setWidget(self.logviewhandler) self.notificationFrameHandler = NotificationFrameHandler(self.ui.notificationArea) self.pluginloader.addAvailablePlugins() self.setWindowFilePath("<none>") self.setupUi() self.readSettings() self.quickwatch = QuickWatch(self, self.do) def __makeRunWithArgumentsMenu(self): self.__runWithArgumentsMenu = QMenu(self) self.__argumentsEdit = QLineEdit() self.__argumentsEdit.returnPressed.connect(self.__runWithArgumentsTriggered) hl = QHBoxLayout(self.__runWithArgumentsMenu) hl.addWidget(QLabel("Run with arguments:")) hl.addWidget(self.__argumentsEdit) w = QWidget(self.__runWithArgumentsMenu) w.setLayout(hl) wa = QWidgetAction(self.__runWithArgumentsMenu) wa.setDefaultWidget(w) self.__runWithArgumentsMenu.addAction(wa) self.act.Run.setMenu(self.__runWithArgumentsMenu) def __runWithArgumentsTriggered(self): self.__runWithArgumentsMenu.close() self.debugController.run(str(self.__argumentsEdit.text())) def setupUi(self): self.__initActions() self.ui.statusLabel = QLabel() self.ui.statusLabel.setText("Not running") self.ui.statusbar.addPermanentWidget(self.ui.statusLabel) self.ui.statusIcon = QLabel() self.ui.statusIcon.setPixmap(QPixmap(":/icons/images/22x22/not_running.png")) self.ui.statusbar.addPermanentWidget(self.ui.statusIcon) def __initActions(self): self.disableButtons() self.act.Record.setCheckable(True) self.act.ReverseNext.setEnabled(False) self.act.ReverseStep.setEnabled(False) self.act.ReverseFinish.setEnabled(False) self.act.SaveFile.setEnabled(False) # debug actions self.ui.menuDebug.addAction(self.act.Run) self.ui.menuDebug.addAction(self.act.Continue) self.ui.menuDebug.addAction(self.act.Interrupt) self.ui.menuDebug.addAction(self.act.Next) self.ui.menuDebug.addAction(self.act.Step) self.ui.menuDebug.addAction(self.act.Finish) self.ui.menuDebug.addAction(self.act.RunToCursor) self.ui.menuDebug.addAction(self.act.Record) self.ui.menuDebug.addAction(self.act.ReverseNext) self.ui.menuDebug.addAction(self.act.ReverseStep) # file actions self.ui.menuFile.insertAction(self.ui.actionSaveSession, self.act.OpenMenu) self.ui.menuFile.addAction(self.act.SaveFile) self.ui.menuFile.addAction(self.act.Exit) # add them to menubar and also menuView to respect order self.ui.menubar.addAction(self.ui.menuFile.menuAction()) self.ui.menubar.addAction(self.ui.menuView.menuAction()) self.ui.menubar.addAction(self.ui.menuDebug.menuAction()) self.ui.menubar.addAction(self.ui.menuHelp.menuAction()) # now make toolbar actions self.act.Open.setMenu(self.ui.menuRecentlyUsedFiles) self.ui.Main.addAction(self.act.Open) self.ui.Main.addAction(self.act.SaveFile) self.ui.Main.addSeparator() self.__makeRunWithArgumentsMenu() self.ui.Main.addAction(self.act.Run) self.ui.Main.addAction(self.act.Continue) self.ui.Main.addAction(self.act.Interrupt) self.ui.Main.addAction(self.act.Next) self.ui.Main.addAction(self.act.Step) self.ui.reverseBar.addAction(self.act.Record) self.ui.reverseBar.addAction(self.act.ReverseNext) self.ui.reverseBar.addAction(self.act.ReverseStep) self.ui.reverseBar.addAction(self.act.ReverseFinish) self.ui.Main.addAction(self.act.Finish) self.ui.Main.addAction(self.act.RunToCursor) self.ui.Main.addSeparator() self.ui.Main.addAction(self.act.Exit) # connect actions self.__connectActions() def __connectActions(self): self.ui.actionRestoreSession.triggered.connect( self.do.sessionManager.showRestoreSessionDialog) self.ui.actionSaveSession.triggered.connect( self.do.sessionManager.showSaveSessionDialog) self.ui.actionConfigure.triggered.connect(self.do.configStore.edit) def insertDockWidget(self, widget, name, area, addToggleViewAction, icon=None): d = AlertableDockWidget(name, self) d.setObjectName(name) if widget: d.setWidget(widget) if icon: d.setWindowIcon(icon) self.dockToolBar(self.dockToolBarManager.dockWidgetAreaToToolBarArea(area)).addDock(d) if addToggleViewAction: self.ui.menuShow_View.addAction(d.toggleViewAction()) return d def insertStatusbarWidget(self, widget): w = QFrame() w.setLayout(QHBoxLayout()) w.layout().addWidget(widget) f = QFrame() f.setFrameStyle(QFrame.Plain | QFrame.VLine) w.layout().addWidget(f) self.ui.statusbar.insertPermanentWidget(0, w) return w def removeStatusbarWidget(self, widget): self.ui.statusbar.removeWidget(widget) def addPluginAction(self, Action): """ show plugin as menu entry """ self.ui.menuPlugins.addAction(Action) def showOpenExecutableDialog(self): filename = str(QFileDialog.getOpenFileName(self, "Open Executable", self.recentFileHandler.getDirOfLastFile())) if filename != "": self.debugController.openExecutable(filename) def showLoadPluginsDialog(self): dialog = QFileDialog() dialog.setNameFilter("*.xml") filename = str(dialog.getOpenFileName(self, "Load plugin configuration")) if filename != "": self.pluginloader.getActivePlugins(filename) def showSavePluginsDialog(self): dialog = QFileDialog() dialog.setNameFilter("*.xml") filename = str(dialog.getSaveFileName(self, "Save plugin configuration")) if filename != "": self.pluginloader.savePluginInfo(filename) def showExecutableName(self, filename): self.ui.actionSaveSession.setEnabled(True) # enable saving session self.setWindowFilePath(filename) def targetStartedRunning(self): self.ui.statusLabel.setText("Running") self.ui.statusIcon.setPixmap(QPixmap(":/icons/images/22x22/running.png")) self.disableButtons() self.act.Interrupt.setEnabled(True) def targetStopped(self, _): self.ui.statusLabel.setText("Stopped") self.ui.statusIcon.setPixmap(QPixmap(":/icons/images/22x22/stopped.png")) self.enableButtons() self.act.Interrupt.setEnabled(False) def targetExited(self): self.ui.statusLabel.setText("Not running") self.disableButtons() self.ui.statusIcon.setPixmap(QPixmap(":/icons/images/22x22/not_running.png")) logging.info("Inferior exited.") def closeEvent(self, event): if not self.do.editorController.closeOpenedFiles(): event.ignore() # closing source files may be canceled by user else: self.settings.setValue("geometry", self.saveGeometry()) self.settings.setValue("windowState", self.saveState()) self.dockToolBarManager.saveState(self.settings) QMainWindow.closeEvent(self, event) self.pluginloader.savePluginInfo() def readSettings(self): if self.settings.value("geometry") is not None: self.restoreGeometry(self.settings.value("geometry")) if self.settings.value("windowState") is not None: self.restoreState(self.settings.value("windowState")) self.dockToolBarManager.restoreState(self.settings) def setReverseDebugButtonsState(self, check): self.act.ReverseNext.setEnabled(check) self.act.ReverseStep.setEnabled(check) self.act.ReverseFinish.setEnabled(check) def enableButtons(self): self.act.Continue.setEnabled(True) self.act.Interrupt.setEnabled(True) self.act.Next.setEnabled(True) self.act.Step.setEnabled(True) self.act.Finish.setEnabled(True) self.act.RunToCursor.setEnabled(True) self.act.Record.setEnabled(True) def disableButtons(self): self.act.Continue.setEnabled(False) self.act.Interrupt.setEnabled(False) self.act.Next.setEnabled(False) self.act.Step.setEnabled(False) self.act.Finish.setEnabled(False) self.act.RunToCursor.setEnabled(False) self.act.Record.setChecked(False) self.act.Record.setEnabled(False) def dockToolBar(self, area): return self.dockToolBarManager.bar(area)