Skip to content
Snippets Groups Projects

WIP: Library editor

Closed Jaden DIEFENBAUGH requested to merge library-editor-178 into v2
Files
3
@@ -29,6 +29,7 @@ from PyQt5.QtWidgets import QTabWidget
from PyQt5.QtWidgets import QTextEdit
from PyQt5.QtWidgets import QVBoxLayout
from PyQt5.QtWidgets import QWidget
from .library import LibraryEditorWidget
class AssetWidget(QWidget):
@@ -56,18 +57,54 @@ class AssetWidget(QWidget):
self.watcher = QFileSystemWatcher()
self.watcher.fileChanged.connect(self.show_json)
self.watcher.fileChanged.connect(self.update_editor_path)
def show_json(self, file_path):
""" Display the content of the file given in parameter
def update_editor_path(self, file_path):
""" Updates the editor to view the given JSON file
:param file_path: path to the json file to load
:param file_path: path to the json file to view & edit
"""
files = self.watcher.files()
if files:
self.watcher.removePaths(files)
self.watcher.addPath(file_path)
self.show_editor_for_path(file_path)
self.show_json(file_path)
def show_json(self, file_path):
""" Display the content of the file given in parameter
:param file_path: path to the json file to load
"""
with open(file_path) as json_file:
self.jsonWidget.setText(json_file.read())
contents = json_file.read()
self.jsonWidget.setText(contents)
def show_editor_for_path(self, file_path):
""" Changes the editor tab to the correct editor
:param file_path: path to the json file to edit
"""
self.editor = QWidget()
if "/databases/" in file_path:
pass
elif "/dataformats/" in file_path:
pass
elif "/libraries/" in file_path:
self.editor = LibraryEditorWidget(file_path, self)
elif "/algorithms/" in file_path:
pass
elif "/toolchains/" in file_path:
pass
elif "/experiments/" in file_path:
pass
elif "/plotters/" in file_path:
pass
elif "/plotterparameters/" in file_path:
pass
self.tabWidget.removeTab(0)
self.tabWidget.insertTab(0, self.editor, self.tr("Editor"))
self.tabWidget.setCurrentIndex(0)
Loading