def __init__(self, parent=None): ''' Constructor ''' super(MultipleCppEditor, self).__init__(parent) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.DefaultKeywords = getLibraryKeywords() self.findDlg = FindDialog(self) self.setAcceptDrops(True) #self.setTabShape(QtGui.QTabWidget.Triangular) self.setMovable(True) self.setTabsClosable(True) self.sampleProjects = [] try: for group in getExampleProjects(scanFirmwareLibs()): for fname in group[1]: self.sampleProjects.append(fname) # print self.sampleProjects except: pass self.Outline = OutLineView(self) self.connect(self, QtCore.SIGNAL('tabCloseRequested(int)'), self.closeFile) self.connect(self, QtCore.SIGNAL('currentChanged(int)'), self.Outline.update) if self.count() == 0: self.newFile()
def __init__(self, parent=None): ''' Constructor ''' super(MultipleCppEditor, self).__init__(parent) self.setAttribute(QtCore.Qt.WA_DeleteOnClose) self.DefaultKeywords = getLibraryKeywords() self.findDlg = FindDialog(self) self.setAcceptDrops(True) #self.setTabShape(QtGui.QTabWidget.Triangular) self.setMovable(True) self.setTabsClosable(True) self.sampleProjects = [] try: for group in getExampleProjects(scanFirmwareLibs()): for fname in group[1]: self.sampleProjects.append(fname) # print self.sampleProjects except: pass self.Outline = OutLineView(self) self.connect(self, QtCore.SIGNAL('tabCloseRequested(int)'), self.closeFile) self.connect(self, QtCore.SIGNAL('currentChanged(int)'), self.Outline.update) if self.count()==0: self.newFile()
def createActions(self): # file menu self.newAct = QtGui.QAction( QtGui.QIcon("./images/new.png"), "&New", self, shortcut=QtGui.QKeySequence("Ctrl+N"), statusTip="Create a new file", triggered=self.Editor.newFile) self.openAct = QtGui.QAction(QtGui.QIcon("./images/open.png"), "&Open...", self, shortcut=QtGui.QKeySequence("Ctrl+O"), statusTip="Open an existing file") self.openAct.triggered.connect( functools.partial(self.Editor.openFile, None) ) self.closeAct = QtGui.QAction("&Close", self, shortcut=QtGui.QKeySequence("Ctrl+W"), statusTip="Close the current window", triggered=self.Editor.closeCurrentFile) self.saveAct = QtGui.QAction(QtGui.QIcon("./images/save.png"), "&Save", self, shortcut=QtGui.QKeySequence("Ctrl+S"), statusTip="Save the current file", triggered=self.Editor.saveFile) self.saveAsAct = QtGui.QAction("Save &As...", self, shortcut=QtGui.QKeySequence("Ctrl+Shift+S"), statusTip="Save to another file", triggered=self.Editor.saveFileAs) self.exitAct = QtGui.QAction("E&xit", self, shortcut=QtGui.QKeySequence("Alt+F4"), statusTip="Exit the application", triggered=QtGui.qApp.closeAllWindows) # edit menu self.editUndoAct = QtGui.QAction("&Undo", self, shortcut=QtGui.QKeySequence("Ctrl+Z"), triggered=self.Editor.editUndo) self.editRedoAct = QtGui.QAction("&Redo", self, shortcut=QtGui.QKeySequence("Ctrl+Y"), triggered=self.Editor.editRedo) self.editCutAct = QtGui.QAction("Cu&t", self, shortcut=QtGui.QKeySequence("Ctrl+X"), triggered=self.Editor.editCut) self.editCopyAct = QtGui.QAction("&Copy", self, shortcut=QtGui.QKeySequence("Ctrl+C"), triggered=self.Editor.editCopy) self.editPasteAct = QtGui.QAction("&Paste", self, shortcut=QtGui.QKeySequence("Ctrl+V"), triggered=self.Editor.editPaste) self.editSelectAllAct = QtGui.QAction("Select &All", self, shortcut=QtGui.QKeySequence("Ctrl+A"), triggered=self.Editor.editSelectAll) self.editClearAct = QtGui.QAction("Clear", self, triggered=self.Editor.editClear) # find/replace self.findAct = QtGui.QAction("&Find/Replace...", self, shortcut=QtGui.QKeySequence("Ctrl+F"), statusTip="Find/Replace texts", triggered=self.Editor.showFindDialog) # project menu self.compileAct = QtGui.QAction(QtGui.QIcon("./images/build.png"), "&Compile", self, shortcut=QtGui.QKeySequence("Ctrl+B"), statusTip="Build the current project", triggered=self.startBuild) self.stopAct = QtGui.QAction(QtGui.QIcon("./images/stop.png"), "S&top", self, statusTip="Cancel the build process", triggered=self.stopBuild) self.programAct = QtGui.QAction(QtGui.QIcon("./images/load.png"), "&Load", self, shortcut=QtGui.QKeySequence("Ctrl+R"), statusTip="Download program to the board using bootloader", triggered=self.programChip) self.firmwareLibList = scanFirmwareLibs() self.firmwareLibActs = [] if len(self.firmwareLibList): for i in range(len(self.firmwareLibList)): self.firmwareLibActs.append( QtGui.QAction(self.firmwareLibList[i], self, statusTip="include " + self.firmwareLibList[i] + " library" ) ) self.exampleProjects = getExampleProjects(self.firmwareLibList) self.exampleFolderMenus = [] self.openExampleActs = [] for group in self.exampleProjects: folder, files = group[0], group[1] self.exampleFolderMenus.append(QtGui.QMenu(str(folder), self)) for fname in files: baseName = os.path.basename(fname) self.openExampleActs.append(QtGui.QAction(os.path.splitext(baseName)[0], self, statusTip = 'Open "' + str(fname).replace('\\', '/') + '"') ) # serial monitor/terminal window self.serialMonitorAct = QtGui.QAction(QtGui.QIcon("./images/serial.png"), "Serial &Monitor", self, shortcut=QtGui.QKeySequence("Ctrl+Shift+M"), statusTip="Launch Serial Monitor Dialog", triggered=self.openSerialPortMonitorDialog) self.serialPortGroup = QtGui.QActionGroup(self) self.serialPortList = scan_serialports() self.serialPortActs = [] if len(self.serialPortList): for i in range(len(self.serialPortList)): self.serialPortActs.append( QtGui.QAction(self.serialPortList[i], self, checkable=True, statusTip="select " + self.serialPortList[i] + " serial port", triggered=self.selectSerialPort) ) self.serialPortGroup.addAction( self.serialPortActs[i] ) # todo: board names?? #self.boardAnitoAct = QtGui.QAction("PhilRobokit &Anito", self, # checkable=True, statusTip="Select PhilRobokit Anito board" ) self.boardStellarisAct = QtGui.QAction("EK-&LM4F120XL", self, checkable=True, statusTip="Select TI Stellaris LM4F120 LaunchPad" ) self.boardGroup = QtGui.QActionGroup(self) #self.boardGroup.addAction(self.boardAnitoAct) self.boardGroup.addAction(self.boardStellarisAct) self.boardStellarisAct.setChecked(True) self.restoreDefaultsAct = QtGui.QAction("Restore Defaults", self, statusTip="Clear configuration files", triggered=self.Configs.setDefaults) # help menu self.aboutAct = QtGui.QAction("&About", self, shortcut=QtGui.QKeySequence("F1"), statusTip="About the IDE", triggered=self.about) self.aboutCompilerAct = QtGui.QAction("About &Compiler", self, statusTip="About GNU tools for ARM Embedded", triggered=self.aboutCompiler) self.aboutQtAct = QtGui.QAction("About &Qt", self, statusTip="Show the Qt library's About box", triggered=QtGui.qApp.aboutQt) self.visitProjectprotoSiteAct = QtGui.QAction("Visit &ProjectProto", self, statusTip="Open ProjectProto blog site (yus' projects)", triggered=self.openProjectProtoSite) self.visitPhilroboticsSiteAct = QtGui.QAction("Visit Phil&Robotics", self, statusTip="Open PhilRobotics website", triggered=self.openPhilRoboticsSite)
def createActions(self): # file menu self.newAct = QtGui.QAction(QtGui.QIcon("./images/new.png"), "&New", self, shortcut=QtGui.QKeySequence("Ctrl+N"), statusTip="Create a new file", triggered=self.Editor.newFile) self.openAct = QtGui.QAction(QtGui.QIcon("./images/open.png"), "&Open...", self, shortcut=QtGui.QKeySequence("Ctrl+O"), statusTip="Open an existing file") self.openAct.triggered.connect( functools.partial(self.Editor.openFile, None)) self.closeAct = QtGui.QAction("&Close", self, shortcut=QtGui.QKeySequence("Ctrl+W"), statusTip="Close the current window", triggered=self.Editor.closeCurrentFile) self.saveAct = QtGui.QAction(QtGui.QIcon("./images/save.png"), "&Save", self, shortcut=QtGui.QKeySequence("Ctrl+S"), statusTip="Save the current file", triggered=self.Editor.saveFile) self.saveAsAct = QtGui.QAction( "Save &As...", self, shortcut=QtGui.QKeySequence("Ctrl+Shift+S"), statusTip="Save to another file", triggered=self.Editor.saveFileAs) self.exitAct = QtGui.QAction("E&xit", self, shortcut=QtGui.QKeySequence("Alt+F4"), statusTip="Exit the application", triggered=QtGui.qApp.closeAllWindows) # edit menu self.editUndoAct = QtGui.QAction("&Undo", self, shortcut=QtGui.QKeySequence("Ctrl+Z"), triggered=self.Editor.editUndo) self.editRedoAct = QtGui.QAction("&Redo", self, shortcut=QtGui.QKeySequence("Ctrl+Y"), triggered=self.Editor.editRedo) self.editCutAct = QtGui.QAction("Cu&t", self, shortcut=QtGui.QKeySequence("Ctrl+X"), triggered=self.Editor.editCut) self.editCopyAct = QtGui.QAction("&Copy", self, shortcut=QtGui.QKeySequence("Ctrl+C"), triggered=self.Editor.editCopy) self.editPasteAct = QtGui.QAction( "&Paste", self, shortcut=QtGui.QKeySequence("Ctrl+V"), triggered=self.Editor.editPaste) self.editSelectAllAct = QtGui.QAction( "Select &All", self, shortcut=QtGui.QKeySequence("Ctrl+A"), triggered=self.Editor.editSelectAll) self.editClearAct = QtGui.QAction("Clear", self, triggered=self.Editor.editClear) # find/replace self.findAct = QtGui.QAction("&Find/Replace...", self, shortcut=QtGui.QKeySequence("Ctrl+F"), statusTip="Find/Replace texts", triggered=self.Editor.showFindDialog) # project menu self.compileAct = QtGui.QAction(QtGui.QIcon("./images/build.png"), "&Compile", self, shortcut=QtGui.QKeySequence("Ctrl+B"), statusTip="Build the current project", triggered=self.startBuild) self.stopAct = QtGui.QAction(QtGui.QIcon("./images/stop.png"), "S&top", self, statusTip="Cancel the build process", triggered=self.stopBuild) self.programAct = QtGui.QAction( QtGui.QIcon("./images/load.png"), "&Load", self, shortcut=QtGui.QKeySequence("Ctrl+R"), statusTip="Download program to the board using bootloader", triggered=self.programChip) self.firmwareLibList = scanFirmwareLibs() self.firmwareLibActs = [] if len(self.firmwareLibList): for i in range(len(self.firmwareLibList)): self.firmwareLibActs.append( QtGui.QAction(self.firmwareLibList[i], self, statusTip="include " + self.firmwareLibList[i] + " library")) self.exampleProjects = getExampleProjects(self.firmwareLibList) self.exampleFolderMenus = [] self.openExampleActs = [] for group in self.exampleProjects: folder, files = group[0], group[1] self.exampleFolderMenus.append(QtGui.QMenu(str(folder), self)) for fname in files: baseName = os.path.basename(fname) self.openExampleActs.append( QtGui.QAction(os.path.splitext(baseName)[0], self, statusTip='Open "' + str(fname).replace('\\', '/') + '"')) # serial monitor/terminal window self.serialMonitorAct = QtGui.QAction( QtGui.QIcon("./images/serial.png"), "Serial &Monitor", self, shortcut=QtGui.QKeySequence("Ctrl+Shift+M"), statusTip="Launch Serial Monitor Dialog", triggered=self.openSerialPortMonitorDialog) self.serialPortGroup = QtGui.QActionGroup(self) self.serialPortList = scan_serialports() self.serialPortActs = [] if len(self.serialPortList): for i in range(len(self.serialPortList)): self.serialPortActs.append( QtGui.QAction(self.serialPortList[i], self, checkable=True, statusTip="select " + self.serialPortList[i] + " serial port", triggered=self.selectSerialPort)) self.serialPortGroup.addAction(self.serialPortActs[i]) # todo: board names?? #self.boardAnitoAct = QtGui.QAction("PhilRobokit &Anito", self, # checkable=True, statusTip="Select PhilRobokit Anito board" ) self.boardEgizmoStm32Act = QtGui.QAction( "e&Gizmo STM32", self, checkable=True, statusTip="Select eGizmo STM32F100C8 MCU board") self.boardGroup = QtGui.QActionGroup(self) #self.boardGroup.addAction(self.boardAnitoAct) self.boardGroup.addAction(self.boardEgizmoStm32Act) self.boardEgizmoStm32Act.setChecked(True) self.restoreDefaultsAct = QtGui.QAction( "Restore Defaults", self, statusTip="Clear configuration files", triggered=self.Configs.setDefaults) # help menu self.aboutAct = QtGui.QAction("&About", self, shortcut=QtGui.QKeySequence("F1"), statusTip="About the IDE", triggered=self.about) self.aboutCompilerAct = QtGui.QAction( "About &Compiler", self, statusTip="About GNU tools for ARM Embedded", triggered=self.aboutCompiler) self.aboutQtAct = QtGui.QAction( "About &Qt", self, statusTip="Show the Qt library's About box", triggered=QtGui.qApp.aboutQt) self.visitProjectprotoSiteAct = QtGui.QAction( "Visit &ProjectProto", self, statusTip="Open ProjectProto blog site (yus' projects)", triggered=self.openProjectProtoSite) self.visitPhilroboticsSiteAct = QtGui.QAction( "Visit Phil&Robotics", self, statusTip="Open PhilRobotics website", triggered=self.openPhilRoboticsSite)
def createActions(self): # file menu self.newAct = QtGui.QAction( QtGui.QIcon("./images/new.png"), "&New", self, shortcut=QtGui.QKeySequence("Ctrl+N"), statusTip="Create a new file", triggered=self.Editor.newFile) self.openAct = QtGui.QAction(QtGui.QIcon("./images/open.png"), "&Open...", self, shortcut=QtGui.QKeySequence("Ctrl+O"), statusTip="Open an existing file") self.openAct.triggered.connect( functools.partial(self.Editor.openFile, None) ) self.closeAct = QtGui.QAction("&Close", self, shortcut=QtGui.QKeySequence("Ctrl+W"), statusTip="Close the current window", triggered=self.Editor.closeCurrentFile) self.saveAct = QtGui.QAction(QtGui.QIcon("./images/save.png"), "&Save", self, shortcut=QtGui.QKeySequence("Ctrl+S"), statusTip="Save the current file", triggered=self.Editor.saveFile) self.saveAsAct = QtGui.QAction("Save &As...", self, shortcut=QtGui.QKeySequence("Ctrl+Shift+S"), statusTip="Save to another file", triggered=self.Editor.saveFileAs) self.exitAct = QtGui.QAction("E&xit", self, shortcut=QtGui.QKeySequence("Alt+F4"), statusTip="Exit the application", triggered=QtGui.qApp.closeAllWindows) # edit menu self.editUndoAct = QtGui.QAction("&Undo", self, shortcut=QtGui.QKeySequence("Ctrl+Z"), triggered=self.Editor.editUndo) self.editRedoAct = QtGui.QAction("&Redo", self, shortcut=QtGui.QKeySequence("Ctrl+Y"), triggered=self.Editor.editRedo) self.editCutAct = QtGui.QAction("Cu&t", self, shortcut=QtGui.QKeySequence("Ctrl+X"), triggered=self.Editor.editCut) self.editCopyAct = QtGui.QAction("&Copy", self, shortcut=QtGui.QKeySequence("Ctrl+C"), triggered=self.Editor.editCopy) self.editPasteAct = QtGui.QAction("&Paste", self, shortcut=QtGui.QKeySequence("Ctrl+V"), triggered=self.Editor.editPaste) self.editSelectAllAct = QtGui.QAction("Select &All", self, shortcut=QtGui.QKeySequence("Ctrl+A"), triggered=self.Editor.editSelectAll) self.editClearAct = QtGui.QAction("Clear", self, triggered=self.Editor.editClear) # find/replace self.findAct = QtGui.QAction("&Find/Replace...", self, shortcut=QtGui.QKeySequence("Ctrl+F"), statusTip="Find/Replace texts", triggered=self.Editor.showFindDialog) # project menu self.compileAct = QtGui.QAction(QtGui.QIcon("./images/build.png"), "&Compile", self, shortcut=QtGui.QKeySequence("Ctrl+B"), statusTip="Build the current project", triggered=self.startBuild) self.stopAct = QtGui.QAction(QtGui.QIcon("./images/stop.png"), "S&top", self, statusTip="Cancel the build process", triggered=self.stopBuild) self.programAct = QtGui.QAction(QtGui.QIcon("./images/load.png"), "&Load", self, statusTip="Write program to the board", triggered=self.programChip) self.pickit2ProgramAct = QtGui.QAction(QtGui.QIcon("./images/pickit2.png"), "PIC&kit2", self, statusTip="Write program to the board using PICkit2 programmer", triggered=self.pickit2ProgramChip) self.firmwareLibList = scanFirmwareLibs() self.firmwareLibActs = [] if len(self.firmwareLibList): for i in range(len(self.firmwareLibList)): self.firmwareLibActs.append( QtGui.QAction(self.firmwareLibList[i], self, statusTip="include " + self.firmwareLibList[i] + " library" ) ) self.exampleProjects = getExampleProjects(self.firmwareLibList) self.exampleFolderMenus = [] self.openExampleActs = [] for group in self.exampleProjects: folder, files = group[0], group[1] self.exampleFolderMenus.append(QtGui.QMenu(str(folder), self)) for fname in files: baseName = os.path.basename(fname) self.openExampleActs.append(QtGui.QAction(os.path.splitext(baseName)[0], self, statusTip = 'Open "' + str(fname).replace('\\', '/') + '"') ) # serial monitor/terminal window self.serialMonitorAct = QtGui.QAction(QtGui.QIcon("./images/serial.png"), "Serial &Monitor", self, shortcut=QtGui.QKeySequence("Ctrl+Shift+M"), statusTip="Launch Serial Monitor Dialog", triggered=self.openSerialPortMonitorDialog) # board names self.boardAnito877aAct = QtGui.QAction("Anito-877A", self, checkable=True, statusTip="Select PhilRobokit Anito with PIC16F877A", # pic16 support triggered=self.selectBoard ) self.boardAnito4520Act = QtGui.QAction("Anito-4520", self, checkable=True, statusTip="Select PhilRobokit Anito with PIC18F4520", # pic18 support triggered=self.selectBoard ) self.boardGroup = QtGui.QActionGroup(self) self.boardGroup.addAction(self.boardAnito877aAct) self.boardGroup.addAction(self.boardAnito4520Act) previousBoardName = self.Configs.getBoardName() if self.boardAnito877aAct.text() == previousBoardName: self.boardAnito877aAct.setChecked(True) elif self.boardAnito4520Act.text() == previousBoardName: self.boardAnito4520Act.setChecked(True) self.selectBoard() self.programHexAct = QtGui.QAction("Program &HEX File", self, statusTip="Download pre-built *.hex file to board using bootloader", triggered=self.programChipHexFile) self.recoverBootloaderAct = QtGui.QAction("Recover TinyPIC", self, statusTip="Recover TinyPIC Bootloader Firmware using PICkit2", triggered=self.recoverBootloader) self.restoreDefaultsAct = QtGui.QAction("Restore Defaults", self, statusTip="Clear configuration files", triggered=self.Configs.setDefaults) # help menu self.aboutAct = QtGui.QAction("&About", self, shortcut=QtGui.QKeySequence("F1"), statusTip="About the IDE", triggered=self.about) self.aboutCompilerAct = QtGui.QAction("About &Compiler", self, statusTip="About XC8 tool", triggered=self.aboutCompiler) self.aboutQtAct = QtGui.QAction("About &Qt", self, statusTip="Show the Qt library's About box", triggered=QtGui.qApp.aboutQt) self.visitSiteAct = QtGui.QAction("Visit &PhilRobotics", self, statusTip="Open PhilRobotics Website", triggered=self.openPhilRoboticsSite)