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))
 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
Ejemplo n.º 3
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)
 def __getFileName(self):
     """
     Private method to get the filename to save to from the user.
     
     @return flag indicating success (boolean)
     """
     downloadDirectory = Preferences.getUI("DownloadPath")
     if downloadDirectory.isEmpty():
         downloadDirectory = \
             QDesktopServices.storageLocation(QDesktopServices.DocumentsLocation)
     if not downloadDirectory.isEmpty():
         downloadDirectory += '/'
     
     defaultFileName = self.__saveFileName(downloadDirectory)
     fileName = defaultFileName
     baseName = QFileInfo(fileName).completeBaseName()
     self.__autoOpen = False
     if not self.__toDownload:
         res = KQMessageBox.question(None,
             self.trUtf8("Downloading"),
             self.trUtf8("""<p>You are about to download the file <b>%1</b>.</p>"""
                         """<p>What do you want to do?</p>""").arg(fileName),
             QMessageBox.StandardButtons(\
                 QMessageBox.Open | \
                 QMessageBox.Save | \
                 QMessageBox.Cancel))
         if res == QMessageBox.Cancel:
             self.__stop()
             self.close()
             return False
         
         self.__autoOpen = res == QMessageBox.Open
         fileName = QDesktopServices.storageLocation(QDesktopServices.TempLocation) + \
                     '/' + QFileInfo(fileName).completeBaseName()
     
     if not self.__autoOpen and self.__requestFilename:
         fileName = KQFileDialog.getSaveFileName(\
             None,
             self.trUtf8("Save File"),
             defaultFileName,
             QString(),
             None)
         if fileName.isEmpty():
             self.__reply.close()
             if not self.keepOpenCheckBox.isChecked():
                 self.close()
                 return False
             else:
                 self.filenameLabel.setText(self.trUtf8("Download canceled: %1")\
                     .arg(QFileInfo(defaultFileName).fileName()))
                 self.__stop()
                 return True
     
     self.__output.setFileName(fileName)
     self.filenameLabel.setText(QFileInfo(self.__output.fileName()).fileName())
     if self.__requestFilename:
         self.__readyRead()
     
     return True
Ejemplo n.º 5
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)
 def on_saveButton_clicked(self):
     """
     Private slot to handle the Save button press.
     
     It saves the diff shown in the dialog to a file in the local
     filesystem.
     """
     if type(self.filename) is types.ListType:
         if len(self.filename) > 1:
             fname = self.vcs.splitPathList(self.filename)[0]
         else:
             dname, fname = self.vcs.splitPath(self.filename[0])
             if fname != '.':
                 fname = "%s.diff" % self.filename[0]
             else:
                 fname = dname
     else:
         fname = self.vcs.splitPath(self.filename)[0]
     
     selectedFilter = QString("")
     fname = KQFileDialog.getSaveFileName(\
         self,
         self.trUtf8("Save Diff"),
         fname,
         self.trUtf8("Patch Files (*.diff)"),
         selectedFilter,
         QFileDialog.Options(QFileDialog.DontConfirmOverwrite))
     
     if fname.isEmpty():
         return
     
     ext = QFileInfo(fname).suffix()
     if ext.isEmpty():
         ex = selectedFilter.section('(*',1,1).section(')',0,0)
         if not ex.isEmpty():
             fname.append(ex)
     if QFileInfo(fname).exists():
         res = KQMessageBox.warning(self,
             self.trUtf8("Save Diff"),
             self.trUtf8("<p>The patch file <b>%1</b> already exists.</p>")
                 .arg(fname),
             QMessageBox.StandardButtons(\
                 QMessageBox.Abort | \
                 QMessageBox.Save),
             QMessageBox.Abort)
         if res != QMessageBox.Save:
             return
     fname = unicode(Utilities.toNativeSeparators(fname))
     
     try:
         f = open(fname, "wb")
         f.write(unicode(self.contents.toPlainText()))
         f.close()
     except IOError, why:
         KQMessageBox.critical(self, self.trUtf8('Save Diff'),
             self.trUtf8('<p>The patch file <b>%1</b> could not be saved.'
                 '<br>Reason: %2</p>')
                 .arg(unicode(fname)).arg(str(why)))
Ejemplo n.º 7
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))
Ejemplo n.º 8
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)
 def on_exceptDirButton_clicked(self):
     """
     Private slot to select a file to exempt from translation.
     """
     texcept = KQFileDialog.getExistingDirectory(\
         self,
         self.trUtf8("Exempt directory from translation"),
         self.project.ppath,
         QFileDialog.Options(QFileDialog.ShowDirsOnly))
     if not texcept.isEmpty():
         self.exceptionEdit.setText(Utilities.toNativeSeparators(texcept))
 def on_pathButton_clicked(self):
     """
     Private slot called to open a directory selection dialog.
     """
     path = KQFileDialog.getExistingDirectory(\
         self,
         self.trUtf8("Select source directory"),
         QDir.fromNativeSeparators(self.pathnameEdit.text()),
         QFileDialog.Options(QFileDialog.Option(0)))
     if not path.isEmpty():
         self.pathnameEdit.setText(QDir.toNativeSeparators(path))
 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))
 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)
 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))
 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))
 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))
Ejemplo n.º 16
0
 def __newToplevelDir(self):
     """
     Private slot to handle the New toplevel directory popup menu entry.
     """
     dname = KQFileDialog.getExistingDirectory(\
         None,
         QApplication.translate('Browser', "New toplevel directory"),
         QString(),
         QFileDialog.Options(QFileDialog.ShowDirsOnly))
     if not dname.isEmpty():
         dname = os.path.abspath(unicode(Utilities.toNativeSeparators(dname)))
         self.__model.addTopLevelDir(dname)
 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))
Ejemplo n.º 18
0
 def on_qt4TransButton_clicked(self):
     """
     Private slot to handle the Qt4 translations directory selection.
     """
     dir = KQFileDialog.getExistingDirectory(\
         self,
         self.trUtf8("Select Qt4 Translations Directory"),
         self.qt4TransEdit.text(),
         QFileDialog.Options(QFileDialog.ShowDirsOnly))
         
     if not dir.isNull():
         self.qt4TransEdit.setText(Utilities.toNativeSeparators(dir))
 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))
Ejemplo n.º 20
0
 def on_iconDirectoryButton_clicked(self):
     """
     Private slot to select an icon directory.
     """
     dir = KQFileDialog.getExistingDirectory(\
         None,
         self.trUtf8("Select icon directory"),
         QString(),
         QFileDialog.Options(QFileDialog.ShowDirsOnly))
         
     if not dir.isEmpty():
         self.iconDirectoryEdit.setText(Utilities.toNativeSeparators(dir))
 def on_transBinPathButton_clicked(self):
     """
     Private slot to display a directory selection dialog.
     """
     directory = KQFileDialog.getExistingDirectory(\
         self,
         self.trUtf8("Select directory for binary translations"),
         self.transBinPathEdit.text(),
         QFileDialog.Options(QFileDialog.Option(0)))
     
     if not directory.isEmpty():
         self.transBinPathEdit.setText(Utilities.toNativeSeparators(directory))
 def on_projectDirButton_clicked(self):
     """
     Private slot to display a directory selection dialog.
     """
     directory = KQFileDialog.getExistingDirectory(\
         self,
         self.trUtf8("Select Project Directory"),
         self.vcsProjectDirEdit.text(),
         QFileDialog.Options(QFileDialog.ShowDirsOnly))
     
     if not directory.isEmpty():
         self.vcsProjectDirEdit.setText(Utilities.toNativeSeparators(directory))
 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)
 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))
Ejemplo n.º 25
0
 def on_dirSelectButton_clicked(self):
     """
     Private slot to display a directory selection dialog.
     """
     directory = KQFileDialog.getExistingDirectory(\
         self,
         self.trUtf8("Select directory"),
         self.dirCombo.currentText(),
         QFileDialog.Options(QFileDialog.ShowDirsOnly))
         
     if not directory.isEmpty():
         self.dirCombo.setEditText(Utilities.toNativeSeparators(directory))
Ejemplo n.º 26
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))
 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)
Ejemplo n.º 28
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))
 def on_dirButton_clicked(self):
     """
     Private slot to handle the button press for selecting the target via a 
     selection dialog.
     """
     if os.path.isdir(self.source):
         target = KQFileDialog.getExistingDirectory(\
             None,
             self.trUtf8("Select target"),
             self.targetEdit.text(),
             QFileDialog.Options(QFileDialog.ShowDirsOnly))
     else:
         target = KQFileDialog.getSaveFileName(\
             None,
             self.trUtf8("Select target"),
             self.targetEdit.text(),
             QString(),
             None,
             QFileDialog.Options(QFileDialog.DontConfirmOverwrite))
     
     if not target.isEmpty():
         self.targetEdit.setText(Utilities.toNativeSeparators(target))
Ejemplo n.º 30
0
 def on_dirButton_clicked(self):
     """
     Private method used to open a directory selection dialog.
     """
     cwd = self.ui.workdirCombo.currentText()
     d = KQFileDialog.getExistingDirectory(\
         self,
         self.trUtf8("Working directory"),
         cwd,
         QFileDialog.Options(QFileDialog.ShowDirsOnly))
         
     if not d.isNull() and not d.isEmpty():
         self.ui.workdirCombo.setEditText(Utilities.toNativeSeparators(d))