Skip to content

Commit 5606e69

Browse files
committed
added workbench import
1 parent c18af19 commit 5606e69

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

qgist/workbench/dtype_fsm.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -202,6 +202,28 @@ def save_workbench(self, name, mainwindow):
202202

203203
self._update_config()
204204

205+
def import_workbench(self, workbench_dict, mainwindow):
206+
207+
if not isinstance(workbench_dict, str):
208+
raise QgistTypeError(translate('global', '"workbench_dict" must be dict. (dtype_fsm import)'))
209+
if 'name' not in workbench_dict.keys():
210+
raise QgistValueError(translate('global', '"workbench_dict" does not contain a name. (dtype_fsm import)'))
211+
if not isinstance(mainwindow, QMainWindow):
212+
raise QgistTypeError(translate('global', '"mainwindow" must be a QGis mainwindow. (dtype_fsm import)'))
213+
214+
name = workbench_dict['name']
215+
216+
if name in self._workbench_dict.keys():
217+
raise QgistWorkbenchNameError(translate('global', '"name" is a known workbench, i.e. already exists. (dtype_fsm import)'))
218+
if len(name) == 0:
219+
raise QgistWorkbenchNameError(translate('global', '"name" is empty. (dtype_fsm import)'))
220+
221+
self._workbench_dict[name] = dtype_workbench_class(
222+
mainwindow = mainwindow, config = self._config, **workbench_dict
223+
)
224+
225+
self._update_config()
226+
205227
def export_workbench(self, name):
206228

207229
if not isinstance(name, str):

0 commit comments

Comments
 (0)