コード例 #1
0
 def on_mainscriptButton_clicked(self):
     """
     Private slot to display a file selection dialog.
     """
     dir = self.dirEdit.text()
     if dir.isEmpty():
         dir = QDir.currentPath()
     patterns = QStringList()
     for pattern, filetype in self.project.pdata["FILETYPES"].items():
         if filetype == "SOURCES":
             patterns.append(QString(pattern))
     filters = self.trUtf8("Source Files (%1);;All Files (*)")\
         .arg(patterns.join(" "))
     fn = KQFileDialog.getOpenFileName(\
         self,
         self.trUtf8("Select main script file"),
         dir,
         filters)
     
     if not fn.isEmpty():
         ppath = self.dirEdit.text()
         if not ppath.isEmpty():
             ppath = QDir(ppath).absolutePath()
             ppath.append(QDir.separator())
             fn.replace(QRegExp(ppath), "")
         self.mainscriptEdit.setText(Utilities.toNativeSeparators(fn))
コード例 #2
0
 def on_addButton_clicked(self):
     """
     Private slot to handle the Add... button.
     """
     fname = KQFileDialog.getOpenFileName(self, self.trUtf8("Attach file"), QString(), QString())
     if not fname.isEmpty():
         self.attachFile(fname, False)
コード例 #3
0
 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 = KQFileDialog.getOpenFileName(\
         self,
         self.trUtf8("Import Highlighting Styles"),
         QString(),
         self.trUtf8("eric4 highlighting styles file (*.e4h)"),
         None)
     
     if fn.isEmpty():
         return
     
     fn = unicode(fn)
     
     try:
         f = open(fn, "rb")
         try:
             line = f.readline()
             dtdLine = f.readline()
         finally:
             f.close()
     except IOError, err:
         KQMessageBox.critical(self,
             self.trUtf8("Import Highlighting Styles"),
             self.trUtf8("""<p>The highlighting styles could not be read"""
                         """ from file <b>%1</b>.</p><p>Reason: %2</p>""")\
                 .arg(fn)\
                 .arg(str(err))
         )
         return
コード例 #4
0
 def on_fileButton_clicked(self):
     """
     Private slot to handle the file selection via a file selection dialog.
     """
     bookmark = KQFileDialog.getOpenFileName()
     if not bookmark.isEmpty():
         bookmark = Utilities.toNativeSeparators(bookmark)
         self.fileEdit.setText(bookmark)
コード例 #5
0
    def on_interpreterButton_clicked(self):
        """
        Private slot to handle the Python interpreter selection.
        """
        file = KQFileDialog.getOpenFileName(
            self, self.trUtf8("Select Python interpreter for Debug Client"), self.interpreterEdit.text(), QString()
        )

        if not file.isEmpty():
            self.interpreterEdit.setText(Utilities.toNativeSeparators(file))
コード例 #6
0
 def __openFile(self):
     """
     Private slot to load a new file.
     """
     fn = KQFileDialog.getOpenFileName(\
         self, 
         self.trUtf8("Select UI file"),
         self.currentFile,
         self.trUtf8("Qt User-Interface Files (*.ui)"))
     if not fn.isEmpty():
         self.__loadFile(fn)
コード例 #7
0
 def on_styleSheetButton_clicked(self):
     """
     Private slot to handle the user style sheet selection.
     """
     file = KQFileDialog.getOpenFileName(\
         self,
         self.trUtf8("Select Style Sheet"),
         self.styleSheetEdit.text(),
         QString())
     
     if not file.isNull():
         self.styleSheetEdit.setText(Utilities.toNativeSeparators(file))
コード例 #8
0
 def on_qt4DocDirButton_clicked(self):
     """
     Private slot to select the Qt4 documentation directory.
     """
     entry = KQFileDialog.getOpenFileName(\
         self,
         self.trUtf8("Select Qt4 documentation entry"),
         QUrl(self.qt4DocDirEdit.text()).path(),
         self.trUtf8("HTML Files (*.html *.htm);;All Files (*)"))
     
     if entry:
         self.qt4DocDirEdit.setText(Utilities.toNativeSeparators(entry))
コード例 #9
0
 def on_fileButton_clicked(self):
     """
     Private slot called by pressing the file selection button.
     """
     fn = KQFileDialog.getOpenFileName(\
         self,
         self.trUtf8("Select file for property"),
         self.propFileEdit.text(),
         QString())
     
     if not fn.isEmpty():
         self.propFileEdit.setText(Utilities.toNativeSeparators(fn))
コード例 #10
0
 def on_idlButton_clicked(self):
     """
     Private slot to handle the IDL compiler selection.
     """
     file = KQFileDialog.getOpenFileName(\
         self,
         self.trUtf8("Select IDL compiler"),
         self.idlEdit.text(),
         QString())
         
     if not file.isNull():
         self.idlEdit.setText(Utilities.toNativeSeparators(file))
コード例 #11
0
 def on_iconButton_clicked(self):
     """
     Private slot to handle the icon selection via a file selection dialog.
     """
     icon = KQFileDialog.getOpenFileName(\
         self,
         self.trUtf8("Select icon file"),
         self.iconEdit.text(),
         self.trUtf8("Icon files (*.png)"),
         None)
     if not icon.isEmpty():
         self.iconEdit.setText(icon)
コード例 #12
0
 def on_fileButton_clicked(self):
     """
     Private slot to select a file via a file selection dialog.
     """
     file = KQFileDialog.getOpenFileName(\
         self,
         self.trUtf8("Select filename of the breakpoint"),
         self.filenameCombo.currentText(),
         QString())
         
     if not file.isNull():
         self.filenameCombo.setEditText(Utilities.toNativeSeparators(file))
コード例 #13
0
 def on_customViewerSelectionButton_clicked(self):
     """
     Private slot to handle the custom viewer selection.
     """
     file = KQFileDialog.getOpenFileName(\
         self,
         self.trUtf8("Select Custom Viewer"),
         self.customViewerEdit.text(),
         QString())
     
     if not file.isNull():
         self.customViewerEdit.setText(Utilities.toNativeSeparators(file))
コード例 #14
0
 def __import(self):
     """
     Private slot to handle the Import context menu action.
     """
     fn = KQFileDialog.getOpenFileName(\
         self,
         self.trUtf8("Import Templates"),
         QString(),
         self.trUtf8("Templates Files (*.e3c *.e4c);; All Files (*)"))
     
     if not fn.isEmpty():
         self.readTemplates(fn)
コード例 #15
0
 def on_exceptFileButton_clicked(self):
     """
     Private slot to select a file to exempt from translation.
     """
     texcept = KQFileDialog.getOpenFileName(\
         self,
         self.trUtf8("Exempt file from translation"),
         self.project.ppath,
         self.filters,
         None)
     if not texcept.isEmpty():
         self.exceptionEdit.setText(Utilities.toNativeSeparators(texcept))
コード例 #16
0
 def on_pelButton_clicked(self):
     """
     Private method to select the personal exclude list file.
     """
     file = KQFileDialog.getOpenFileName(\
         self,
         self.trUtf8("Select personal exclude list"),
         self.pelEdit.text(),
         self.trUtf8("Dictionary File (*.dic);;All Files (*)"))
         
     if not file.isEmpty():
         self.pelEdit.setText(Utilities.toNativeSeparators(file))
コード例 #17
0
 def importBookmarks(self):
     """
     Public method to import bookmarks.
     """
     supportedFormats = QStringList() \
         << self.trUtf8("XBEL bookmarks").append(" (*.xbel *.xml)") \
         << self.trUtf8("HTML Netscape bookmarks").append(" (*.html *.htm)")
     
     fileName = KQFileDialog.getOpenFileName(\
         None,
         self.trUtf8("Import Bookmarks"),
         QString(),
         supportedFormats.join(";;"),
         None)
     if fileName.isEmpty():
         return
     
     reader = XbelReader()
     importRootNode = None
     if fileName.endsWith(".html"):
         inFile = QFile(fileName)
         inFile.open(QIODevice.ReadOnly)
         if inFile.openMode == QIODevice.NotOpen:
             KQMessageBox.warning(None,
                 self.trUtf8("Import Bookmarks"),
                 self.trUtf8("""Error opening bookmarks file <b>%1</b>.""")\
                     .arg(fileName))
             return
         
         webpage = QWebPage()
         webpage.mainFrame().setHtml(QString(inFile.readAll()))
         result = webpage.mainFrame().evaluateJavaScript(extract_js).toByteArray()
         buffer_ = QBuffer(result)
         buffer_.open(QIODevice.ReadOnly)
         importRootNode = reader.read(buffer_)
     else:
         importRootNode = reader.read(fileName)
     
     if reader.error() != QXmlStreamReader.NoError:
         KQMessageBox.warning(None,
             self.trUtf8("Import Bookmarks"),
             self.trUtf8("""Error when importing bookmarks on line %1, column %2:\n"""
                         """%3""")\
                 .arg(reader.lineNumber())\
                 .arg(reader.columnNumber())\
                 .arg(reader.errorString()))
         return
     
     importRootNode.setType(BookmarkNode.Folder)
     importRootNode.title = self.trUtf8("Imported %1")\
         .arg(QDate.currentDate().toString(Qt.SystemLocaleShortDate))
     self.addBookmark(self.menu(), importRootNode)
コード例 #18
0
 def on_debugClientButton_clicked(self):
     """
     Private slot to handle the Debug Client selection.
     """
     file = KQFileDialog.getOpenFileName(\
         None,
         self.trUtf8("Select Debug Client"),
         self.debugClientEdit.text(),
         self.trUtf8("Python Files (*.py)"))
         
     if not file.isEmpty():
         self.debugClientEdit.setText(\
             Utilities.toNativeSeparators(file))
コード例 #19
0
    def on_apiFileButton_clicked(self):
        """
        Private method to select an api file.
        """
        file = KQFileDialog.getOpenFileName(
            self,
            self.trUtf8("Select API file"),
            self.apiFileEdit.text(),
            self.trUtf8("API File (*.api);;All Files (*)"),
        )

        if not file.isEmpty():
            self.apiFileEdit.setText(Utilities.toNativeSeparators(file))
コード例 #20
0
    def on_fileButton_clicked(self):
        """
        Private slot to display a file selection dialog.
        """
        startdir = self.filenameEdit.text()
        if startdir.isEmpty() and self.startdir is not None:
            startdir = self.startdir
            projectFile = KQFileDialog.getOpenFileName(
                self, self.trUtf8("Add Project"), startdir, self.trUtf8("Project Files (*.e4p *.e4pz)"), None
            )

        if not projectFile.isEmpty():
            self.filenameEdit.setText(Utilities.toNativeSeparators(projectFile))
コード例 #21
0
 def on_styleSheetButton_clicked(self):
     """
     Private method to select the style sheet file via a dialog.
     """
     file = KQFileDialog.getOpenFileName(\
         self,
         self.trUtf8("Select style sheet file"),
         self.styleSheetEdit.text(),
         self.trUtf8("Qt Style Sheets (*.qss);;Cascading Style Sheets (*.css);;"
                     "All files (*)"),
         None)
     
     if not file.isEmpty():
         self.styleSheetEdit.setText(Utilities.toNativeSeparators(file))
コード例 #22
0
 def on_debugClientButton_clicked(self):
     """
     Private slot to handle the Debug Client selection.
     """
     filters = QString(self.project.dbgFilters[self.project.pdata["PROGLANGUAGE"][0]])
     filters.append(self.trUtf8("All Files (*)"))
     file = KQFileDialog.getOpenFileName(\
         self,
         self.trUtf8("Select Debug Client"),
         self.debugClientEdit.text(),
         filters)
         
     if not file.isNull():
         self.debugClientEdit.setText(Utilities.toNativeSeparators(file))
コード例 #23
0
 def on_databaseFileButton_clicked(self):
     """
     Private slot to open a database file via a file selection dialog.
     """
     startdir = self.databaseEdit.text()
     dbFile = KQFileDialog.getOpenFileName(
         self,
         self.trUtf8("Select Database File"),
         startdir,
         self.trUtf8("All Files (*)"),
         None)
     
     if not dbFile.isEmpty():
         self.databaseEdit.setText(Utilities.toNativeSeparators(dbFile))
コード例 #24
0
 def __selectFile(self, lineEdit):
     """
     Private slot to display a file selection dialog.
     
     @param lineEdit field for the display of the selected filename
             (QLineEdit)
     """
     filename = KQFileDialog.getOpenFileName(\
         self,
         self.trUtf8("Select file to compare"),
         lineEdit.text(),
         QString())
         
     if not filename.isEmpty():
         lineEdit.setText(Utilities.toNativeSeparators(filename))
コード例 #25
0
 def on_pelButton_clicked(self):
     """
     Private slot to select the project exclude list file.
     """
     pel = self.pelEdit.text()
     if pel.isEmpty():
         pel = self.project.ppath
     file = KQFileDialog.getOpenFileName(\
         self,
         self.trUtf8("Select project exclude list"),
         pel,
         self.trUtf8("Dictionary File (*.dic);;All Files (*)"))
         
     if not file.isEmpty():
         self.pelEdit.setText(Utilities.toNativeSeparators(file))
コード例 #26
0
 def on_cssButton_clicked(self):
     """
     Private slot to select a css style sheet.
     """
     cssFile = KQFileDialog.getOpenFileName(\
         self,
         self.trUtf8("Select CSS style sheet"),
         getConfig('ericCSSDir'),
         self.trUtf8("Style sheet (*.css);;All files (*)"))
         
     if not cssFile.isEmpty():
         # make it relative, if it is in a subdirectory of the project path 
         cf = unicode(Utilities.toNativeSeparators(cssFile))
         cf = self.project.getRelativePath(cf)
         self.cssEdit.setText(cf)
コード例 #27
0
 def on_transPatternButton_clicked(self):
     """
     Private slot to display a file selection dialog.
     """
     tp = self.transPatternEdit.text()
     if tp.contains("%language%"):
         tp = tp.section("%language%", 0, 0)
     tsfile = KQFileDialog.getOpenFileName(\
         self,
         self.trUtf8("Select translation file"),
         tp,
         QString(),
         None)
     
     if not tsfile.isEmpty():
         self.transPatternEdit.setText(Utilities.toNativeSeparators(tsfile))
コード例 #28
0
 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
     @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 = KQFileDialog.getOpenFileName(\
             self.parent(),
             self.trUtf8("Open multiproject"),
             Preferences.getMultiProject("Workspace") or Utilities.getHomeDir(),
             self.trUtf8("Multiproject Files (*.e4m *.e4mz)"))
         
         if fn.isEmpty():
             fn = None
         else:
             fn = unicode(fn)
     
     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.emit(SIGNAL('multiProjectOpened'))
             
             if openMaster and Preferences.getMultiProject("OpenMasterAutomatically"):
                 self.__openMasterProject(False)
         else:
             QApplication.restoreOverrideCursor()
コード例 #29
0
 def on_executableButton_clicked(self):
     """
     Private slot to handle the executable selection via a file selection dialog.
     """
     execfile = KQFileDialog.getOpenFileName(\
         self,
         self.trUtf8("Select executable"),
         self.executableEdit.text(),
         QString())
     if not execfile.isEmpty():
         execfile = unicode(Utilities.toNativeSeparators(execfile))
         if not Utilities.isinpath(execfile):
             KQMessageBox.critical(self,
                 self.trUtf8("Select executable"),
                 self.trUtf8("The selected file is not an executable."
                     " Please choose an executable filename."))
             return
         
         self.executableEdit.setText(execfile)
コード例 #30
0
 def on_loadButton_clicked(self):
     """
     Private slot to load a regexp from a file.
     """
     fname = KQFileDialog.getOpenFileName(\
         self,
         self.trUtf8("Load regular expression"),
         QString(),
         self.trUtf8("RegExp Files (*.rx);;All Files (*)"),
         None)
     if not fname.isEmpty():
         try:
             f=open(unicode(Utilities.toNativeSeparators(fname)), "rb")
             regexp = f.read()
             f.close()
             self.regexpLineEdit.setText(regexp)
         except IOError, err:
             KQMessageBox.information(self,
                 self.trUtf8("Save regular expression"),
                 self.trUtf8("""<p>The regular expression could not be saved.</p>"""
                             """<p>Reason: %1</p>""").arg(str(err)))