File: QDialog.sc

package info (click to toggle)
supercollider 1%3A3.13.0%2Brepack-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 80,292 kB
  • sloc: cpp: 476,363; lisp: 84,680; ansic: 77,685; sh: 25,509; python: 7,909; makefile: 3,440; perl: 1,964; javascript: 974; xml: 826; java: 677; yacc: 314; lex: 175; objc: 152; ruby: 136
file content (52 lines) | stat: -rw-r--r-- 1,391 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
FileDialog : QObject {
	*qtClass { ^'QcFileDialog' }

	*new { arg okFunc, cancelFunc, fileMode = 1, acceptMode = 0, stripResult = false, path;
		/**
		fileMode:
			QFileDialog::AnyFile		0	The name of a file, whether it exists or not.
			QFileDialog::ExistingFile	1	The name of a single existing file.
			QFileDialog::Directory		2	The name of a directory. Both files and directories are displayed.
			QFileDialog::ExistingFiles	3	The names of zero or more existing files.
		acceptMode:
			QFileDialog::AcceptOpen		0
			QFileDialog::AcceptSave		1

		stripResult:
			true: okFunc(path1, path2, path3)
			false: okFunc(paths)
		**/

		var me = super.new([fileMode, acceptMode, path]);

		if( okFunc.notNil ) {
			me.connectFunction( 'accepted(QVariantList)', {
				|me, result|
				if( stripResult )
				{ okFunc.performList(\value, result) }
				{ okFunc.value(result) }
			});
		};

		if( cancelFunc.notNil ) {
			me.connectFunction( 'rejected()', { cancelFunc.value() } );
		};

		me.invokeMethod('show', synchronous:false);

		^me;
	}
}

Dialog {

	*openPanel { arg okFunc, cancelFunc, multipleSelection = false, path;
		var fileMode;
		if( multipleSelection ) { fileMode = 3 } { fileMode = 1 };
		^FileDialog.new( okFunc, cancelFunc, fileMode, 0, multipleSelection.not, path );
	}

	*savePanel { arg okFunc, cancelFunc, path;
		^FileDialog.new( okFunc, cancelFunc, 0, 1, true, path );
	}
}