def addSettings(self, flags, props, cfg, prefix): from build_settings_cfg import tabs parenPat = re.compile('.+\((.+)\)') for t in tabs: desc = tabs.get(t) for d in desc: name = d[0] if name.startswith(prefix) or name.startswith('BUILD_'): value = props.get(name) if d[2] == 'CB': if value == 'True': flags = flags + ' ' + d[4] else: if d[2] != 'EDIT': if value and not value == 'Default': m = re.match(parenPat, value) if m: g = m.groups() value = g[0] else: value = value.replace('\\n', ' ') flags = flags + ' ' + value else: if value: value = value.replace('\\n', ' ') value = value.replace('\n', ' ') flags = flags + ' ' + value return flags
def addSettings(self,flags,props,cfg,prefix): from build_settings_cfg import tabs parenPat=re.compile('.+\((.+)\)') for t in tabs: desc=tabs.get(t) for d in desc: name=d[0] if name.startswith(prefix) or name.startswith('BUILD_'): value=props.get(name) if d[2]=='CB': if value=='True': flags=flags+' '+d[4] else: if value and not value=='Default': m=re.match(parenPat,value) if m: g=m.groups() value=g[0] else: value=value.replace('\\n',' ') flags=flags+' '+value return flags
def __init__(self, mainwin, startPath, parent=None): super(BuildSettingsDialog, self).__init__(parent) self.mainWindow = mainwin uis.loadDialog('build_settings', self) s = QtCore.QSettings() check(self.parallelCB, s.value('parallel_make', False).toBool()) check(self.symscanCB, s.value('symbol_scan', True).toBool()) self.tabWidget.clear() self.tabs = [] for t in tabs: desc = tabs.get(t) dlg = SettingsTabDialog() dlg.addWidgets(desc, self) self.tabs.append((t, dlg)) for (name, tab) in self.tabs: self.tabWidget.addTab(tab, name) self.workspaceItem = QtGui.QTreeWidgetItem(['Workspace']) self.mainWindow.workspaceTree.addProjectsToTree(self.workspaceItem) self.workspaceDir = self.workspaceItem.data(0, DirectoryRole).toString() self.projTree.addTopLevelItem(self.workspaceItem) self.workspaceItem.setExpanded(True) self.projTree.itemSelectionChanged.connect(self.selectionChanged) self.closeButton.clicked.connect(self.closeClicked) self.resetButton.clicked.connect(self.resetClicked) self.prevPath = '' firstItem = None if startPath == self.workspaceDir: firstItem = self.workspaceItem else: firstItem = self.findItem(self.workspaceItem, startPath) if not firstItem: firstItem = self.workspaceItem self.projTree.setCurrentItem(firstItem) self.projTree.scrollToItem(firstItem) dir = firstItem.data(0, DirectoryRole).toString() self.prevPath = os.path.join(dir, 'mk.cfg')
def __init__(self, mainwin, startPath, parent=None): super(BuildSettingsDialog, self).__init__(parent) self.mainWindow = mainwin uis.loadDialog("build_settings", self) s = QtCore.QSettings() check(self.parallelCB, s.value("parallel_make", False).toBool()) check(self.symscanCB, s.value("symbol_scan", True).toBool()) self.tabWidget.clear() self.tabs = [] for t in tabs: desc = tabs.get(t) dlg = SettingsTabDialog() dlg.addWidgets(desc, self) self.tabs.append((t, dlg)) for (name, tab) in self.tabs: self.tabWidget.addTab(tab, name) self.workspaceItem = QtGui.QTreeWidgetItem(["Workspace"]) self.mainWindow.workspaceTree.addProjectsToTree(self.workspaceItem) self.workspaceDir = self.workspaceItem.data(0, DirectoryRole).toString() self.projTree.addTopLevelItem(self.workspaceItem) self.workspaceItem.setExpanded(True) self.projTree.itemSelectionChanged.connect(self.selectionChanged) self.closeButton.clicked.connect(self.closeClicked) self.resetButton.clicked.connect(self.resetClicked) self.prevPath = "" firstItem = None if startPath == self.workspaceDir: firstItem = self.workspaceItem else: firstItem = self.findItem(self.workspaceItem, startPath) if not firstItem: firstItem = self.workspaceItem self.projTree.setCurrentItem(firstItem) self.projTree.scrollToItem(firstItem) dir = firstItem.data(0, DirectoryRole).toString() self.prevPath = os.path.join(dir, "mk.cfg")
def selectionChanged(self): if self.prevPath: self.save(self.prevPath) item = self.projTree.currentItem() dir = item.data(0, DirectoryRole).toString() path = os.path.join(dir, 'mk.cfg') self.load(path) self.prevPath = path def load(self, path): props = Properties(path) for (name, tab) in self.tabs: tab.load(props) def save(self, path): props = Properties(path) for (name, tab) in self.tabs: tab.save(props) props.save(path) if __name__ == '__main__': import sys from build_settings_cfg import tabs app = QtGui.QApplication(sys.argv) d = SettingsTabDialog() d.addWidgets(tabs.get('Compile')) d.show() app.exec_()
def selectionChanged(self): if self.prevPath: self.save(self.prevPath) item = self.projTree.currentItem() dir = item.data(0, DirectoryRole).toString() path = os.path.join(dir, "mk.cfg") self.load(path) self.prevPath = path def load(self, path): props = Properties(path) for (name, tab) in self.tabs: tab.load(props) def save(self, path): props = Properties(path) for (name, tab) in self.tabs: tab.save(props) props.save(path) if __name__ == "__main__": import sys from build_settings_cfg import tabs app = QtGui.QApplication(sys.argv) d = SettingsTabDialog() d.addWidgets(tabs.get("Compile")) d.show() app.exec_()