mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 21:32:15 +01:00
added Experimental tools category to local settings
This commit is contained in:
parent
e1e2f8e9dd
commit
6a68cfd4c9
2 changed files with 96 additions and 0 deletions
|
|
@ -0,0 +1,63 @@
|
|||
from Qt import QtWidgets
|
||||
from openpype.tools.experimental_tools import (
|
||||
ExperimentalTools,
|
||||
LOCAL_EXPERIMENTAL_KEY
|
||||
)
|
||||
|
||||
|
||||
__all__ = (
|
||||
"LocalExperimentalToolsWidgets",
|
||||
"LOCAL_EXPERIMENTAL_KEY"
|
||||
)
|
||||
|
||||
|
||||
class LocalExperimentalToolsWidgets(QtWidgets.QWidget):
|
||||
def __init__(self, parent):
|
||||
super(LocalExperimentalToolsWidgets, self).__init__(parent)
|
||||
|
||||
self._loading_local_settings = False
|
||||
|
||||
layout = QtWidgets.QFormLayout(self)
|
||||
layout.setContentsMargins(0, 0, 0, 0)
|
||||
|
||||
# Label that says there are no experimental tools available
|
||||
empty_label = QtWidgets.QLabel(self)
|
||||
empty_label.setText("There are no experimental tools available.")
|
||||
|
||||
layout.addRow(empty_label)
|
||||
|
||||
experimental_defs = ExperimentalTools()
|
||||
checkboxes_by_identifier = {}
|
||||
for tool in experimental_defs.experimental_tools:
|
||||
checkbox = QtWidgets.QCheckBox(self)
|
||||
label_widget = QtWidgets.QLabel(tool.label, self)
|
||||
checkbox.setToolTip(tool.tooltip)
|
||||
label_widget.setToolTip(tool.tooltip)
|
||||
layout.addRow(label_widget, checkbox)
|
||||
|
||||
checkboxes_by_identifier[tool.identifier] = checkbox
|
||||
|
||||
empty_label.setVisible(len(checkboxes_by_identifier) == 0)
|
||||
|
||||
self._empty_label = empty_label
|
||||
self._checkboxes_by_identifier = checkboxes_by_identifier
|
||||
self._experimental_defs = experimental_defs
|
||||
|
||||
def update_local_settings(self, value):
|
||||
self._loading_local_settings = True
|
||||
value = value or {}
|
||||
|
||||
for identifier, checkbox in self._checkboxes_by_identifier.items():
|
||||
checked = value.get(identifier, False)
|
||||
checkbox.setChecked(checked)
|
||||
|
||||
self._loading_local_settings = False
|
||||
|
||||
def settings_value(self):
|
||||
# Add changed
|
||||
# If these have changed then
|
||||
output = {}
|
||||
for identifier, checkbox in self._checkboxes_by_identifier.items():
|
||||
if checkbox.isChecked():
|
||||
output[identifier] = True
|
||||
return output
|
||||
|
|
@ -20,6 +20,10 @@ from .widgets import (
|
|||
)
|
||||
from .mongo_widget import OpenPypeMongoWidget
|
||||
from .general_widget import LocalGeneralWidgets
|
||||
from .experimental_widget import (
|
||||
LocalExperimentalToolsWidgets,
|
||||
LOCAL_EXPERIMENTAL_KEY
|
||||
)
|
||||
from .apps_widget import LocalApplicationsWidgets
|
||||
from .projects_widget import ProjectSettingsWidget
|
||||
|
||||
|
|
@ -44,11 +48,13 @@ class LocalSettingsWidget(QtWidgets.QWidget):
|
|||
|
||||
self.pype_mongo_widget = None
|
||||
self.general_widget = None
|
||||
self.experimental_widget = None
|
||||
self.apps_widget = None
|
||||
self.projects_widget = None
|
||||
|
||||
self._create_pype_mongo_ui()
|
||||
self._create_general_ui()
|
||||
self._create_experimental_ui()
|
||||
self._create_app_ui()
|
||||
self._create_project_ui()
|
||||
|
||||
|
|
@ -85,6 +91,26 @@ class LocalSettingsWidget(QtWidgets.QWidget):
|
|||
|
||||
self.general_widget = general_widget
|
||||
|
||||
def _create_experimental_ui(self):
|
||||
# General
|
||||
experimental_expand_widget = ExpandingWidget(
|
||||
"Experimental tools", self
|
||||
)
|
||||
|
||||
experimental_content = QtWidgets.QWidget(self)
|
||||
experimental_layout = QtWidgets.QVBoxLayout(experimental_content)
|
||||
experimental_layout.setContentsMargins(CHILD_OFFSET, 5, 0, 0)
|
||||
experimental_expand_widget.set_content_widget(experimental_content)
|
||||
|
||||
experimental_widget = LocalExperimentalToolsWidgets(
|
||||
experimental_content
|
||||
)
|
||||
experimental_layout.addWidget(experimental_widget)
|
||||
|
||||
self.main_layout.addWidget(experimental_expand_widget)
|
||||
|
||||
self.experimental_widget = experimental_widget
|
||||
|
||||
def _create_app_ui(self):
|
||||
# Applications
|
||||
app_expand_widget = ExpandingWidget("Applications", self)
|
||||
|
|
@ -135,6 +161,9 @@ class LocalSettingsWidget(QtWidgets.QWidget):
|
|||
self.projects_widget.update_local_settings(
|
||||
value.get(LOCAL_PROJECTS_KEY)
|
||||
)
|
||||
self.experimental_widget.update_local_settings(
|
||||
value.get(LOCAL_EXPERIMENTAL_KEY)
|
||||
)
|
||||
|
||||
def settings_value(self):
|
||||
output = {}
|
||||
|
|
@ -149,6 +178,10 @@ class LocalSettingsWidget(QtWidgets.QWidget):
|
|||
projects_value = self.projects_widget.settings_value()
|
||||
if projects_value:
|
||||
output[LOCAL_PROJECTS_KEY] = projects_value
|
||||
|
||||
experimental_value = self.experimental_widget.settings_value()
|
||||
if experimental_value:
|
||||
output[LOCAL_EXPERIMENTAL_KEY] = experimental_value
|
||||
return output
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue