Beispiel #1
0
 def mousePressEvent(self, e):
     """ 鼠标点击窗口时进行透视变换 """
     super().mousePressEvent(e)
     self.grabMouse()
     # 截屏
     self.__perspectiveTrans.setPixmap(self.grab())
     # 获取鼠标点击位置
     self.__pressedPos = getPressedPos(self, e)
     # 根据鼠标点击位置的不同设置背景封面的透视变换
     if self.__pressedPos == 'left':
         self.__perspectiveTrans.setDstPoints(
             [3, 1], [self.__perspectiveTrans.width - 2, 1],
             [3, self.__perspectiveTrans.height - 2],
             [self.__perspectiveTrans.width - 2, self.__perspectiveTrans.height - 1])
     elif self.__pressedPos == 'left-top':
         self.__perspectiveTrans.setDstPoints(
             [3, 2], [self.__perspectiveTrans.width - 1, 1],
             [1, self.__perspectiveTrans.height - 2],
             [self.__perspectiveTrans.width - 2, self.__perspectiveTrans.height - 1])
     elif self.__pressedPos == 'left-bottom':
         self.__perspectiveTrans.setDstPoints(
             [3, 1], [self.__perspectiveTrans.width - 2, 1],
             [3, self.__perspectiveTrans.height - 3],
             [self.__perspectiveTrans.width - 1, self.__perspectiveTrans.height - 1])
     elif self.__pressedPos == 'top':
         self.__perspectiveTrans.setDstPoints(
             [2, 2], [self.__perspectiveTrans.width - 3, 2],
             [1, self.__perspectiveTrans.height - 2],
             [self.__perspectiveTrans.width - 2, self.__perspectiveTrans.height - 2])
     elif self.__pressedPos == 'center':
         self.__perspectiveTrans.setDstPoints(
             [2, 2], [self.__perspectiveTrans.width - 3, 2],
             [2, self.__perspectiveTrans.height - 3],
             [self.__perspectiveTrans.width - 3, self.__perspectiveTrans.height - 3])
     elif self.__pressedPos == 'bottom':
         self.__perspectiveTrans.setDstPoints(
             [1, 1], [self.__perspectiveTrans.width - 2, 1],
             [3, self.__perspectiveTrans.height - 3],
             [self.__perspectiveTrans.width - 4, self.__perspectiveTrans.height - 3])
     elif self.__pressedPos == 'right-top':
         self.__perspectiveTrans.setDstPoints(
             [0, 0], [self.__perspectiveTrans.width - 4, 1],
             [1, self.__perspectiveTrans.height - 1],
             [self.__perspectiveTrans.width - 2, self.__perspectiveTrans.height - 2])
     elif self.__pressedPos == 'right':
         self.__perspectiveTrans.setDstPoints(
             [1, 0], [self.__perspectiveTrans.width - 4, 1],
             [1, self.__perspectiveTrans.height - 1],
             [self.__perspectiveTrans.width - 4, self.__perspectiveTrans.height - 2])
     elif self.__pressedPos == 'right-bottom':
         self.__perspectiveTrans.setDstPoints(
             [1, 1], [self.__perspectiveTrans.width - 2, 1],
             [0, self.__perspectiveTrans.height - 1],
             [self.__perspectiveTrans.width - 4, self.__perspectiveTrans.height - 3])
     self.__pressedPix = self.__perspectiveTrans.getPerspectiveTransform(
         self.__perspectiveTrans.width, self.__perspectiveTrans.height).scaled(
             self.size(), Qt.KeepAspectRatio, Qt.SmoothTransformation)
     self.update()
Beispiel #2
0
 def mousePressEvent(self, e):
     """ 鼠标点击窗口时进行透视变换 """
     super().mousePressEvent(e)
     # 多次点击时不响应,防止小部件的再次隐藏
     if self.__pressedPos:
         return
     self.grabMouse()
     pixmap = self.grab()
     self.__perspectiveTrans.setPixmap(pixmap)
     # 根据鼠标点击位置的不同设置背景封面的透视变换
     self.__setDstPointsByPressedPos(getPressedPos(self,e))
     # 获取透视变换后的QPixmap
     self.__pressedPix = self.__getTransformPixmap()
     # 对桌面上的窗口进行截图
     if self.__isTransScreenshot:
         self.__adjustTransformPix()
     # 隐藏本来看得见的小部件
     self.__visibleChildren = [
         child for child in self.children() if hasattr(child, 'isVisible') and child.isVisible()]
     for child in self.__visibleChildren:
         if hasattr(child, 'hide'):
             child.hide()
     self.update()
Beispiel #3
0
 def mousePressEvent(self, e):
     """ 鼠标点击时更新样式 """
     self.pressedPos = getPressedPos(self, e)
     self.update()
     super().mousePressEvent(e)
Beispiel #4
0
 def mousePressEvent(self, e: QMouseEvent):
     """ 根据鼠标的不同按下位置更新标志位 """
     self.pressedPos = getPressedPos(self, e)
     self.update()