fixed settings and widget of example addon

This commit is contained in:
iLLiCiTiT 2021-09-07 12:11:18 +02:00
parent 3dd6903251
commit 8c37b2b141
8 changed files with 46 additions and 7 deletions

View file

@ -6,8 +6,10 @@ be found by OpenPype discovery.
from .addon import (
AddonSettingsDef,
ExampleAddon
)
__all__ = (
"AddonSettingsDef",
"ExampleAddon"
)

View file

@ -31,7 +31,7 @@ class AddonSettingsDef(JsonFilesSettingsDef):
# recommended as schemas and templates may have name clashes across
# multiple addons
# - it is also recommended that prefix has addon name in it
schema_prefix = "addon_with_settings"
schema_prefix = "example_addon"
def get_settings_root_path(self):
"""Implemented abstract class of JsonFilesSettingsDef.
@ -67,6 +67,14 @@ class ExampleAddon(OpenPypeAddOn, IPluginPaths, ITrayAction):
# UI which must not be created at this time
self._dialog = None
def tray_init(self):
"""Implementation of abstract method for `ITrayAction`.
We're definetely in trat tool so we can precreate dialog.
"""
self._create_dialog()
def connect_with_modules(self, enabled_modules):
"""Method where you should find connected modules.

View file

@ -1 +1,15 @@
{}
{
"project_settings/example_addon": {
"number": 0,
"color_1": [
0.0,
0.0,
0.0
],
"color_2": [
0.0,
0.0,
0.0
]
}
}

View file

@ -0,0 +1,5 @@
{
"modules/example_addon": {
"enabled": true
}
}

View file

@ -1,6 +1,6 @@
{
"project_settings/global": {
"type": "schema",
"name": "addon_with_settings/main"
"name": "example_addon/main"
}
}

View file

@ -1,6 +1,6 @@
{
"system_settings/modules": {
"type": "schema",
"name": "addon_with_settings/main"
"name": "example_addon/main"
}
}

View file

@ -1,6 +1,7 @@
{
"type": "dict",
"key": "exmaple_addon",
"key": "example_addon",
"label": "Example addon",
"collapsible": true,
"children": [
{
@ -17,11 +18,11 @@
"template_data": [
{
"name": "color_1",
"lable": "Color 1"
"label": "Color 1"
},
{
"name": "color_2",
"lable": "Color 2"
"label": "Color 2"
}
]
}

View file

@ -1,5 +1,7 @@
from Qt import QtWidgets
from openpype.style import load_stylesheet
class MyExampleDialog(QtWidgets.QDialog):
def __init__(self, parent=None):
@ -18,8 +20,15 @@ class MyExampleDialog(QtWidgets.QDialog):
layout.addWidget(label_widget)
layout.addLayout(btns_layout)
ok_btn.clicked.connect(self._on_ok_clicked)
self._label_widget = label_widget
self.setStyleSheet(load_stylesheet())
def _on_ok_clicked(self):
self.done(1)
def set_connected_modules(self, connected_modules):
if connected_modules:
message = "\n".join(connected_modules)