Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update on task comment widget and screen capture #2

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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
27 changes: 12 additions & 15 deletions qtazu/widgets/comment.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,11 @@ def dropEvent(self, event):

class CommentWidget(QtWidgets.QDialog):
"""A CG-Wire comment widget

This includes the ability to take Screenshots from the widget
by default, to disable use `set_allow_screenshot(False)`

If you are using this Widget in another interface that has its
own submit button then use `set_button_visibility(False)` and
trigger `submit()` from your surrounding widget.

"""

StatusRole = QtCore.Qt.UserRole + 1
Expand Down Expand Up @@ -210,10 +207,8 @@ def set_close_on_submit(self, value):

def set_thumbnail_visible(self, value):
"""Set thumbnail visibility

Disabling this also implicitly disables the screenshot feature
since screenshotting is only possible by clicking the thumbnail.

"""
self.thumbnail_label.setVisible(value)
self.thumbnail.setVisible(value)
Expand All @@ -225,11 +220,9 @@ def set_button_visible(self, value):

def set_attachment(self, path):
"""Set the attachment.

Args:
path (str): This should be a valid path that can be
used as preview attachment for the comment.

"""
assert os.path.exists(path), \
"Attachment path does not exist: %s" % path
Expand Down Expand Up @@ -357,10 +350,7 @@ def submit(self):
comment_text = self.comment.toPlainText()

# Submit comment
comment = gazu.task.add_comment(task,
status,
comment=comment_text)
log.info("Submitted comment: %s", comment)


# Upload preview and attach to comment
has_preview = bool(self._attachment)
Expand All @@ -369,12 +359,19 @@ def submit(self):
assert os.path.exists(filepath), \
"File does not exist: %s" % filepath

preview = gazu.task.add_preview(task, comment, filepath)
log.info("Submitted preview: %s", preview)
comment = gazu.task.add_comment(task,
status,
comment=comment_text,
attachments=[filepath])
log.info("Submitted comment: %s", comment)

# Clear the attachment
self._attachment = None

else:
comment = gazu.task.add_comment(task,
status,
comment=comment_text)
log.info("Submitted comment: %s", comment)
if self._close_on_submit:
# Close after submission for now to avoid confusion
# todo: if not closing add message that submission succeeded
Expand All @@ -391,4 +388,4 @@ def submit(self):
screenshot = ScreenshotWidget()
screenshot.set_button_visible(False)
screenshot.set_allow_screenshot(False)
screenshot.set_thumbnail_visible(False)
screenshot.set_thumbnail_visible(False)
9 changes: 7 additions & 2 deletions qtazu/widgets/screenmarquee.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os

from Qt import QtCore, QtGui, QtWidgets
from PyQt5.QtGui import QPixmap, QScreen


class ScreenMarquee(QtWidgets.QDialog):
Expand Down Expand Up @@ -128,7 +129,10 @@ def showEvent(self, event):
self._fit_screen_geometry()

# Start fade in animation
fade_anim = QtCore.QPropertyAnimation(self, b"_opacity_anim_prop", self)
property = "_opacity_anim_prop"
encoded_property = property.encode()
byte_array = bytearray(encoded_property)
fade_anim = QtCore.QPropertyAnimation(self, byte_array , self)
fade_anim.setStartValue(self._opacity)
fade_anim.setEndValue(50)
fade_anim.setDuration(200)
Expand Down Expand Up @@ -169,8 +173,9 @@ def get_desktop_pixmap(rect):
QtGui.QPixmap: Captured pixmap image

"""
screen = QtWidgets.QApplication.primaryScreen()
desktop = QtWidgets.QApplication.desktop()
pixmap = QtGui.QPixmap.grabWindow(desktop.winId(),
pixmap = screen.grabWindow(desktop.winId(),
rect.x(),
rect.y(),
rect.width(),
Expand Down