Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@ dist
cover
.coverage
build
.idea/
.idea/misc.xml
.idea/modules.xml
.idea/pyblish-lite.iml
.idea/vcs.xml
.idea/workspace.xml
.vscode/
.vscode/
5 changes: 5 additions & 0 deletions pyblish_lite/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,11 @@ QListView {
background: "transparent"
}

QTreeView {
border: 0px;
background: "transparent"
}

QPushButton {
width: 27px;
height: 27px;
Expand Down
60 changes: 60 additions & 0 deletions pyblish_lite/delegate.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,66 @@ def sizeHint(self, option, index):
return QtCore.QSize(option.rect.width(), 20)


class Section(QtWidgets.QStyledItemDelegate):
"""Generic delegate for section header"""

def paint(self, painter, option, index):
"""Paint text
_
My label

"""

body_rect = QtCore.QRectF(option.rect)

metrics = painter.fontMetrics()

label_rect = QtCore.QRectF(option.rect.adjusted(0, 2, 0, -2))

assert label_rect.width() > 0

label = index.data(model.Label)
label = metrics.elidedText(label,
QtCore.Qt.ElideRight,
label_rect.width())

font_color = colors["idle"]
if not index.data(model.IsChecked):
font_color = colors["inactive"]

# Maintain reference to state, so we can restore it once we're done
painter.save()

# Draw label
painter.setFont(fonts["h4"])
painter.setPen(QtGui.QPen(font_color))
painter.drawText(label_rect, label)

if option.state & QtWidgets.QStyle.State_MouseOver:
painter.fillRect(body_rect, colors["hover"])

if option.state & QtWidgets.QStyle.State_Selected:
painter.fillRect(body_rect, colors["selected"])

# Ok, we're done, tidy up.
painter.restore()

def sizeHint(self, option, index):
return QtCore.QSize(option.rect.width(), 20)


class ItemAndSection(Item):
"""Generic delegate for model items in proxy tree view"""
def paint(self, painter, option, index):

model = index.model()
if model.is_header(index):
Section().paint(painter, option, index)
return

super(ItemAndSection, self).paint(painter, option, index)


class Artist(QtWidgets.QStyledItemDelegate):
"""Delegate used on Artist page"""

Expand Down
2 changes: 2 additions & 0 deletions pyblish_lite/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
Label = QtCore.Qt.DisplayRole + 0
Families = QtCore.Qt.DisplayRole + 1
Icon = QtCore.Qt.DisplayRole + 13
Order = QtCore.Qt.UserRole + 62

# The item has not been used
IsIdle = QtCore.Qt.UserRole + 2
Expand Down Expand Up @@ -134,6 +135,7 @@ def __init__(self, parent=None):
Actions: "actions",
IsOptional: "optional",
Icon: "icon",
Order: "order",

# GUI-only data
Type: "_type",
Expand Down
Loading