mrv.maya.ui.browse.option
Covered: 20 lines
Missed: 25 lines
Skipped 19 lines
Percent: 44 %
 2
"""module with option implementations, to be shown in finder layouts"""
 3
__docformat__ = "restructuredtext"
 5
from interface import iOptions
 6
import mrv.maya.ui as ui
 7
import mrv.maya
 8
import mrv.maya.util
 9
Mel = mrv.maya.Mel
10
opts = mrv.maya.util.optionvars
12
class FileOpenOptions(ui.ColumnLayout, iOptions):
13
	"""Options implementation providing options useful during file-open"""
16
	kOVExecuteScriptNodes = 'fileExecuteSN'
17
	kOVIgnoreVersion = 'fileOpenIgnoreVersion'
18
	kOVSelectivePreload = 'fileSelPreload'
19
	kOVRefLoadSetting = 'fileOpenRefLoadSetting'
22
	def __init__(self):
23
		self._create_ui_elements()
24
		self._restore_saved_values()
26
	def _create_ui_elements(self):
27
		self.cbScriptNodes = ui.CheckBox(label="Execute ScriptNodes", value=1)   
28
		self.cbIgnoreVersion = ui.CheckBox(label="Ignore Version")
30
		self.omReference = ui.OptionMenu(label="Load Settings")
32
		ui.MenuItem(label="Load Default References")
33
		ui.MenuItem(label="Load All References")
34
		ui.MenuItem(label="Load Top References")
35
		ui.MenuItem(label="Load No References")
37
		self.cbSelectivePreload = ui.CheckBox(label="Selective Preload")
39
	def _restore_saved_values(self):
40
		self.cbScriptNodes.p_value = opts.get(self.kOVExecuteScriptNodes, True)
41
		self.cbIgnoreVersion.p_value = opts.get(self.kOVIgnoreVersion, False)
42
		self.cbSelectivePreload.p_value = opts.get(self.kOVSelectivePreload, False)
43
		self.omReference.p_select = opts.get(self.kOVRefLoadSetting, 1)
45
	def fileOptions(self):
46
		""":return: dict with keyword options reflecting the settings of the
47
		interface. These should be given to the file command"""
48
		options = dict()
49
		options['ignoreVersion'] = self.cbIgnoreVersion.p_value
50
		options['executeScriptNodes'] = self.cbScriptNodes.p_value
55
		refsl = self.omReference.p_sl
56
		if refsl == 2:
57
			options['loadAllReferences'] = True
58
		elif refsl == 3:
59
			options['loadReferenceDepth'] = "topOnly"
60
		elif refsl == 4:
61
			options['loadNoReferences'] = True
63
		return options