def __importCertificate(self): """ Private method to read a certificate. @return certificates read (list of QSslCertificate) """ fname = E5FileDialog.getOpenFileName( self, self.tr("Import Certificate"), "", self.tr("Certificate Files (*.pem *.crt *.der *.cer *.ca);;" "All Files (*)"), ) if fname: f = QFile(fname) if not f.open(QIODevice.ReadOnly): E5MessageBox.critical( self, self.tr("Export Certificate"), self.tr( """<p>The certificate could not be read from file""" """ <b>{0}</b></p><p>Error: {1}</p>""" ).format(fname, f.errorString()), ) return [] crt = f.readAll() f.close() cert = QSslCertificate.fromData(crt, QSsl.Pem) if not cert: cert = QSslCertificate.fromData(crt, QSsl.Der) return cert return []
def on_loadButton_clicked(self): """ Private slot to load a regexp from a file. """ fname = E5FileDialog.getOpenFileName( self, self.tr("Load regular expression"), "", self.tr("RegExp Files (*.rx);;All Files (*)")) if fname: try: f = open( Utilities.toNativeSeparators(fname), "r", encoding="utf-8") regexp = f.read() f.close() if regexp.startswith("syntax="): lines = regexp.splitlines() syntax = int(lines[0].replace("syntax=", "")) index = self.syntaxCombo.findData(syntax) self.syntaxCombo.setCurrentIndex(index) regexp = lines[1] self.regexpLineEdit.setText(regexp) except IOError as err: E5MessageBox.information( self, self.tr("Save regular expression"), self.tr("""<p>The regular expression could not""" """ be saved.</p><p>Reason: {0}</p>""") .format(str(err)))
def on_mainscriptButton_clicked(self): """ Private slot to display a file selection dialog. """ dir = self.dirEdit.text() if not dir: dir = QDir.currentPath() patterns = [] for pattern, filetype in list(self.project.pdata["FILETYPES"].items()): if filetype == "SOURCES": patterns.append(pattern) filters = self.tr("Source Files ({0});;All Files (*)")\ .format(" ".join(patterns)) fn = E5FileDialog.getOpenFileName( self, self.tr("Select main script file"), dir, filters) if fn: ppath = self.dirEdit.text() if ppath: ppath = QDir(ppath).absolutePath() + QDir.separator() fn = fn.replace(ppath, "") self.mainscriptEdit.setText(Utilities.toNativeSeparators(fn))
def on_fileDialogButton_clicked(self): """ Private slot to open a file dialog. """ if self.dbs: py2Extensions = \ ' '.join(["*{0}".format(ext) for ext in self.dbs.getExtensions('Python2')]) py3Extensions = \ ' '.join(["*{0}".format(ext) for ext in self.dbs.getExtensions('Python3')]) filter = self.tr( "Python3 Files ({1});;Python2 Files ({0});;All Files (*)")\ .format(py2Extensions, py3Extensions) else: filter = self.tr("Python Files (*.py);;All Files (*)") prog = E5FileDialog.getOpenFileName( self, "", self.testsuiteComboBox.currentText(), filter) if not prog: return self.insertProg(Utilities.toNativeSeparators(prog))
def on_fileButton_clicked(self): """ Private slot called by pressing the file selection button. """ fn = E5FileDialog.getOpenFileName(self, self.tr("Select file for property"), self.propFileEdit.text(), "") if fn: self.propFileEdit.setText(Utilities.toNativeSeparators(fn))
def on_styleSheetButton_clicked(self): """ Private slot to handle the user style sheet selection. """ file = E5FileDialog.getOpenFileName(self, self.tr("Select Style Sheet"), self.styleSheetEdit.text(), "") if file: self.styleSheetEdit.setText(Utilities.toNativeSeparators(file))
def on_fileButton_clicked(self): """ Private slot to handle the file selection via a file selection dialog. """ bookmark = E5FileDialog.getOpenFileName() if bookmark: bookmark = Utilities.toNativeSeparators(bookmark) self.fileEdit.setText(bookmark)
def on_iconButton_clicked(self): """ Private slot to handle the icon selection via a file selection dialog. """ icon = E5FileDialog.getOpenFileName( self, self.tr("Select icon file"), self.iconEdit.text(), self.tr("Icon files (*.png)") ) if icon: self.iconEdit.setText(icon)
def on_databaseFileButton_clicked(self): """ Private slot to open a database file via a file selection dialog. """ startdir = self.databaseEdit.text() dbFile = E5FileDialog.getOpenFileName(self, self.tr("Select Database File"), startdir, self.tr("All Files (*)")) if dbFile: self.databaseEdit.setText(Utilities.toNativeSeparators(dbFile))
def on_addButton_clicked(self): """ Private slot to handle the Add... button. """ fname = E5FileDialog.getOpenFileName( self, self.tr("Attach file")) if fname: self.attachFile(fname, False)
def on_pelButton_clicked(self): """ Private method to select the personal exclude list file. """ file = E5FileDialog.getOpenFileName( self, self.tr("Select personal exclude list"), self.pelEdit.text(), self.tr("Dictionary File (*.dic);;All Files (*)")) if file: self.pelEdit.setText(Utilities.toNativeSeparators(file))
def on_apiFileButton_clicked(self): """ Private method to select an api file. """ file = E5FileDialog.getOpenFileName( self, self.tr("Select API file"), self.apiFileEdit.text(), self.tr("API File (*.api);;All Files (*)")) if file: self.apiFileEdit.setText(Utilities.toNativeSeparators(file))
def on_fileButton_clicked(self): """ Private slot to select a file via a file selection dialog. """ file = E5FileDialog.getOpenFileName( self, self.tr("Select filename of the breakpoint"), self.filenameCombo.currentText(), "") if file: self.filenameCombo.setEditText(Utilities.toNativeSeparators(file))
def on_idlButton_clicked(self): """ Private slot to handle the IDL compiler selection. """ file = E5FileDialog.getOpenFileName(self, self.tr("Select IDL compiler"), self.idlEdit.text(), "") if file: self.idlEdit.setText(Utilities.toNativeSeparators(file))
def on_interpreterButton_clicked(self): """ Private slot to handle the interpreter selection. """ file = E5FileDialog.getOpenFileName( self, self.tr("Select interpreter for Debug Client"), self.interpreterEdit.text(), "") if file: self.interpreterEdit.setText(Utilities.toNativeSeparators(file))
def on_debugClientButton_clicked(self): """ Private slot to handle the Debug Client selection. """ file = E5FileDialog.getOpenFileName( None, self.tr("Select Debug Client"), self.debugClientEdit.text(), self.tr("Python Files (*.py *.py2)")) if file: self.debugClientEdit.setText(Utilities.toNativeSeparators(file))
def on_exceptFileButton_clicked(self): """ Private slot to select a file to exempt from translation. """ texcept = E5FileDialog.getOpenFileName( self, self.tr("Exempt file from translation"), self.project.ppath, self.filters) if texcept: self.exceptionEdit.setText(Utilities.toNativeSeparators(texcept))
def on_translationsButton_clicked(self): """ Private slot to select the translations editor via a file selection dialog. """ editor = E5FileDialog.getOpenFileName(self, self.tr("Translations Editor"), self.translationsEdit.text(), self.tr("All Files (*)")) if editor: self.translationsEdit.setText(Utilities.toNativeSeparators(editor))
def __openFile(self): """ Private slot to load a new file. """ fn = E5FileDialog.getOpenFileName( self, self.tr("Select UI file"), self.currentFile, self.tr("Qt User-Interface Files (*.ui)")) if fn: self.__loadFile(fn)
def __import(self): """ Private slot to handle the Import context menu action. """ fn = E5FileDialog.getOpenFileName( self, self.tr("Import Templates"), "", self.tr("Templates Files (*.e4c);; All Files (*)")) if fn: self.readTemplates(fn) self.__dirty = True
def on_pysideDocDirButton_clicked(self): """ Private slot to select the PySide documentation directory. """ entry = E5FileDialog.getOpenFileName( self, self.tr("Select PySide documentation entry"), QUrl(self.pysideDocDirEdit.text()).path(), self.tr("HTML Files (*.html *.htm);;All Files (*)")) if entry: self.pysideDocDirEdit.setText(Utilities.toNativeSeparators(entry))
def on_customViewerSelectionButton_clicked(self): """ Private slot to handle the custom viewer selection. """ file = E5FileDialog.getOpenFileName( self, self.tr("Select Custom Viewer"), self.customViewerEdit.text(), "") if file: self.customViewerEdit.setText(Utilities.toNativeSeparators(file))
def on_patchFileButton_clicked(self): """ Private slot called by pressing the file selection button. """ fn = E5FileDialog.getOpenFileName( self, self.tr("Select patch file"), self.patchFileEdit.text(), self.tr("Patch Files (*.diff *.patch);;All Files (*)")) if fn: self.patchFileEdit.setText(Utilities.toNativeSeparators(fn))
def on_webbrowserButton_clicked(self): """ Private slot to handle the Web browser selection. """ file = E5FileDialog.getOpenFileName( self, self.tr("Select Web-Browser"), self.webbrowserEdit.text(), "") if file: self.webbrowserEdit.setText(Utilities.toNativeSeparators(file))
def on_fileButton_clicked(self): """ Private slot to enter the requirements file via a file selection dialog. """ fileName = E5FileDialog.getOpenFileName( self, self.tr("Select the requirements file"), self.requirementsEdit.text() or os.path.expanduser("~"), self.tr("Text Files (*.txt);;All Files (*)")) if fileName: self.requirementsEdit.setText( Utilities.toNativeSeparators(fileName))
def __selectFile(self, lineEdit): """ Private slot to display a file selection dialog. @param lineEdit field for the display of the selected filename (QLineEdit) """ filename = E5FileDialog.getOpenFileName( self, self.tr("Select file to compare"), lineEdit.text(), "") if filename: lineEdit.setText(Utilities.toNativeSeparators(filename))
def on_styleSheetButton_clicked(self): """ Private method to select the style sheet file via a dialog. """ file = E5FileDialog.getOpenFileName( self, self.tr("Select style sheet file"), self.styleSheetEdit.text(), self.tr("Qt Style Sheets (*.qss);;Cascading Style Sheets (*.css);;" "All files (*)")) if file: self.styleSheetEdit.setText(Utilities.toNativeSeparators(file))
def on_idlButton_clicked(self): """ Private slot to handle the IDL compiler selection. """ file = E5FileDialog.getOpenFileName( self, self.tr("Select IDL compiler"), self.idlEdit.text(), "") if file: self.idlEdit.setText(Utilities.toNativeSeparators(file))
def on_debugClientButton_clicked(self): """ Private slot to handle the Debug Client selection. """ file = E5FileDialog.getOpenFileName( None, self.tr("Select Debug Client"), self.debugClientEdit.text(), self.tr("Python Files (*.py *.py2)")) if file: self.debugClientEdit.setText( Utilities.toNativeSeparators(file))
def on_cssButton_clicked(self): """ Private slot to select a css style sheet. """ cssFile = E5FileDialog.getOpenFileName( self, self.tr("Select CSS style sheet"), getConfig('ericCSSDir'), self.tr("Style sheet (*.css);;All files (*)")) if cssFile: # make it relative, if it is in a subdirectory of the project path cf = Utilities.toNativeSeparators(cssFile) cf = self.project.getRelativePath(cf) self.cssEdit.setText(cf)
def on_styleSheetButton_clicked(self): """ Private method to select the style sheet file via a dialog. """ file = E5FileDialog.getOpenFileName( self, self.tr("Select style sheet file"), self.styleSheetEdit.text(), self.tr("Qt Style Sheets (*.qss);;Cascading Style Sheets (*.css);;" "All files (*)"), ) if file: self.styleSheetEdit.setText(Utilities.toNativeSeparators(file))
def on_pythonExecButton_clicked(self): """ Private slot to select a Python interpreter via a file selection dialog. """ pythonExec = self.pythonExecEdit.text() if not pythonExec: pythonExec = sys.executable.replace("w.exe", ".exe") pythonExec = Utilities.fromNativeSeparators(pythonExec) pythonExec = E5FileDialog.getOpenFileName( self, self.tr("Python Interpreter"), pythonExec, "") if pythonExec: self.pythonExecEdit.setText( Utilities.toNativeSeparators(pythonExec))
def on_debugClientButton_clicked(self): """ Private slot to handle the Debug Client selection. """ filters = self.project.dbgFilters[self.project.pdata["PROGLANGUAGE"] [0]] filters += self.tr("All Files (*)") file = E5FileDialog.getOpenFileName(self, self.tr("Select Debug Client"), self.debugClientEdit.text(), filters) if file: self.debugClientEdit.setText(Utilities.toNativeSeparators(file))
def on_fileButton_clicked(self): """ Private slot to display a file selection dialog. """ startdir = self.filenameEdit.text() if startdir or self.startdir is not None: if not startdir: startdir = self.startdir projectFile = E5FileDialog.getOpenFileName( self, self.tr("Add Project"), startdir, self.tr("Project Files (*.e4p)")) if projectFile: self.filenameEdit.setText( Utilities.toNativeSeparators(projectFile))
def on_debugClientButton_clicked(self): """ Private slot to handle the Debug Client selection. """ filters = self.project.dbgFilters[ self.project.pdata["PROGLANGUAGE"][0]] filters += self.tr("All Files (*)") file = E5FileDialog.getOpenFileName( self, self.tr("Select Debug Client"), self.debugClientEdit.text(), filters) if file: self.debugClientEdit.setText(Utilities.toNativeSeparators(file))
def on_addButton_clicked(self): """ Private slot used to add an executable to the list. """ executable = E5FileDialog.getOpenFileName( self, self.tr("Add pip executable"), os.path.expanduser("~"), "") executable = Utilities.toNativeSeparators(executable) if executable != "" and executable not in self.__model.stringList(): self.__model.insertRow(self.__model.rowCount()) self.__model.setData( self.__model.index(self.__model.rowCount() - 1), executable) self.__model.sort(0)
def on_pelButton_clicked(self): """ Private slot to select the project exclude list file. """ pel = Utilities.fromNativeSeparators(self.pelEdit.text()) if not pel: pel = self.project.ppath elif not os.path.isabs(pel): pel = Utilities.fromNativeSeparators(os.path.join(self.project.ppath, pel)) file = E5FileDialog.getOpenFileName( self, self.tr("Select project exclude list"), pel, self.tr("Dictionary File (*.dic);;All Files (*)") ) if file: self.pelEdit.setText(self.project.getRelativePath(Utilities.toNativeSeparators(file)))
def __importStyles(self, lexers): """ Private method to import the styles of the given lexers. @param lexers dictionary of lexer objects for which to import the styles """ fn = E5FileDialog.getOpenFileName( self, self.tr("Import Highlighting Styles"), "", self.tr("Highlighting styles file (*.e4h)")) if not fn: return f = QFile(fn) if f.open(QIODevice.ReadOnly): from E5XML.HighlightingStylesReader import HighlightingStylesReader reader = HighlightingStylesReader(f, lexers) reader.readXML() f.close() else: E5MessageBox.critical( self, self.tr("Import Highlighting Styles"), self.tr( """<p>The highlighting styles could not be read""" """ from file <b>{0}</b>.</p><p>Reason: {1}</p>""") .format(fn, f.errorString()) ) return if self.lexer: colour = self.lexer.color(self.style) paper = self.lexer.paper(self.style) eolfill = self.lexer.eolFill(self.style) font = self.lexer.font(self.style) self.sampleText.setFont(font) pl = self.sampleText.palette() pl.setColor(QPalette.Text, colour) pl.setColor(QPalette.Base, paper) self.sampleText.setPalette(pl) self.sampleText.repaint() self.eolfillCheckBox.setChecked(eolfill) self.__styleAllItems()
def openMultiProject(self, fn=None, openMaster=True): """ Public slot to open a multi project. @param fn optional filename of the multi project file to be read (string) @param openMaster flag indicating, that the master project should be opened depending on the configuration (boolean) """ if not self.checkDirty(): return if fn is None: fn = E5FileDialog.getOpenFileName( self.parent(), self.tr("Open multiproject"), Preferences.getMultiProject("Workspace") or Utilities.getHomeDir(), self.tr("Multiproject Files (*.e5m *.e4m)")) if fn == "": fn = None QApplication.processEvents() if fn is not None: QApplication.setOverrideCursor(QCursor(Qt.WaitCursor)) QApplication.processEvents() self.closeMultiProject() if self.__readMultiProject(fn): self.opened = True QApplication.restoreOverrideCursor() QApplication.processEvents() self.closeAct.setEnabled(True) self.saveasAct.setEnabled(True) self.addProjectAct.setEnabled(True) self.propsAct.setEnabled(True) self.multiProjectOpened.emit() if openMaster and Preferences.getMultiProject( "OpenMasterAutomatically"): self.__openMasterProject(False) else: QApplication.restoreOverrideCursor()
def on_transPatternButton_clicked(self): """ Private slot to display a file selection dialog. """ tp = Utilities.fromNativeSeparators(self.transPatternEdit.text()) if "%language%" in tp: tp = tp.split("%language%")[0] if not os.path.isabs(tp): tp = Utilities.fromNativeSeparators( os.path.join(self.project.ppath, tp)) tsfile = E5FileDialog.getOpenFileName( self, self.tr("Select translation file"), tp, "") if tsfile: self.transPatternEdit.setText( self.project.getRelativePath( Utilities.toNativeSeparators(tsfile)))
def on_executableButton_clicked(self): """ Private slot to handle the executable selection via a file selection dialog. """ execfile = E5FileDialog.getOpenFileName(self, self.tr("Select executable"), self.executableEdit.text(), "") if execfile: execfile = Utilities.toNativeSeparators(execfile) if not Utilities.isinpath(execfile): E5MessageBox.critical( self, self.tr("Select executable"), self.tr("The selected file is not an executable." " Please choose an executable filename.")) return self.executableEdit.setText(execfile)
def on_pelButton_clicked(self): """ Private slot to select the project exclude list file. """ pel = Utilities.fromNativeSeparators(self.pelEdit.text()) if not pel: pel = self.project.ppath elif not os.path.isabs(pel): pel = Utilities.fromNativeSeparators( os.path.join(self.project.ppath, pel)) file = E5FileDialog.getOpenFileName( self, self.tr("Select project exclude list"), pel, self.tr("Dictionary File (*.dic);;All Files (*)")) if file: self.pelEdit.setText( self.project.getRelativePath( Utilities.toNativeSeparators(file)))
def on_chooseButton_clicked(self): """ Private slot to choose the bookmarks file or directory. """ if self.__selectedSource == "ie": path = E5FileDialog.getExistingDirectory( self, self.tr("Choose Directory ..."), self.__sourceDir, E5FileDialog.Options(E5FileDialog.Option(0))) else: if Globals.isMacPlatform(): filter = "*{0}".format(os.path.splitext(self.__sourceFile)[1]) else: filter = self.__sourceFile path = E5FileDialog.getOpenFileName(self, self.tr("Choose File ..."), self.__sourceDir, filter) if path: self.fileEdit.setText(Utilities.toNativeSeparators(path))