Skip to content

Commit

Permalink
Extras are a dict now
Browse files Browse the repository at this point in the history
  • Loading branch information
mporcheron committed Jun 22, 2020
1 parent 30f045d commit 560a6aa
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 10 deletions.
3 changes: 2 additions & 1 deletion nottreal/controllers/c_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ def ready(self):
method=self._new_config_directory,
default=str(Path.home()),
restorable=False,
extras=[WizardOption.FILES_SAVE])
extras={'action': WizardOption.FILES_ACTION_SAVE})
self.register_option(self._opt_config_dir_new)

self._opt_config_dir = WizardOption(
Expand All @@ -69,6 +69,7 @@ def ready(self):
choose=WizardOption.CHOOSE_DIRECTORY,
method=self._set_config_directory,
default=str(Path.home()),
extras={'action': WizardOption.FILES_ACTION_OPEN},
restorable=False)
self.register_option(self._opt_config_dir)

Expand Down
10 changes: 5 additions & 5 deletions nottreal/models/m_mvc.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,14 @@ class WizardOption:
CAT_OUTPUT {int} -- Identifier for options relating to the
visual output
FILES_SAVE {int} -- Show a file for saving
FILE_OPEN {int} -- Show a file for opening
FILES_ACTION_SAVE {int} -- Show a file for saving
FILE_ACTION_OPEN {int} -- Show a file for opening
appstate {instance}-- App state controller
"""
CHOOSE_BOOLEAN, CHOOSE_SINGLE_CHOICE, CHOOSE_DIRECTORY = range(3)
CAT_CORE, CAT_WIZARD, CAT_VOICE, CAT_INPUT, CAT_OUTPUT = range(5)
FILES_SAVE, FILES_OPEN = range(10, 12)
FILES_ACTION_SAVE, FILES_ACTION_OPEN = range(10, 12)

appstate = None

Expand All @@ -281,7 +281,7 @@ def __init__(self,
group=49,
restorable=False,
restore=True,
extras=[]):
extras={}):
"""
Create a runtime Wizard option
Expand All @@ -305,7 +305,7 @@ def __init__(self,
grouping {int} -- Grouping of options
restorable {bool} -- Save/restore value to app state
restore {bool} -- Restore if restorable
extras {[mixed]} -- Extra information
extras {dict} -- Extra information
"""
self.key = key
self.label = label
Expand Down
11 changes: 7 additions & 4 deletions nottreal/views/v_wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,13 +811,16 @@ def _on_option_directory_triggered(self):
dialog = QFileDialog(self, option.label, option.value)
dialog.setFileMode(QFileDialog.Directory)

for extra in iter(option.extras):
if extra == WizardOption.FILES_SAVE:
try:
if option.extras['action'] == WizardOption.FILES_ACTION_SAVE:
dialog.setAcceptMode(QFileDialog.AcceptSave)
elif extra == WizardOption.FILES_OPEN:
elif option.extras['action'] == WizardOption.FILES_ACTION_OPEN:
dialog.setAcceptMode(QFileDialog.AcceptOpen)
except AttributeError:
pass

if dialog.exec_():
response = dialog.exec_()
if response:
directory = dialog.selectedFiles()
option.change(directory[0])

Expand Down

0 comments on commit 560a6aa

Please sign in to comment.