def __kdeGetSaveFileName(parent = None, caption = QString(), dir_ = QString(), filter = QString(), selectedFilter = None, options = QFileDialog.Options()): """ Module function to get the name of a file for saving it. @param parent parent widget of the dialog (QWidget) @param caption window title of the dialog (QString) @param dir_ working directory of the dialog (QString) @param filter filter string for the dialog (QString) @param selectedFilter selected filter for the dialog (QString) @param options various options for the dialog (QFileDialog.Options) @return name of file to be saved (QString) """ if not QString(filter).isEmpty(): filter = __convertFilter(filter, selectedFilter) wdir = __workingDirectory(dir_) dlg = KFileDialog(KUrl.fromPath(wdir), filter, parent) if wdir != dir_: dlg.setSelection(dir_) dlg.setOperationMode(KFileDialog.Saving) dlg.setMode(KFile.Modes(KFile.File) | KFile.Modes(KFile.LocalOnly)) dlg.setWindowTitle(caption.isEmpty() and \ QApplication.translate('KFileDialog', 'Save As') or caption) dlg.exec_() if selectedFilter is not None: flt = dlg.currentFilter() flt.prepend("(").append(")") selectedFilter.replace(0, selectedFilter.length(), flt) return dlg.selectedFile()
def __kdeGetExistingDirectory(parent = None, caption = QString(), dir_ = QString(), options = QFileDialog.Options(QFileDialog.ShowDirsOnly)): """ Module function to get the name of a directory. @param parent parent widget of the dialog (QWidget) @param caption window title of the dialog (QString) @param dir_ working directory of the dialog (QString) @param options various options for the dialog (QFileDialog.Options) @return name of selected directory (QString) """ wdir = __workingDirectory(dir_) dlg = KFileDialog(KUrl.fromPath(wdir), QString(), parent) dlg.setOperationMode(KFileDialog.Opening) dlg.setMode(KFile.Modes(KFile.Directory) | KFile.Modes(KFile.LocalOnly) | \ KFile.Modes(KFile.ExistingOnly)) dlg.setWindowTitle(caption.isEmpty() and \ QApplication.translate('KFileDialog', 'Select Directory') or caption) dlg.exec_() return dlg.selectedFile()