diff --git a/bec_widgets/widgets/vscode/register_vscode.py b/bec_widgets/widgets/vscode/register_vscode.py new file mode 100644 index 00000000..ed313a1d --- /dev/null +++ b/bec_widgets/widgets/vscode/register_vscode.py @@ -0,0 +1,15 @@ +def main(): # pragma: no cover + from qtpy import PYSIDE6 + + if not PYSIDE6: + print("PYSIDE6 is not available in the environment. Cannot patch designer.") + return + from PySide6.QtDesigner import QPyDesignerCustomWidgetCollection + + from bec_widgets.widgets.vscode.vscode_plugin import VSCodeEditorPlugin + + QPyDesignerCustomWidgetCollection.addCustomWidget(VSCodeEditorPlugin()) + + +if __name__ == "__main__": # pragma: no cover + main() diff --git a/bec_widgets/widgets/vscode/vscode.pyproject b/bec_widgets/widgets/vscode/vscode.pyproject new file mode 100644 index 00000000..4cb76cdd --- /dev/null +++ b/bec_widgets/widgets/vscode/vscode.pyproject @@ -0,0 +1,3 @@ +{ + "files": ["vscode.py"] +} diff --git a/bec_widgets/widgets/vscode/vscode_plugin.py b/bec_widgets/widgets/vscode/vscode_plugin.py new file mode 100644 index 00000000..a761b37d --- /dev/null +++ b/bec_widgets/widgets/vscode/vscode_plugin.py @@ -0,0 +1,54 @@ +# Copyright (C) 2022 The Qt Company Ltd. +# SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause + +from qtpy.QtDesigner import QDesignerCustomWidgetInterface +from qtpy.QtGui import QIcon + +from bec_widgets.widgets.vscode.vscode import VSCodeEditor + +DOM_XML = """ + + + + +""" + + +class VSCodeEditorPlugin(QDesignerCustomWidgetInterface): # pragma: no cover + def __init__(self): + super().__init__() + self._form_editor = None + + def createWidget(self, parent): + t = VSCodeEditor(parent) + return t + + def domXml(self): + return DOM_XML + + def group(self): + return "" + + def icon(self): + return QIcon() + + def includeFile(self): + return "vscode" + + def initialize(self, form_editor): + self._form_editor = form_editor + + def isContainer(self): + return False + + def isInitialized(self): + return self._form_editor is not None + + def name(self): + return "VSCodeEditor" + + def toolTip(self): + return "VSCodeEditor widget" + + def whatsThis(self): + return self.toolTip()