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

Publisher: Easy access to publish page from create page #4058

Merged
merged 22 commits into from
Nov 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
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
4 changes: 4 additions & 0 deletions openpype/style/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1126,6 +1126,10 @@ ValidationArtistMessage QLabel {
background: transparent;
}

CreateNextPageOverlay {
font-size: 32pt;
}

/* Settings - NOT USED YET
- we need to define font family for settings UI */

Expand Down
2 changes: 2 additions & 0 deletions openpype/tools/publisher/widgets/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
ResetBtn,
ValidateBtn,
PublishBtn,
CreateNextPageOverlay,
)
from .help_widget import (
HelpButton,
Expand All @@ -28,6 +29,7 @@
"ResetBtn",
"ValidateBtn",
"PublishBtn",
"CreateNextPageOverlay",

"HelpButton",
"HelpDialog",
Expand Down
10 changes: 10 additions & 0 deletions openpype/tools/publisher/widgets/overview_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,16 @@ def set_state(self, new_state, animate):
self._subset_views_widget.setMaximumWidth(view_width)
self._change_anim.start()

def get_subset_views_geo(self):
parent = self._subset_views_widget.parent()
global_pos = parent.mapToGlobal(self._subset_views_widget.pos())
return QtCore.QRect(
global_pos.x(),
global_pos.y(),
self._subset_views_widget.width(),
self._subset_views_widget.height()
)

def _on_create_clicked(self):
"""Pass signal to parent widget which should care about changing state.

Expand Down
2 changes: 1 addition & 1 deletion openpype/tools/publisher/widgets/validations_widget.py
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ def __init__(self, controller, parent):
)
# After success publishing
publish_started_widget = ValidationArtistMessage(
"Publishing went smoothly", self
"So far so good", self
)
# After success publishing
publish_stop_ok_widget = ValidationArtistMessage(
Expand Down
156 changes: 156 additions & 0 deletions openpype/tools/publisher/widgets/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -1708,3 +1708,159 @@ def _update_thumbnails(self):

self._thumbnail_widget.setVisible(True)
self._thumbnail_widget.set_current_thumbnails(thumbnail_paths)


class CreateNextPageOverlay(QtWidgets.QWidget):
clicked = QtCore.Signal()

def __init__(self, parent):
super(CreateNextPageOverlay, self).__init__(parent)
self.setCursor(QtCore.Qt.PointingHandCursor)
self._arrow_color = (
get_objected_colors("font").get_qcolor()
)
self._bg_color = (
get_objected_colors("bg-buttons").get_qcolor()
)

change_anim = QtCore.QVariantAnimation()
change_anim.setStartValue(0.0)
change_anim.setEndValue(1.0)
change_anim.setDuration(200)
change_anim.setEasingCurve(QtCore.QEasingCurve.OutCubic)

change_anim.valueChanged.connect(self._on_anim)

self._change_anim = change_anim
self._is_visible = None
self._anim_value = 0.0
self._increasing = False
self._under_mouse = None
self._handle_show_on_own = True
self._mouse_pressed = False
self.set_visible(True)

def set_increasing(self, increasing):
if self._increasing is increasing:
return
self._increasing = increasing
if increasing:
self._change_anim.setDirection(self._change_anim.Forward)
else:
self._change_anim.setDirection(self._change_anim.Backward)

if self._change_anim.state() != self._change_anim.Running:
self._change_anim.start()

def set_visible(self, visible):
if self._is_visible is visible:
return

self._is_visible = visible
if not visible:
self.set_increasing(False)
if not self._is_anim_finished():
return

self.setVisible(visible)
self._check_anim_timer()

def _is_anim_finished(self):
if self._increasing:
return self._anim_value == 1.0
return self._anim_value == 0.0

def _on_anim(self, value):
self._check_anim_timer()

self._anim_value = value

self.update()

if not self._is_anim_finished():
return

if not self._is_visible:
self.setVisible(False)

def set_under_mouse(self, under_mouse):
if self._under_mouse is under_mouse:
return

self._under_mouse = under_mouse
self.set_increasing(under_mouse)

def _is_under_mouse(self):
mouse_pos = self.mapFromGlobal(QtGui.QCursor.pos())
under_mouse = self.rect().contains(mouse_pos)
return under_mouse

def _check_anim_timer(self):
if not self.isVisible():
return

self.set_increasing(self._under_mouse)

def mousePressEvent(self, event):
if event.button() == QtCore.Qt.LeftButton:
self._mouse_pressed = True
super(CreateNextPageOverlay, self).mousePressEvent(event)

def mouseReleaseEvent(self, event):
if self._mouse_pressed:
self._mouse_pressed = False
if self.rect().contains(event.pos()):
self.clicked.emit()

super(CreateNextPageOverlay, self).mouseReleaseEvent(event)

def paintEvent(self, event):
painter = QtGui.QPainter()
painter.begin(self)
if self._anim_value == 0.0:
painter.end()
return

painter.setClipRect(event.rect())
painter.setRenderHints(
painter.Antialiasing
| painter.SmoothPixmapTransform
)

painter.setPen(QtCore.Qt.NoPen)

rect = QtCore.QRect(self.rect())
rect_width = rect.width()
rect_height = rect.height()
radius = rect_width * 0.2

x_offset = 0
y_offset = 0
if self._anim_value != 1.0:
x_offset += rect_width - (rect_width * self._anim_value)

arrow_height = rect_height * 0.4
arrow_half_height = arrow_height * 0.5
arrow_x_start = x_offset + ((rect_width - arrow_half_height) * 0.5)
arrow_x_end = arrow_x_start + arrow_half_height
center_y = rect.center().y()

painter.setBrush(self._bg_color)
painter.drawRoundedRect(
x_offset, y_offset,
rect_width + radius, rect_height,
radius, radius
)

src_arrow_path = QtGui.QPainterPath()
src_arrow_path.moveTo(arrow_x_start, center_y - arrow_half_height)
src_arrow_path.lineTo(arrow_x_end, center_y)
src_arrow_path.lineTo(arrow_x_start, center_y + arrow_half_height)

arrow_stroker = QtGui.QPainterPathStroker()
arrow_stroker.setWidth(min(4, arrow_half_height * 0.2))
arrow_path = arrow_stroker.createStroke(src_arrow_path)

painter.fillPath(arrow_path, self._arrow_color)

painter.end()
Loading