Beispiel #1
0
 def mouseMoveEvent(self, event):
     dex = self.indexAt(event.pos())
     if dex.isValid():
         self.setCursor(Qt.PointingHandCursor)
     else:
         self.unsetCursor()
     if not event.buttons() & Qt.LeftButton:
         return
     if self.in_drag_drop or not dex.isValid():
         QTreeView.mouseMoveEvent(self, event)
         return
     # Must deal with odd case where the node being dragged is 'virtual',
     # created to form a hierarchy. We can't really drag this node, but in
     # addition we can't allow drag recognition to notice going over some
     # other node and grabbing that one. So we set in_drag_drop to prevent
     # this from happening, turning it off when the user lifts the button.
     self.in_drag_drop = True
     if not self._model.flags(dex) & Qt.ItemIsDragEnabled:
         QTreeView.mouseMoveEvent(self, event)
         return
     md = self._model.mimeData([dex])
     pixmap = dex.data(DRAG_IMAGE_ROLE).pixmap(self.iconSize())
     drag = QDrag(self)
     drag.setPixmap(pixmap)
     drag.setMimeData(md)
     if self._model.is_in_user_category(dex):
         drag.exec_(Qt.CopyAction|Qt.MoveAction, Qt.CopyAction)
     else:
         drag.exec_(Qt.CopyAction)
Beispiel #2
0
 def mouseMoveEvent(self, event):
     dex = self.indexAt(event.pos())
     if dex.isValid():
         self.setCursor(Qt.PointingHandCursor)
     else:
         self.unsetCursor()
     if not event.buttons() & Qt.LeftButton:
         return
     if self.in_drag_drop or not dex.isValid():
         QTreeView.mouseMoveEvent(self, event)
         return
     # Must deal with odd case where the node being dragged is 'virtual',
     # created to form a hierarchy. We can't really drag this node, but in
     # addition we can't allow drag recognition to notice going over some
     # other node and grabbing that one. So we set in_drag_drop to prevent
     # this from happening, turning it off when the user lifts the button.
     self.in_drag_drop = True
     if not self._model.flags(dex) & Qt.ItemIsDragEnabled:
         QTreeView.mouseMoveEvent(self, event)
         return
     md = self._model.mimeData([dex])
     pixmap = dex.data(DRAG_IMAGE_ROLE).pixmap(self.iconSize())
     drag = QDrag(self)
     drag.setPixmap(pixmap)
     drag.setMimeData(md)
     if self._model.is_in_user_category(dex):
         drag.exec_(Qt.CopyAction | Qt.MoveAction, Qt.CopyAction)
     else:
         drag.exec_(Qt.CopyAction)
Beispiel #3
0
    def mouseMoveEvent(self, event):
        '''
        @param: event QMouseEvent
        '''
        if not self._locationBar or event.buttons() != Qt.LeftButton:
            super().mouseMoveEvent(event)
            return

        manhattanLength = (event.pos() -
                           self._drawStartPosition).manhattanLength()
        if manhattanLength <= QApplication.startDragDistance():
            super().mouseMoveEvent(event)
            return

        url = self._locationBar.webView().url()
        title = self._locationBar.webView().title()

        if url.isEmpty() or not title:
            super().mouseMoveEvent(event)
            return

        drag = QDrag(self)
        mime = QMimeData()
        mime.setUrls([url])
        mime.setText(title)
        mime.setImageData(self.icon.pixmap(16).toImage())

        drag.setMimeData(mime)
        drag.setPixmap(
            gVar.appTools.createPixmapForSite(self.icon, title,
                                              url.toString()))
        drag.exec_()

        # Restore Down State
        self.setDown(False)
    def mouseMoveEvent(self, event):
        '''
        @param: event QMouseEvent
        '''
        if (event.pos() - self._dragStartPosition
            ).manhattanLength() < QApplication.startDragDistance():
            super().mouseMoveEvent(event)
            return

        self.setDown(False)

        drag = QDrag(self)
        mime = BookmarksButtonMimeData()
        mime.setBookmarkItem(self._bookmark)
        drag.setMimeData(mime)
        drag.setPixmap(self.grab())
        drag.exec_()
Beispiel #5
0
 def mouseMoveEvent(self, event):
     if not (event.buttons() & Qt.LeftButton):
         return
     if (event.pos() - self.drag_start_position).manhattanLength() < QApplication.startDragDistance():
         return
     drag = QDrag(self)
     
     mimedata = QMimeData()
     mimedata.setParent(self)
     mimedata.setText(self.text())
     drag.setMimeData(mimedata)
     pixmap = QPixmap(self.size())
     painter = QPainter(pixmap)
     painter.drawPixmap(self.rect(), self.grab())
     painter.end()
     drag.setPixmap(pixmap)
     drag.setHotSpot(event.pos())
     drag.exec_(Qt.CopyAction | Qt.MoveAction)
    def mouseMoveEvent(self, event):
        '''
        @param: event QMouseEvent
        '''
        if not (event.buttons() & Qt.LeftButton) or len(
                self.selectedText()) != len(self.text()):
            super().mouseMoveEvent(event)
            return

        manhattanLength = (event.pos() - self._dragStart).manhattanLength()
        if manhattanLength <= QApplication.startDragDistance():
            return

        drag = QDrag(self)
        mime = QMimeData()
        mime.setText(self._originalText)

        drag.setMimeData(mime)
        drag.exec_()
Beispiel #7
0
 def mouseMoveEvent(self, event):
     dex = self.indexAt(event.pos())
     if dex.isValid():
         self.setCursor(Qt.PointingHandCursor)
     else:
         self.unsetCursor()
     if not event.buttons() & Qt.LeftButton:
         return
     if self.in_drag_drop or not dex.isValid():
         QTreeView.mouseMoveEvent(self, event)
         return
     # don't start drag/drop until the mouse has moved a bit.
     if ((event.pos() - self.possible_drag_start).manhattanLength() <
                                 QApplication.startDragDistance()):
         QTreeView.mouseMoveEvent(self, event)
         return
     # Must deal with odd case where the node being dragged is 'virtual',
     # created to form a hierarchy. We can't really drag this node, but in
     # addition we can't allow drag recognition to notice going over some
     # other node and grabbing that one. So we set in_drag_drop to prevent
     # this from happening, turning it off when the user lifts the button.
     self.in_drag_drop = True
     if not self._model.flags(dex) & Qt.ItemIsDragEnabled:
         QTreeView.mouseMoveEvent(self, event)
         return
     md = self._model.mimeData([dex])
     pixmap = dex.data(DRAG_IMAGE_ROLE).pixmap(self.iconSize())
     drag = QDrag(self)
     drag.setPixmap(pixmap)
     drag.setMimeData(md)
     if (self._model.is_in_user_category(dex) or
                 self._model.is_index_on_a_hierarchical_category(dex)):
         '''
         Things break if we specify MoveAction as the default, which is
         what we want for drag on hierarchical categories. Dragging user
         categories stops working. Don't know why. To avoid the problem
         we fix the action in dragMoveEvent.
         '''
         drag.exec_(Qt.CopyAction|Qt.MoveAction, Qt.CopyAction)
     else:
         drag.exec_(Qt.CopyAction)
Beispiel #8
0
    def mouseMoveEvent(self, event):
        '''
        @param: event QMouseEvent
        '''
        super().mouseMoveEvent(event)

        if gVar.app.plugins().processMouseMove(const.ON_TabBar, self, event):
            return

        if self.count() == 1 and gVar.app.windowCount() == 1:
            return

        if not self._dragStartPosition.isNull():
            offset = 0
            eventY = event.pos().y()
            if eventY < 0:
                offset = abs(eventY)
            elif eventY > self.height():
                offset = eventY - self.height()
            if offset > QApplication.startDragDistance() * 3:
                global_ = self.mapToGlobal(self._dragStartPosition)
                w = QApplication.widgetAt(global_)
                if w:
                    mouse = QMouseEvent(QEvent.MouseButtonRelease,
                                        w.mapFromGlobal(global_),
                                        Qt.LeftButton, Qt.LeftButton,
                                        event.modifiers())
                    QApplication.sendEvent(w, mouse)
                drag = QDrag(self)
                mime = QMimeData()
                mime.setData(self.MIMETYPE, b'')
                drag.setMimeData(mime)
                drag.setPixmap(self.tabPixmap(self.currentIndex()))
                if drag.exec_() == Qt.IgnoreAction:
                    self._tabWidget.detachTabByIndex(self.currentIndex())
                return