mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 21:04:40 +01:00
Merge pull request #2420 from pypeclub/feature/OP-2054_Hyperlinks-in-Settings-labels
Settings UI: Hyperlinks to settings
This commit is contained in:
commit
501497089a
3 changed files with 75 additions and 0 deletions
|
|
@ -554,7 +554,9 @@ class GUIWidget(BaseWidget):
|
|||
def _create_label_ui(self):
|
||||
label = self.entity["label"]
|
||||
label_widget = QtWidgets.QLabel(label, self)
|
||||
label_widget.setTextInteractionFlags(QtCore.Qt.TextBrowserInteraction)
|
||||
label_widget.setObjectName("SettingsLabel")
|
||||
label_widget.linkActivated.connect(self._on_link_activate)
|
||||
|
||||
layout = QtWidgets.QHBoxLayout(self)
|
||||
layout.setContentsMargins(0, 5, 0, 5)
|
||||
|
|
@ -570,6 +572,14 @@ class GUIWidget(BaseWidget):
|
|||
layout.setContentsMargins(5, 5, 5, 5)
|
||||
layout.addWidget(splitter_item)
|
||||
|
||||
def _on_link_activate(self, url):
|
||||
if not url.startswith("settings://"):
|
||||
QtGui.QDesktopServices.openUrl(url)
|
||||
return
|
||||
|
||||
path = url.replace("settings://", "")
|
||||
self.category_widget.go_to_fullpath(path)
|
||||
|
||||
def set_entity_value(self):
|
||||
pass
|
||||
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ class SettingsCategoryWidget(QtWidgets.QWidget):
|
|||
state_changed = QtCore.Signal()
|
||||
saved = QtCore.Signal(QtWidgets.QWidget)
|
||||
restart_required_trigger = QtCore.Signal()
|
||||
full_path_requested = QtCore.Signal(str, str)
|
||||
|
||||
def __init__(self, user_role, parent=None):
|
||||
super(SettingsCategoryWidget, self).__init__(parent)
|
||||
|
|
@ -268,6 +269,37 @@ class SettingsCategoryWidget(QtWidgets.QWidget):
|
|||
# Scroll to widget
|
||||
self.scroll_widget.ensureWidgetVisible(widget)
|
||||
|
||||
def go_to_fullpath(self, full_path):
|
||||
"""Full path of settings entity which can lead to different category.
|
||||
|
||||
Args:
|
||||
full_path (str): Full path to settings entity. It is expected that
|
||||
path starts with category name ("system_setting" etc.).
|
||||
"""
|
||||
if not full_path:
|
||||
return
|
||||
items = full_path.split("/")
|
||||
category = items[0]
|
||||
path = ""
|
||||
if len(items) > 1:
|
||||
path = "/".join(items[1:])
|
||||
self.full_path_requested.emit(category, path)
|
||||
|
||||
def contain_category_key(self, category):
|
||||
"""Parent widget ask if category of full path lead to this widget.
|
||||
|
||||
Args:
|
||||
category (str): The category name.
|
||||
|
||||
Returns:
|
||||
bool: Passed category lead to this widget.
|
||||
"""
|
||||
return False
|
||||
|
||||
def set_category_path(self, category, path):
|
||||
"""Change path of widget based on category full path."""
|
||||
pass
|
||||
|
||||
def set_path(self, path):
|
||||
self.breadcrumbs_widget.set_path(path)
|
||||
|
||||
|
|
@ -555,6 +587,14 @@ class SettingsCategoryWidget(QtWidgets.QWidget):
|
|||
|
||||
|
||||
class SystemWidget(SettingsCategoryWidget):
|
||||
def contain_category_key(self, category):
|
||||
if category == "system_settings":
|
||||
return True
|
||||
return False
|
||||
|
||||
def set_category_path(self, category, path):
|
||||
self.breadcrumbs_widget.change_path(path)
|
||||
|
||||
def _create_root_entity(self):
|
||||
self.entity = SystemSettings(set_studio_state=False)
|
||||
self.entity.on_change_callbacks.append(self._on_entity_change)
|
||||
|
|
@ -591,6 +631,21 @@ class SystemWidget(SettingsCategoryWidget):
|
|||
|
||||
|
||||
class ProjectWidget(SettingsCategoryWidget):
|
||||
def contain_category_key(self, category):
|
||||
if category in ("project_settings", "project_anatomy"):
|
||||
return True
|
||||
return False
|
||||
|
||||
def set_category_path(self, category, path):
|
||||
if path:
|
||||
path_items = path.split("/")
|
||||
if path_items[0] not in ("project_settings", "project_anatomy"):
|
||||
path = "/".join([category, path])
|
||||
else:
|
||||
path = category
|
||||
|
||||
self.breadcrumbs_widget.change_path(path)
|
||||
|
||||
def initialize_attributes(self):
|
||||
self.project_name = None
|
||||
|
||||
|
|
|
|||
|
|
@ -63,7 +63,9 @@ class MainWidget(QtWidgets.QWidget):
|
|||
tab_widget.restart_required_trigger.connect(
|
||||
self._on_restart_required
|
||||
)
|
||||
tab_widget.full_path_requested.connect(self._on_full_path_request)
|
||||
|
||||
self._header_tab_widget = header_tab_widget
|
||||
self.tab_widgets = tab_widgets
|
||||
|
||||
def _on_tab_save(self, source_widget):
|
||||
|
|
@ -90,6 +92,14 @@ class MainWidget(QtWidgets.QWidget):
|
|||
if app:
|
||||
app.processEvents()
|
||||
|
||||
def _on_full_path_request(self, category, path):
|
||||
for tab_widget in self.tab_widgets:
|
||||
if tab_widget.contain_category_key(category):
|
||||
idx = self._header_tab_widget.indexOf(tab_widget)
|
||||
self._header_tab_widget.setCurrentIndex(idx)
|
||||
tab_widget.set_category_path(category, path)
|
||||
break
|
||||
|
||||
def showEvent(self, event):
|
||||
super(MainWidget, self).showEvent(event)
|
||||
if self._reset_on_show:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue