Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #602 from pypeclub/feature/animated_pyblish_gui
Browse files Browse the repository at this point in the history
Animated pyblish gui
  • Loading branch information
mkolar authored Oct 6, 2020
2 parents d3904d4 + f04301b commit 526be6f
Show file tree
Hide file tree
Showing 5 changed files with 390 additions and 58 deletions.
33 changes: 31 additions & 2 deletions pype/tools/pyblish_pype/app.css
Original file line number Diff line number Diff line change
Expand Up @@ -459,7 +459,7 @@ QToolButton {
color: #fff;
}

#TerminalFilerBtn {
#TerminalFilterWidget QPushButton {
/* font: %(font_size_pt)spt; */
font-family: "FontAwesome";
text-align: center;
Expand All @@ -468,29 +468,58 @@ QToolButton {
border-color: #777777;
border-style: none;
padding: 0px;
border-radius: 3px;
border-radius: 8px;
}
#TerminalFilterWidget QPushButton:hover {
background: #5f5f5f;
border-style: none;
}
#TerminalFilterWidget QPushButton:pressed {
background: #606060;
border-style: none;
}
#TerminalFilterWidget QPushButton:pressed:hover {
background: #626262;
border-style: none;
}

#TerminalFilerBtn[type="info"]:checked {color: rgb(255, 255, 255);}
#TerminalFilerBtn[type="info"]:hover:pressed {color: rgba(255, 255, 255, 163);}
#TerminalFilerBtn[type="info"] {color: rgba(255, 255, 255, 63);}

#TerminalFilerBtn[type="error"]:checked {color: rgb(255, 74, 74);}
#TerminalFilerBtn[type="error"]:hover:pressed {color: rgba(255, 74, 74, 163);}
#TerminalFilerBtn[type="error"] {color: rgba(255, 74, 74, 63);}

#TerminalFilerBtn[type="log_debug"]:checked {color: rgb(255, 102, 232);}
#TerminalFilerBtn[type="log_debug"] {color: rgba(255, 102, 232, 63);}
#TerminalFilerBtn[type="log_debug"]:hover:pressed {
color: rgba(255, 102, 232, 163);
}

#TerminalFilerBtn[type="log_info"]:checked {color: rgb(102, 171, 255);}
#TerminalFilerBtn[type="log_info"] {color: rgba(102, 171, 255, 63);}
#TerminalFilerBtn[type="log_info"]:hover:pressed {
color: rgba(102, 171, 255, 163);
}

#TerminalFilerBtn[type="log_warning"]:checked {color: rgb(255, 186, 102);}
#TerminalFilerBtn[type="log_warning"] {color: rgba(255, 186, 102, 63);}
#TerminalFilerBtn[type="log_warning"]:hover:pressed {
color: rgba(255, 186, 102, 163);
}

#TerminalFilerBtn[type="log_error"]:checked {color: rgb(255, 77, 88);}
#TerminalFilerBtn[type="log_error"] {color: rgba(255, 77, 88, 63);}
#TerminalFilerBtn[type="log_error"]:hover:pressed {
color: rgba(255, 77, 88, 163);
}

#TerminalFilerBtn[type="log_critical"]:checked {color: rgb(255, 79, 117);}
#TerminalFilerBtn[type="log_critical"] {color: rgba(255, 79, 117, 63);}
#TerminalFilerBtn[type="log_critical"]:hover:pressed {
color: rgba(255, 79, 117, 163);
}

#SuspendLogsBtn {
background: #444;
Expand Down
2 changes: 1 addition & 1 deletion pype/tools/pyblish_pype/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,13 +92,13 @@ def show(parent=None):

self._window.show()
self._window.activateWindow()
self._window.resize(*settings.WindowSize)
self._window.setWindowTitle(settings.WindowTitle)

font = QtGui.QFont("Open Sans", 8, QtGui.QFont.Normal)
self._window.setFont(font)
self._window.setStyleSheet(css)

self._window.reset()
self._window.resize(*settings.WindowSize)

return self._window
106 changes: 88 additions & 18 deletions pype/tools/pyblish_pype/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def __init__(self, parent=None):
self.setHeaderHidden(True)
self.setRootIsDecorated(False)
self.setIndentation(0)
self.setAnimated(True)

def event(self, event):
if not event.type() == QtCore.QEvent.KeyPress:
Expand Down Expand Up @@ -159,6 +160,8 @@ class InstanceView(OverviewView):
def __init__(self, parent=None):
super(InstanceView, self).__init__(parent)
self.viewport().setMouseTracking(True)
self._pressed_group_index = None
self._pressed_expander = None

def mouseMoveEvent(self, event):
index = self.indexAt(event.pos())
Expand All @@ -176,6 +179,8 @@ def item_expand(self, index, expand=None):
self.collapse(index)

def group_toggle(self, index):
if not index.isValid():
return
model = index.model()

chilren_indexes_checked = []
Expand All @@ -201,25 +206,90 @@ def group_toggle(self, index):
model.setData(index, new_state, QtCore.Qt.CheckStateRole)
self.toggled.emit(index, new_state)

def mouseReleaseEvent(self, event):
if event.button() == QtCore.Qt.LeftButton:
def _mouse_press(self, event):
if event.button() != QtCore.Qt.LeftButton:
return

self._pressed_group_index = None
self._pressed_expander = None

pos_index = self.indexAt(event.pos())
if not pos_index.isValid():
return

if pos_index.data(Roles.TypeRole) != model.InstanceType:
self._pressed_group_index = pos_index
if event.pos().x() < 20:
self._pressed_expander = True
else:
self._pressed_expander = False

elif event.pos().x() < 20:
indexes = self.selectionModel().selectedIndexes()
if len(indexes) == 1:
index = indexes[0]
pos_index = self.indexAt(event.pos())
if index == pos_index:
# If instance or Plugin
if index.data(Roles.TypeRole) == model.InstanceType:
if event.pos().x() < 20:
self.toggled.emit(index, None)
elif event.pos().x() > self.width() - 20:
self.show_perspective.emit(index)
else:
if event.pos().x() < EXPANDER_WIDTH:
self.item_expand(index)
else:
self.group_toggle(index)
self.item_expand(index, True)
any_checked = False
if len(indexes) <= 1:
return

if pos_index in indexes:
for index in indexes:
if index.data(QtCore.Qt.CheckStateRole):
any_checked = True
break

for index in indexes:
self.toggled.emit(index, not any_checked)
return True
self.toggled.emit(pos_index, not any_checked)

def mousePressEvent(self, event):
if self._mouse_press(event):
return
return super(InstanceView, self).mousePressEvent(event)

def _mouse_release(self, event, pressed_expander, pressed_index):
if event.button() != QtCore.Qt.LeftButton:
return

pos_index = self.indexAt(event.pos())
if not pos_index.isValid():
return

if pos_index.data(Roles.TypeRole) == model.InstanceType:
indexes = self.selectionModel().selectedIndexes()
if len(indexes) == 1 and indexes[0] == pos_index:
if event.pos().x() < 20:
self.toggled.emit(indexes[0], None)
elif event.pos().x() > self.width() - 20:
self.show_perspective.emit(indexes[0])
return True
return

if pressed_index != pos_index:
return

if self.state() == QtWidgets.QTreeView.State.DragSelectingState:
indexes = self.selectionModel().selectedIndexes()
if len(indexes) != 1 or indexes[0] != pos_index:
return

if event.pos().x() < EXPANDER_WIDTH:
if pressed_expander is True:
self.item_expand(pos_index)
return True
else:
if pressed_expander is False:
self.group_toggle(pos_index)
self.item_expand(pos_index, True)
return True

def mouseReleaseEvent(self, event):
pressed_index = self._pressed_group_index
pressed_expander = self._pressed_expander is True
self._pressed_group_index = None
self._pressed_expander = None
result = self._mouse_release(event, pressed_expander, pressed_index)
if result:
return
return super(InstanceView, self).mouseReleaseEvent(event)


Expand Down
34 changes: 17 additions & 17 deletions pype/tools/pyblish_pype/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

class EllidableLabel(QtWidgets.QLabel):
def __init__(self, *args, **kwargs):
super(self.__class__, self).__init__(*args, **kwargs)
super(EllidableLabel, self).__init__(*args, **kwargs)
self.setObjectName("EllidableLabel")

def paintEvent(self, event):
Expand All @@ -21,7 +21,7 @@ def paintEvent(self, event):

class PerspectiveLabel(QtWidgets.QTextEdit):
def __init__(self, parent=None):
super(self.__class__, self).__init__(parent)
super(PerspectiveLabel, self).__init__(parent)
self.setObjectName("PerspectiveLabel")

size_policy = self.sizePolicy()
Expand Down Expand Up @@ -50,7 +50,7 @@ def heightForWidth(self, width):
return margins.top() + document.size().height() + margins.bottom()

def sizeHint(self):
width = super(self.__class__, self).sizeHint().width()
width = super(PerspectiveLabel, self).sizeHint().width()
return QtCore.QSize(width, self.heightForWidth(width))


Expand Down Expand Up @@ -328,7 +328,7 @@ def set_records(self, records):
self.records.toggle_content(len_records > 0)

def toggle_me(self):
self.parent_widget.toggle_perspective_widget()
self.parent_widget.parent().toggle_perspective_widget()


class ClickableWidget(QtWidgets.QLabel):
Expand Down Expand Up @@ -407,7 +407,7 @@ def toggle_content(self, *args):
self.content_widget.setVisible(checked)

def resizeEvent(self, event):
super(self.__class__, self).resizeEvent(event)
super(ExpandableWidget, self).resizeEvent(event)
self.content.updateGeometry()

def set_content(self, in_widget):
Expand Down Expand Up @@ -481,7 +481,7 @@ def focusOutEvent(self, event):

class TerminalDetail(QtWidgets.QTextEdit):
def __init__(self, text, *args, **kwargs):
super(self.__class__, self).__init__(*args, **kwargs)
super(TerminalDetail, self).__init__(*args, **kwargs)

self.setReadOnly(True)
self.setHtml(text)
Expand All @@ -504,7 +504,7 @@ class FilterButton(QtWidgets.QPushButton):
def __init__(self, name, *args, **kwargs):
self.filter_name = name

super(self.__class__, self).__init__(*args, **kwargs)
super(FilterButton, self).__init__(*args, **kwargs)

self.toggled.connect(self.on_toggle)

Expand All @@ -522,25 +522,25 @@ def on_toggle(self, toggle_state):
class TerminalFilterWidget(QtWidgets.QWidget):
# timer.timeout.connect(lambda: self._update(self.parent_widget))
def __init__(self, *args, **kwargs):
super(self.__class__, self).__init__(*args, **kwargs)

super(TerminalFilterWidget, self).__init__(*args, **kwargs)
self.setObjectName("TerminalFilterWidget")
self.filter_changed = QtCore.Signal()

info_icon = awesome.tags["info"]
log_icon = awesome.tags["circle"]
error_icon = awesome.tags["exclamation-triangle"]

filter_buttons = (
FilterButton("info", info_icon),
FilterButton("log_debug", log_icon),
FilterButton("log_info", log_icon),
FilterButton("log_warning", log_icon),
FilterButton("log_error", log_icon),
FilterButton("log_critical", log_icon),
FilterButton("error", error_icon)
FilterButton("info", info_icon, self),
FilterButton("log_debug", log_icon, self),
FilterButton("log_info", log_icon, self),
FilterButton("log_warning", log_icon, self),
FilterButton("log_error", log_icon, self),
FilterButton("log_critical", log_icon, self),
FilterButton("error", error_icon, self)
)

layout = QtWidgets.QHBoxLayout()
layout = QtWidgets.QHBoxLayout(self)
layout.setContentsMargins(0, 0, 0, 0)
# Add spacers
layout.addWidget(QtWidgets.QWidget(), 1)
Expand Down
Loading

0 comments on commit 526be6f

Please sign in to comment.