Mercurial > lcfOS
diff python/ide.py @ 256:225f444019b1
Added build and flash menu option
author | Windel Bouwman |
---|---|
date | Sun, 04 Aug 2013 18:32:04 +0200 |
parents | 7416c923a02a |
children | 04c19282a5aa |
line wrap: on
line diff
--- a/python/ide.py Sun Aug 04 15:10:10 2013 +0200 +++ b/python/ide.py Sun Aug 04 18:32:04 2013 +0200 @@ -16,12 +16,13 @@ import zcc import outstream +logformat='%(asctime)s|%(levelname)s|%(name)s|%(msg)s' class BuildOutput(QTextEdit): """ Build output component """ def __init__(self, parent=None): super(BuildOutput, self).__init__(parent) - fmt = logging.Formatter(fmt='%(asctime)s %(levelname)s %(name)s %(msg)s') + fmt = logging.Formatter(fmt=logformat) class MyHandler(logging.Handler): def emit(self2, x): self.append(str(fmt.format(x))) @@ -57,11 +58,11 @@ self.model.appendRow([item, irow, icol]) def itemSelected(self, index): - if not index.isValid(): - return - item = self.model.itemFromIndex(index) - err = item.data() - self.sigErrorSelected.emit(err) + if not index.isValid(): + return + item = self.model.itemFromIndex(index) + err = item.data() + self.sigErrorSelected.emit(err) class AboutDialog(QDialog): @@ -87,7 +88,7 @@ class Ide(QMainWindow): def __init__(self, parent=None): super(Ide, self).__init__(parent) - + self.to_open_files = [] self.setWindowTitle('LCFOS IDE') icon = QIcon('icons/logo.png') @@ -103,6 +104,7 @@ self.mdiArea = QMdiArea() self.mdiArea.setViewMode(QMdiArea.TabbedView) self.mdiArea.setTabsClosable(True) + self.mdiArea.setTabsMovable(True) self.setCentralWidget(self.mdiArea) # Create components: @@ -147,6 +149,7 @@ addMenuEntry("Open", self.fileMenu, self.openFile, shortcut=QKeySequence(QKeySequence.Open)) addMenuEntry("Save", self.fileMenu, self.saveFile, shortcut=QKeySequence(QKeySequence.Save)) addMenuEntry("Build", self.fileMenu, self.buildFile, shortcut=QKeySequence("F7")) + addMenuEntry("Build and flash", self.fileMenu, self.buildFileAndFlash, shortcut=QKeySequence("F8")) self.helpAction = QAction('Help', self) self.helpAction.setShortcut(QKeySequence('F1')) @@ -217,8 +220,13 @@ self.restoreGeometry(self.settings.value('mainwindowgeometry')) if self.settings.contains('lastfiles'): lfs = self.settings.value('lastfiles') - for lf in lfs: - self.loadFile(lf) + self.to_open_files.extend(lfs) + + def showEvent(self, ev): + super().showEvent(ev) + while self.to_open_files: + fn = self.to_open_files.pop(0) + self.loadFile(fn) def closeEvent(self, ev): self.settings.setValue('mainwindowstate', self.saveState()) @@ -282,6 +290,18 @@ ce.setErrors(self.diag.diags) return + def buildFileAndFlash(self): + ce = self.activeMdiChild() + if not ce: + return + self.diag.clear() + outs = outstream.TextOutputStream() + if not zcc.zcc(ce.Source, outs, self.diag, do_optimize=True): + # Set errors: + self.builderrors.setErrorList(self.diag.diags) + ce.setErrors(self.diag.diags) + return + code_s = outs.getSection('code') self.debugInfo = code_s.debugInfos() if self.ctrlToolbar.device: @@ -291,10 +311,12 @@ stl = self.ctrlToolbar.device.iface stl.reset() stl.halt() + stl.run() logging.info('Done!') + if __name__ == '__main__': - logging.basicConfig(format='%(asctime)s %(levelname)s %(name)s %(message)s', level=logging.DEBUG) + logging.basicConfig(format=logformat, level=logging.DEBUG) app = QApplication(sys.argv) ide = Ide() ide.show()