Skip to content

Commit

Permalink
EMSUSD-1984 collection tab look
Browse files Browse the repository at this point in the history
- Make tabs be themeable by the Theme class.
- Create a MayaTheme to theme the tab to look right in Maya.
- Make the collection widget theme its tab using the Theme class.
- Only inject Host and Theme once.
  • Loading branch information
pierrebai-adsk committed Jan 14, 2025
1 parent 0bee92d commit 92a4ce0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ def __init__(
self._tabWidget = QTabWidget()
self._tabWidget.setTabBar(NonScrollingTabBar(self._tabWidget))
self._tabWidget.currentChanged.connect(self.onTabChanged)
self._tabWidget.setDocumentMode(True)

self._expressionWidget = ExpressionWidget(self._collData, self._tabWidget)
self._tabWidget.addTab(self._includeExcludeWidget, QIcon(), "Include/Exclude")
Expand All @@ -60,8 +59,7 @@ def __init__(
self._includeExcludeWidget.setContentsMargins(0, offset, 0, 0)
self._expressionWidget.setContentsMargins(0, offset, 0, 0)

self._tabWidget.tabBar().setExpanding(True)
self._tabWidget.tabBar().setCursor(Qt.ArrowCursor)
Theme.instance().themeTab(self._tabWidget)
mainLayout.addWidget(self._tabWidget)
else:
mainLayout.addWidget(self._includeExcludeWidget)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
from PySide6 import QtSvg
from PySide6.QtCore import QRect, Qt # type: ignore
from PySide6.QtGui import QImage, QPixmap, QPalette, QPainter, QColor, QPen, QIcon # type: ignore
from PySide6.QtWidgets import QWidget # type: ignore
from PySide6.QtWidgets import QWidget, QTabWidget # type: ignore
except:
from PySide2 import QtSvg # type: ignore
from PySide2.QtCore import QRect, Qt # type: ignore
from PySide2.QtGui import QImage, QPixmap, QPalette, QPainter, QColor, QPen, QIcon # type: ignore
from PySide2.QtWidgets import QWidget # type: ignore
from PySide2.QtWidgets import QWidget, QTabWidget # type: ignore

from enum import Flag, auto
from typing import Union
Expand Down Expand Up @@ -102,6 +102,9 @@ def themedIcon(self, name: str, theme: str) -> QIcon:
result.addPixmap(pixmap)

return result

def themeTab(self, tab: QTabWidget):
tab.tabBar().setCursor(Qt.ArrowCursor)

@property
def palette(self) -> Palette:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@

from usd_shared_components.collection.widget import CollectionWidget # type: ignore
from usd_shared_components.common.host import Host # type: ignore
from usd_shared_components.common.theme import Theme # type: ignore

from .collectionMayaHost import MayaHost
from .collectionMayaHost import MayaHost, MayaTheme

class CollectionCustomControl(object):
'''Custom control for the light linking data we want to display.'''
Expand Down Expand Up @@ -65,7 +66,9 @@ def onCreate(self, *args):
ptr = MQtUtil.findControl(self.parent)
parentWidget = wrapInstance(int(ptr), QWidget)

Host.injectInstance(MayaHost())
if Host._instance is None:
Host.injectInstance(MayaHost())
Theme.injectInstance(MayaTheme())
self.widget = CollectionWidget(self.prim, Usd.CollectionAPI.Get(self.prim, self.instanceName))
parentWidget.layout().addWidget(self.widget)

Expand Down
10 changes: 10 additions & 0 deletions lib/mayaUsd/resources/ae/usdschemabase/collectionMayaHost.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@

from usd_shared_components.common.host import Host
from usd_shared_components.common.theme import Theme
from usd_shared_components.usdData.usdCollectionData import UsdCollectionData
from usd_shared_components.usdData.usdCollectionStringListData import CollectionStringListData

Expand Down Expand Up @@ -307,6 +308,15 @@ def removeStrings(self, items: Sequence[AnyStr]):
with _UsdUndoBlockContext(_RemoveItemsCommand.commandName):
super().removeStrings(items)

class MayaTheme(Theme):
def __init__(self):
self._palette = None
self._icons = {}

def themeTab(self, tab):
super().themeTab(tab)
tab.setDocumentMode(False)
tab.tabBar().setExpanding(False)

class MayaHost(Host):
'''Class to host and override Maya-specific functions for the collection API.'''
Expand Down

0 comments on commit 92a4ce0

Please sign in to comment.