Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
beat
beat.editor
Commits
d0c35f98
Commit
d0c35f98
authored
Mar 25, 2019
by
Samuel GAIST
Browse files
[widgets][editor] Add string getter for editor JSON content
parent
73328f6f
Changes
1
Hide whitespace changes
Inline
Side-by-side
beat/editor/widgets/editor.py
View file @
d0c35f98
...
...
@@ -23,6 +23,8 @@
# #
###############################################################################
import
simplejson
as
json
from
PyQt5.QtCore
import
pyqtSignal
from
PyQt5.QtWidgets
import
QFormLayout
...
...
@@ -64,10 +66,12 @@ class AbstractAssetEditor(QWidget):
def
_load_json
(
self
,
json_object
):
"""To be implemented by subclass to load their specific JSON parts"""
raise
NotImplementedError
def
_dump_json
(
self
,
json_object
):
"""To be implemented by subclass to dump their specific JSON parts"""
raise
NotImplementedError
def
set_dirty
(
self
):
...
...
@@ -117,11 +121,17 @@ class AbstractAssetEditor(QWidget):
def
dump_json
(
self
):
"""Returns the json representation of the asset"""
json_data
=
{
"description"
:
self
.
description_lineedit
.
text
()}
json_data
.
update
(
self
.
_dump_json
())
return
json_data
def
dump_as_string
(
self
):
"""Returns the string representation of this editor json"""
return
json
.
dumps
(
self
.
dump_json
(),
sort_keys
=
True
,
indent
=
4
)
class
PlaceholderEditor
(
AbstractAssetEditor
):
"""Placeholder widget providing the API of an editor"""
...
...
@@ -138,8 +148,10 @@ class PlaceholderEditor(AbstractAssetEditor):
def
_load_json
(
self
,
json_object
):
"""Re-imp. Does nothing"""
pass
def
_dump_json
(
self
):
"""Re-imp. Does nothing"""
return
{}
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment