From 779e81acb9e75e7023e304cb3839a108018d8d55 Mon Sep 17 00:00:00 2001 From: ingvar1995 Date: Wed, 23 Mar 2016 11:33:21 +0300 Subject: [PATCH] screenshots added (without send) --- src/mainscreen.py | 42 +++++++++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/src/mainscreen.py b/src/mainscreen.py index ec1fa1e..8abe55a 100644 --- a/src/mainscreen.py +++ b/src/mainscreen.py @@ -300,7 +300,8 @@ class MainWindow(QtGui.QMainWindow): def send_screenshot(self): # TODO: add screenshots support if self.profile.is_active_online(): # active friend exists and online - pass + self.sw = ScreenShotWindow() + self.sw.show() # ----------------------------------------------------------------------------------------------------------------- # Functions which called when user open context menu in friends list @@ -373,3 +374,42 @@ class MainWindow(QtGui.QMainWindow): self.profile.filtration(self.online_contacts.isChecked(), self.contact_name.text()) +class ScreenShotWindow(QtGui.QWidget): + # TODO: send raw data and make window semi-transparent + def __init__(self): + super(ScreenShotWindow, self).__init__() + self.rubberband = QtGui.QRubberBand(QtGui.QRubberBand.Rectangle, self) + self.setMouseTracking(True) + self.setWindowFlags(self.windowFlags() | QtCore.Qt.FramelessWindowHint | QtCore.Qt.FramelessWindowHint) + self.setAttribute(QtCore.Qt.WA_TranslucentBackground) + self.showFullScreen() + + def mousePressEvent(self, event): + self.origin = event.pos() + self.rubberband.setGeometry( + QtCore.QRect(self.origin, QtCore.QSize())) + self.rubberband.show() + QtGui.QWidget.mousePressEvent(self, event) + + def mouseMoveEvent(self, event): + if self.rubberband.isVisible(): + self.rubberband.setGeometry( + QtCore.QRect(self.origin, event.pos()).normalized()) + QtGui.QWidget.mouseMoveEvent(self, event) + + def mouseReleaseEvent(self, event): + if self.rubberband.isVisible(): + self.rubberband.hide() + rect = self.rubberband.geometry() + print rect + p = QtGui.QPixmap.grabWindow(QtGui.QApplication.desktop().winId(), + rect.x(), + rect.y(), + rect.width(), + rect.height()) + image = p.toImage() + print len(image.bits()) + self.close() + + +