Skip to content
This repository was archived by the owner on Apr 15, 2024. It is now read-only.

Commit 9a24c9a

Browse files
authored
Merge pull request #13 from takavfx/develop
Merge for v4.1.0 release. - Add Houdini16 support for Cache Manager - Add optional styling with hqt module
2 parents e4a85b4 + 538ba46 commit 9a24c9a

File tree

3 files changed

+56
-49
lines changed

3 files changed

+56
-49
lines changed

docs/cacheManager.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
## Feature
66

7-
* List cache nodes scatted everywhere in Houdini scene.
7+
* List cache nodes scatterd everywhere in Houdini scene.
88
* Filter Read/Write and Multi type of nodes.
99
* This tool is supported only above on Houdini 15.0.
1010

python2.7libs/CacheManager/cacheWidget.py

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,20 @@
88

99
import sys
1010
sys.dont_write_bytecode = True
11-
1211
import os
1312
import re
1413
import platform
1514
from functools import partial
1615

17-
from PySide import QtCore, QtGui
16+
import imp
17+
try:
18+
imp.find_module('PySide2')
19+
from PySide2.QtWidgets import *
20+
from PySide2.QtGui import *
21+
from PySide2.QtCore import *
22+
except ImportError:
23+
from PySide.QtGui import *
24+
from PySide.QtCore import *
1825

1926
import hou
2027

@@ -30,11 +37,11 @@
3037
#-------------------------------------------------------------------------------
3138
# QTreeWidget for displaying Cache List
3239
#-------------------------------------------------------------------------------
33-
class cacheTreeWidget(QtGui.QTreeWidget):
40+
class cacheTreeWidget(QTreeWidget):
3441
"""docstring for cacheTableView"""
3542

3643
mouseReleased = QtCore.Signal(QtCore.QPoint)
37-
keyPressed = QtCore.Signal(QtGui.QKeyEvent)
44+
keyPressed = QtCore.Signal(QKeyEvent)
3845

3946
HEADER_SETTING = Define.HEADER_SETTING
4047

@@ -54,7 +61,7 @@ def _initUI(self):
5461
self.setHeaderLabels(headerLabels)
5562
self.setSortingEnabled(True)
5663
self.setAlternatingRowColors(True)
57-
self.setSelectionMode(QtGui.QAbstractItemView.ExtendedSelection)
64+
self.setSelectionMode(QAbstractItemView.ExtendedSelection)
5865
self._setHeaderWidth()
5966
self._setHeaderVisible()
6067
self.setData()
@@ -102,14 +109,14 @@ def showCellMenu(self, pos):
102109
:param pos: <QtCore.QPoint> mouse click position.
103110
"""
104111

105-
cellMenu = QtGui.QMenu(self)
112+
cellMenu = QMenu(self)
106113
currentItem = self.itemAt(pos.x(), pos.y())
107114

108115
if currentItem is None:
109116
return
110117

111118
## Replace Cache File
112-
actionReplaceCacheFile = QtGui.QAction("Replace Cache File", self)
119+
actionReplaceCacheFile = QAction("Replace Cache File", self)
113120
actionReplaceCacheFile.triggered.connect(partial(self._replaceCacheFile, currentItem))
114121

115122
actionReplaceCacheFile.setEnabled(False)
@@ -121,7 +128,7 @@ def showCellMenu(self, pos):
121128
cellMenu.addSeparator() ##----------------------------------------------
122129

123130
## Forcus selected item
124-
actionFocusThisNode = QtGui.QAction("Focus this node", self)
131+
actionFocusThisNode = QAction("Focus this node", self)
125132
actionFocusThisNode.triggered.connect(partial(self.focusThisNode, currentItem))
126133

127134
actionFocusThisNode.setEnabled(False)
@@ -133,19 +140,19 @@ def showCellMenu(self, pos):
133140

134141
cellMenu.addSeparator() ##----------------------------------------------
135142

136-
actionExpandAll = QtGui.QAction("Expand all", self)
143+
actionExpandAll = QAction("Expand all", self)
137144
actionExpandAll.triggered.connect(self.expandAll)
138145
cellMenu.addAction(actionExpandAll)
139146

140-
actionCollapseAll = QtGui.QAction("Collapse all", self)
147+
actionCollapseAll = QAction("Collapse all", self)
141148
actionCollapseAll.triggered.connect(self.collapseAll)
142149
cellMenu.addAction(actionCollapseAll)
143150

144151
cellMenu.addSeparator() ##----------------------------------------------
145152

146153
# Debug
147154
if Define.DEBUG_MODE:
148-
debug = QtGui.QAction("Debug", self)
155+
debug = QAction("Debug", self)
149156
debug.triggered.connect(self.debugfunc)
150157

151158
cellMenu.addAction(debug)
@@ -180,7 +187,7 @@ def setData(self):
180187
topItem = self.findChild(rootItem, topToken)
181188

182189
if topItem is None:
183-
topItem = QtGui.QTreeWidgetItem(rootItem, [topToken])
190+
topItem = QTreeWidgetItem(rootItem, [topToken])
184191

185192
if len(pathTokens) > 0:
186193
self._setChildItem(topItem, pathTokens, path, cache_path, rwtype, editable, status)
@@ -212,7 +219,7 @@ def _setChildItem(self, parentItem, restTokens, nodePathItem, cachePathItem, rwt
212219
childItem = self.findChild(parentItem, nextToken)
213220

214221
if childItem is None:
215-
childItem = QtGui.QTreeWidgetItem(parentItem, [nextToken])
222+
childItem = QTreeWidgetItem(parentItem, [nextToken])
216223
self.setStatus(childItem, cachePathItem, editable, status)
217224

218225
if len(restTokens) > 0:
@@ -231,23 +238,23 @@ def setStatus(self, treeItem, cachePathItem, editable, status):
231238
treeItem.setHidden(True)
232239
if status == "bypassed":
233240
# treeItem.setForeground(self.section("node"),
234-
# QtGui.QBrush(QtGui.QColor(Define.BYPASSED_COLOR)))
241+
# QBrush(QColor(Define.BYPASSED_COLOR)))
235242
treeItem.setForeground(self.section("cache_path"),
236-
QtGui.QBrush(QtGui.QColor(Define.BYPASSED_COLOR)))
243+
QBrush(QColor(Define.BYPASSED_COLOR)))
237244
treeItem.setForeground(self.section("rwtype"),
238-
QtGui.QBrush(QtGui.QColor(Define.BYPASSED_COLOR)))
245+
QBrush(QColor(Define.BYPASSED_COLOR)))
239246
treeItem.setForeground(self.section("status"),
240-
QtGui.QBrush(QtGui.QColor(Define.BYPASSED_COLOR)))
247+
QBrush(QColor(Define.BYPASSED_COLOR)))
241248

242249
if status == "error":
243250
# treeItem.setForeground(self.section("node"),
244-
# QtGui.QBrush(QtGui.QColor(Define.ERRORS_COLOR)))
251+
# QBrush(QColor(Define.ERRORS_COLOR)))
245252
treeItem.setForeground(self.section("cache_path"),
246-
QtGui.QBrush(QtGui.QColor(Define.ERRORS_COLOR)))
253+
QBrush(QColor(Define.ERRORS_COLOR)))
247254
treeItem.setForeground(self.section("rwtype"),
248-
QtGui.QBrush(QtGui.QColor(Define.ERRORS_COLOR)))
255+
QBrush(QColor(Define.ERRORS_COLOR)))
249256
treeItem.setForeground(self.section("status"),
250-
QtGui.QBrush(QtGui.QColor(Define.ERRORS_COLOR)))
257+
QBrush(QColor(Define.ERRORS_COLOR)))
251258

252259

253260
def _replaceCacheFile(self, treeItem):

python2.7libs/CacheManager/gui.py

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,20 @@
66
"""
77
#-------------------------------------------------------------------------------
88

9-
import os, sys
9+
import sys
1010
sys.dont_write_bytecode = True
11-
11+
import os
1212
import webbrowser
13-
from PySide import QtCore, QtGui
14-
from PySide import QtUiTools
13+
14+
import imp
15+
try:
16+
imp.find_module('PySide2')
17+
from PySide2.QtWidgets import *
18+
from PySide2.QtGui import *
19+
from PySide2.QtCore import *
20+
except ImportError:
21+
from PySide.QtGui import *
22+
from PySide.QtCore import *
1523

1624
import hou
1725

@@ -23,20 +31,15 @@
2331
reload(cacheWidget)
2432

2533
try:
26-
import hqt.hqt as hqt
27-
reload(hqt)
34+
import hqt
2835
except:
2936
pass
3037

3138

32-
class CacheManager(QtGui.QWidget):
39+
class CacheManager(QWidget):
3340
"""docstring for CacheManager"""
3441

3542

36-
CURRENT_DIR = os.path.dirname(os.path.abspath(__file__))
37-
UIPATH = CURRENT_DIR + "/ui/gui.ui"
38-
39-
4043
def __init__(self, parent=None):
4144
super(CacheManager, self).__init__()
4245

@@ -49,7 +52,7 @@ def initSettings(self):
4952

5053
def initGUI(self):
5154

52-
layout = QtGui.QVBoxLayout()
55+
layout = QVBoxLayout()
5356

5457
## Create Menu Bar
5558
self._createMenuBar()
@@ -70,16 +73,20 @@ def initGUI(self):
7073

7174
self.setLayout(layout)
7275

76+
try:
77+
self.setStyleSheet(hqt.get_h14_style())
78+
except:
79+
pass
7380

7481
def _createMenuBar(self):
7582
"""Helper method for the constructor.
7683
7784
Create the menu bar.
7885
"""
79-
self.menuBar = QtGui.QMenuBar()
86+
self.menuBar = QMenuBar()
8087
self.menuBar.setFixedHeight(25)
8188

82-
# help_button = QtGui.QToolButton()
89+
# help_button = QToolButton()
8390
# help_button.setFixedWidth(25)
8491
# help_button.setFixedHeight(25)
8592
# help_button.clicked.connect(self.showHelp)
@@ -90,12 +97,12 @@ def _createMenuBar(self):
9097
# help_button.setProperty("transparent", True);
9198
#
9299
# self.menuBar.setCornerWidget(help_button)
93-
# self.menuBar.cornerWidget(QtCore.Qt.TopRightCorner)
100+
# self.menuBar.cornerWidget(Qt.TopRightCorner)
94101

95102

96103
def _createEditMenu(self):
97104

98-
edit_menu = QtGui.QMenu(self)
105+
edit_menu = QMenu(self)
99106

100107
reloadAction = edit_menu.addAction("Reload")
101108
reloadAction.setShortcuts(("Ctrl+R", "F5"))
@@ -108,9 +115,9 @@ def _createEditMenu(self):
108115

109116
def _createViewMenu(self):
110117

111-
view_menu = QtGui.QMenu(self)
118+
view_menu = QMenu(self)
112119

113-
self.viewActionGroup = QtGui.QActionGroup(self)
120+
self.viewActionGroup = QActionGroup(self)
114121

115122
showRWaction = view_menu.addAction("Toggle R/W")
116123
showRWaction.setShortcut("Ctrl+E")
@@ -141,9 +148,9 @@ def _createViewMenu(self):
141148

142149
def _createAboutMenu(self):
143150

144-
about_menu = QtGui.QMenu(self)
151+
about_menu = QMenu(self)
145152

146-
openGitHubAction = QtGui.QAction("Bento on GitHub", self)
153+
openGitHubAction = QAction("Bento on GitHub", self)
147154
openGitHubAction.triggered.connect(self._gitHubButtonTriggered)
148155

149156
about_menu.addAction(openGitHubAction)
@@ -186,13 +193,6 @@ def _gitHubButtonTriggered(self):
186193
webbrowser.open('http://github.com/takavfx/Bento')
187194

188195

189-
190-
def main(launch_type=""):
191-
try:
192-
return hqt.showUi(CacheManager())
193-
except:
194-
return CacheManager()
195-
196196
#-------------------------------------------------------------------------------
197197
# EOF
198198
#-------------------------------------------------------------------------------

0 commit comments

Comments
 (0)