User Tools

Site Tools


DzFileDialog

Script wrapper for QFileDialog.

More...

Inherits :

Methods

DAZ Script
StringdoAudioClipOpenDialog ( String startWith=“”, DzWidget parent=undefined )
StringdoDirectoryDialog ( String title=“”, String desc=“”, DzWidget parent=undefined )
StringdoDirectoryDialog ( String title, String desc, String startWith, DzWidget parent=undefined )
StringdoFileDialog ( Boolean open, String title=“”, String startWith=“”, String filter=“”, Number selectedFilter=0, DzWidget parent=undefined )
StringdoImageDialog ( Boolean open, String startWith=“”, DzWidget parent=undefined )
StringdoVideoClipSaveDialog ( String startWith=“”, DzWidget parent=undefined )
ArraygetOpenFileNames ( String dir=“”, String filter=“”, String title=“”, DzWidget parent=undefined )

Detailed Description

A global static object available via the Global::FileDialog variable.

This object provides functions that display OS native file dialogs to the user.

Methods


String : doAudioClipOpenDialog( String startWith=“”, DzWidget parent=undefined )

A convenience file dialog that automatically creates a filter list for all audio formats the application can import and displays a file open dialog.

Parameter(s):

  • startWith - The starting directory; can include a default file name.
  • parent - The parent widget for the file dialog.

Return Value:

  • The path of the file selected by the user (if the user does not cancel), otherwise an empty string.

String : doDirectoryDialog( String title=“”, String desc=“”, DzWidget parent=undefined )

Display a dialog for the user to choose a directory.

Parameter(s):

  • title - The title of the dialog box.
  • desc - Unused; retained for backward compatibility.
  • parent - The parent widget for the directory dialog.

Return Value:

  • The path of the directory selected by the user (if the user does not cancel), otherwise an empty string.

Example:

Have the user select a directory.

var sPath = FileDialog.doDirectoryDialog( qsTr("Select a Directory") );

String : doDirectoryDialog( String title, String desc, String startWith, DzWidget parent=undefined )

Display a dialog for the user to choose a directory.

Parameter(s):

  • title - The title of the dialog box.
  • desc - Unused; retained for backward compatibility.
  • startWith - The directory that the dialog will start in.
  • parent - The parent widget for the directory dialog.

Return Value:

  • The path of the directory selected by the user (if the user does not cancel), otherwise an empty string.

Example:

Have the user select a directory.

var sPath = FileDialog.doDirectoryDialog( qsTr("Select a Directory"), "", App.getDocumentsPath() );

String : doFileDialog( Boolean open, String title=“”, String startWith=“”, String filter=“”, Number selectedFilter=0, DzWidget parent=undefined )

Display a dialog for the user to choose a file.

Parameter(s):

  • open - If true, displays an open file dialog, otherwise displays a save file dialog.
  • title - The title of the dialog box.
  • startWith - The starting directory (can include a default file name).
  • filter - The file name filter; e.g., “TIFF files (*.tif *.tiff); JPEG files (*.jpg)”.
  • selectedFilter - If not null, its value is set to the index of the filter that corresponds to the selected file.
  • parent - The parent widget for the file dialog.

Return Value:

  • The path of the file selected by the user (if the user does not cancel), otherwise an empty string.

Example:

Get the name of an existing jpeg file.

var sFilename = FileDialog.doFileDialog( true, qsTr("Select an Image File"), App.getImageMgr().getImportPath(), "JPEG Files (*.jpg)" );

Example:

Get the name of an existing image file (w/ additional filters).

var sFilename = FileDialog.doFileDialog( true, qsTr("Select an Image File"), "",
					"Image Files (*.tif *.tiff *.jpg);TIFF Files (*.tif *.tiff);JPEG Files (*.jpg)" );

Example:

Get the name of a text file to save to.

var sFilename = FileDialog.doFileDialog( false, qsTr("Save As"), "", "Text Files (*.txt)" );

String : doImageDialog( Boolean open, String startWith=“”, DzWidget parent=undefined )

A convenience file dialog that automatically creates a filter list for all image formats the application can import/export and displays a file open/save dialog.

Parameter(s):

  • open - If true, displays an open image dialog, otherwise displays a save image dialog.
  • startWith - The starting directory; can include a default file name.
  • parent - The parent widget for the file dialog.

Return Value:

  • The path of the file selected by the user (if the user does not cancel), otherwise an empty string.

String : doVideoClipSaveDialog( String startWith=“”, DzWidget parent=undefined )

A convenience file dialog that automatically creates a filter list for all video formats the application can export and displays a file save dialog.

Parameter(s):

  • startWith - The starting directory; can include a default file name.
  • parent - The parent widget for the file dialog.

Return Value:

  • The path of the file selected by the user (if the user does not cancel), otherwise an empty string.

Array : getOpenFileNames( String dir=“”, String filter=“”, String title=“”, DzWidget parent=undefined )

Shows an open file dialog to the user that allows selection of multiple files.

Parameter(s):

  • dir - The directory that the dialog will start with.
  • filter - The file name filter; e.g., “TIFF files (*.tif *.tiff); JPEG files (*.jpg)”.
  • title - The title of the dialog.
  • parent - The parent widget of the dialog.

Return Value:

  • A list of paths for the files selected by the user (if the user does not cancel), otherwise an empty list.

Example:

Have the user select one or more image files.

var aFiles = FileDialog.getOpenFileNames( "", "Image files (*.tif *.jpg *.png)", qsTr("Select Image Files") );