diff --git a/src/Mod/Draft/Resources/ui/dialog_AnnotationStyleEditor.ui b/src/Mod/Draft/Resources/ui/dialog_AnnotationStyleEditor.ui
index 2df87d5e94..98ab464e5b 100644
--- a/src/Mod/Draft/Resources/ui/dialog_AnnotationStyleEditor.ui
+++ b/src/Mod/Draft/Resources/ui/dialog_AnnotationStyleEditor.ui
@@ -6,8 +6,8 @@
0
0
- 453
- 424
+ 416
+ 542
@@ -22,6 +22,18 @@
-
+
+
+ 0
+ 0
+
+
+
+
+ 60
+ 0
+
+
The name of your style. Existing style names can be edited.
@@ -46,11 +58,17 @@
false
-
+
0
0
+
+
+ 60
+ 0
+
+
110
@@ -71,11 +89,17 @@
false
-
+
0
0
+
+
+ 60
+ 0
+
+
110
@@ -90,6 +114,26 @@
+ -
+
+
+ Import styles from json file
+
+
+
+
+
+
+ -
+
+
+ Export styles to json file
+
+
+
+
+
+
@@ -108,8 +152,8 @@
0
- -290
- 420
+ 0
+ 383
589
@@ -152,6 +196,18 @@
-
+
+
+ 0
+ 0
+
+
+
+
+ 60
+ 0
+
+
The font to use for texts and dimensions
@@ -400,6 +456,18 @@
-
+
+
+ 0
+ 0
+
+
+
+
+ 60
+ 0
+
+
The type of arrows or markers to use at the end of dimension lines
diff --git a/src/Mod/Draft/draftguitools/gui_annotationstyleeditor.py b/src/Mod/Draft/draftguitools/gui_annotationstyleeditor.py
index ffeaca51b4..82be6d8539 100644
--- a/src/Mod/Draft/draftguitools/gui_annotationstyleeditor.py
+++ b/src/Mod/Draft/draftguitools/gui_annotationstyleeditor.py
@@ -111,6 +111,8 @@ class AnnotationStyleEditor(gui_base.GuiCommandSimplest):
self.form.pushButtonRename.setIcon(QtGui.QIcon(":/icons/accessories-text-editor.svg"))
self.form.pushButtonDelete.resize(self.form.pushButtonDelete.sizeHint())
self.form.pushButtonRename.resize(self.form.pushButtonRename.sizeHint())
+ self.form.pushButtonImport.setIcon(QtGui.QIcon(":/icons/Std_Import.svg"))
+ self.form.pushButtonExport.setIcon(QtGui.QIcon(":/icons/Std_Export.svg"))
# fill the styles combo
self.styles = self.read_meta()
@@ -121,6 +123,8 @@ class AnnotationStyleEditor(gui_base.GuiCommandSimplest):
self.form.comboBoxStyles.currentIndexChanged.connect(self.on_style_changed)
self.form.pushButtonDelete.clicked.connect(self.on_delete)
self.form.pushButtonRename.clicked.connect(self.on_rename)
+ self.form.pushButtonImport.clicked.connect(self.on_import)
+ self.form.pushButtonExport.clicked.connect(self.on_export)
for attr in DEFAULT.keys():
control = getattr(self.form, attr)
for signal in ("clicked", "textChanged",
@@ -280,6 +284,42 @@ class AnnotationStyleEditor(gui_base.GuiCommandSimplest):
self.styles[newname] = value
self.renamed[style] = newname
+
+ def on_import(self):
+ """imports styles from a json file"""
+ filename = QtGui.QFileDialog.getOpenFileName(
+ QtGui.QApplication.activeWindow(),
+ _tr("Open styles file"),
+ None,
+ _tr("JSON file (*.json)"))
+ if filename and filename[0]:
+ with open(filename[0]) as f:
+ nstyles = json.load(f)
+ if nstyles:
+ self.styles.update(nstyles)
+ l1 = self.form.comboBoxStyles.itemText(0)
+ l2 = self.form.comboBoxStyles.itemText(1)
+ self.form.comboBoxStyles.clear()
+ self.form.comboBoxStyles.addItem(l1)
+ self.form.comboBoxStyles.addItem(l2)
+ for style in self.styles.keys():
+ self.form.comboBoxStyles.addItem(style)
+ print("Styles updated from "+filename[0])
+
+
+ def on_export(self):
+ """exports styles to a json file"""
+ filename = QtGui.QFileDialog.getSaveFileName(
+ QtGui.QApplication.activeWindow(),
+ _tr("Save styles file"),
+ None,
+ _tr("JSON file (*.json)"))
+ if filename and filename[0]:
+ with open(filename[0],"w") as f:
+ json.dump(self.styles,f,indent=4)
+ print("Styles saved to "+filename[0])
+
+
def fill_editor(self, style):
"""Fill the editor fields with the contents of a style."""
if style is None: