Beispiel #1
0
    def changeAction(self, nextAction):
        QApplication.clipboard().setText('Test in changeAction function')

        if nextAction == ACTION_UNDO:
            self.undoOperation()
        elif nextAction == ACTION_SAVE:
            self.saveOperation()
        elif nextAction == ACTION_CANCEL:
            self.close()
        elif nextAction == ACTION_SURE:
            self.saveToClipboard()

        else:
            self.action = nextAction

        self.setFocus()
    def copy_path_to_clipboard(filepath):
        """
        Copies the item path to the system clipboard
        """

        clipboard = QApplication.clipboard()
        clipboard.clear(mode=clipboard.Clipboard)
        clipboard.setText(filepath, mode=clipboard.Clipboard)
Beispiel #3
0
def image_to_clipboard(path):
    """
    Copies the image at path to the system's global clipboard
    :param path: str
    """

    image = QtGui.QImage(path)
    clipboard = QApplication.clipboard()
    clipboard.setImage(image, mode=QtGui.QClipboard.Clipboard)
    def copy_text(self, column):
        """
        Copy the given column text to clipboard
        :param column: int or text
        """

        items = self.selectedItems()
        text = '\n'.join([item.text(column) for item in items])
        clipboard = QApplication.clipboard()
        clipboard.setText(text, QClipboard.Clipboard)
Beispiel #5
0
 def _copy(self):
     clipboard = QApplication.clipboard()
     clipboard.setText('```\n' + self.text.toPlainText() + '\n```')
Beispiel #6
0
 def saveUidToClipboard(self):
     clipboard = QApplication.clipboard()
     clipboard.clear()
     clipboard.setText(str(self.uid))
Beispiel #7
0
 def onCopyPathToClipboard(self):
     QApplication.clipboard().clear()
     QApplication.clipboard().setText(self.path())
Beispiel #8
0
    def __init__(self, flags=constant.DEFAULT, parent=None):
        """
        flags: binary flags. see the flags in the constant.py
        """
        super(Screenshot, self).__init__(parent)

        self._screen = 0

        # Init
        self.penColorNow = QColor(PENCOLOR)
        self.penSizeNow = PENSIZE
        self.fontNow = QFont('Sans')
        self.clipboard = QApplication.clipboard()

        self.drawListResult = [
        ]  # draw list that sure to be drew, [action, coord]
        self.drawListProcess = None  # the process to the result
        self.selectedArea = QRect(
        )  # a QRect instance which stands for the selected area
        self.selectedAreaRaw = QRect()
        self.mousePosition = MousePosition.OUTSIDE_AREA  # mouse position
        self.screenPixel = None
        self.textRect = None

        self.mousePressed = False
        self.action = ACTION_SELECT
        self.mousePoint = self.cursor().pos()

        self.startX, self.startY = 0, 0  # the point where you start
        self.endX, self.endY = 0, 0  # the point where you end
        self.pointPath = QPainterPath(
        )  # the point mouse passes, used by draw free line
        self.itemsToRemove = [
        ]  # the items that should not draw on screenshot picture
        self.textPosition = None

        # result
        self.target_img = None

        # Init window
        self.getscreenshot()
        self.setWindowFlags(Qt.WindowStaysOnTopHint | Qt.FramelessWindowHint)

        self.setMouseTracking(True)
        self.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.setContentsMargins(0, 0, 0, 0)
        self.setStyleSheet("QGraphicsView { border-style: none; }")

        self.tooBar = MyToolBar(flags, self)
        self.tooBar.trigger.connect(self.changeAction)

        self.penSetBar = None
        if flags & constant.RECT or flags & constant.ELLIPSE or flags & constant.LINE or flags & constant.FREEPEN \
                or flags & constant.ARROW or flags & constant.TEXT:
            self.penSetBar = PenSetWidget(self)
            self.penSetBar.penSizeTrigger.connect(self.changePenSize)
            self.penSetBar.penColorTrigger.connect(self.changePenColor)
            self.penSetBar.fontChangeTrigger.connect(self.changeFont)

        self.textInput = TextInput(self)
        self.textInput.inputChanged.connect(self.textChange)
        self.textInput.cancelPressed.connect(self.cancelInput)
        self.textInput.okPressed.connect(self.okInput)

        print('======>>> {0}, {1}'.format(self.screenPixel.width(),
                                          self.screenPixel.height()))
        self.graphicsScene = QGraphicsScene(0, 0, self.screenPixel.width(),
                                            self.screenPixel.height())

        # self.show()
        # self.setScene(self.graphicsScene)
        # self.windowHandle().setScreen(QGuiApplication.screenAt(QCursor.pos()))
        # self.scale = self.get_scale()
        # # self.setFixedSize(self.screenPixel.width(), self.screenPixel.height())
        # # screen = QApplication.desktop().screenNumber(QApplication.desktop().cursor().pos())
        # # _rect = QDesktopWidget().availableGeometry(screen=screen)
        # # self.setGeometry(_rect)
        # self.setGeometry(QGuiApplication.screenAt(QCursor.pos()).geometry())
        # self.showFullScreen()
        # self.redraw()
        self._show()

        QShortcut(QKeySequence('ctrl+s'),
                  self).activated.connect(self.saveScreenshot)
        QShortcut(QKeySequence('esc'), self).activated.connect(self.close)
Beispiel #9
0
    def saveToClipboard(self):
        QApplication.clipboard().setText('Test in save function')

        self.saveScreenshot(True)
        self.close()