Exemplo n.º 1
0
    def __onDragStarted(self, index):
        desc = index.data(QtWidgetRegistry.WIDGET_DESC_ROLE)
        icon = index.data(Qt.DecorationRole)

        drag_data = QMimeData()
        drag_data.setData(
            "application/vnv.orange-canvas.registry.qualified-name",
            desc.qualified_name
        )
        drag = QDrag(self)
        drag.setPixmap(icon.pixmap(38))
        drag.setMimeData(drag_data)

        # TODO: Should animate (accept) hide.
        self.hide()

        # When a drag is started and the menu hidden the item's tool tip
        # can still show for a short time UNDER the cursor preventing a
        # drop.
        viewport = self.__menu.view().viewport()
        filter = ToolTipEventFilter()
        viewport.installEventFilter(filter)

        drag.exec_(Qt.CopyAction)

        viewport.removeEventFilter(filter)
Exemplo n.º 2
0
	def mousePressEvent( self, event ):
		# handle an internal move
		from PyQt4.QtCore import Qt

		# start a drag event
		if ( event.button() == Qt.LeftButton and self.dragDropRect().contains( event.pos() ) ):
			from PyQt4.QtCore import QMimeData
			from PyQt4.QtGui import QDrag, QPixmap

			# create the pixmap
			pixmap = QPixmap.grabWidget( self, self.rect() )

			# create the mimedata
			mimeData = QMimeData()
			mimeData.setText( 'ItemTitle::%s' % (self.title()) )

			# create the drag
			drag = QDrag(self)
			drag.setMimeData( mimeData )
			drag.setPixmap( pixmap )
			drag.setHotSpot( event.pos() )

			if ( not drag.exec_() ):
				self._accordianWidget.emitItemDragFailed(self)

			event.accept()

		# determine if the expand/collapse should occur
		elif ( event.button() == Qt.LeftButton and self.expandCollapseRect().contains( event.pos() ) ):
			self._clicked = True
			event.accept()

		else:
			event.ignore()
Exemplo n.º 3
0
    def __onDragStarted(self, index):
        desc = index.data(QtWidgetRegistry.WIDGET_DESC_ROLE)
        icon = index.data(Qt.DecorationRole)

        drag_data = QMimeData()
        drag_data.setData(
            "application/vnv.orange-canvas.registry.qualified-name",
            desc.qualified_name.encode('utf-8'))
        drag = QDrag(self)
        drag.setPixmap(icon.pixmap(38))
        drag.setMimeData(drag_data)

        # TODO: Should animate (accept) hide.
        self.hide()

        # When a drag is started and the menu hidden the item's tool tip
        # can still show for a short time UNDER the cursor preventing a
        # drop.
        viewport = self.__menu.view().viewport()
        filter = ToolTipEventFilter()
        viewport.installEventFilter(filter)

        drag.exec_(Qt.CopyAction)

        viewport.removeEventFilter(filter)
Exemplo n.º 4
0
 def eventFilter( self, object, event ):
     if event.type() == event.MouseButtonPress:
         if self.isLocked():
             return False
             
         if event.button() == Qt.MidButton or \
            (event.button() == Qt.LeftButton and \
             event.modifiers() == Qt.ShiftModifier):
             index = self.tabBar().tabAt(event.pos())
             view  = self.widget(index)
             pixmap = QPixmap.grabWidget(view)
             drag = QDrag(self)
             data = QMimeData()
             data.setText('move view:{}'.format(index))
             drag.setMimeData(data)
             drag.setPixmap(pixmap)
             drag.exec_()
             
             return True
         return False
         
     elif event.type() == event.DragEnter:
         if ( str(event.mimeData().text()).startswith('move view:') and
              event.source() != self ):
             event.acceptProposedAction()
         return True
     
     elif event.type() == event.Drop:
         text = str(event.mimeData().text())
         splt = text.split(':')
         self.snagViewFromPanel(event.source(), int(splt[1]))
         return True
     
     return False
Exemplo n.º 5
0
    def mousePressEvent(self, event):
        # handle an internal move

        # start a drag event
        if event.button() == Qt.LeftButton and self.dragDropRect().contains(
                event.pos()):
            # create the pixmap
            pixmap = QPixmap.grabWidget(self, self.rect())

            # create the mimedata
            mimeData = QMimeData()
            mimeData.setText('ItemTitle::%s' % (self.title()))

            # create the drag
            drag = QDrag(self)
            drag.setMimeData(mimeData)
            drag.setPixmap(pixmap)
            drag.setHotSpot(event.pos())

            if not drag.exec_():
                self._accordianWidget.emitItemDragFailed(self)

            event.accept()

        # determine if the expand/collapse should occur
        elif event.button() == Qt.LeftButton and self.expandCollapseRect(
        ).contains(event.pos()):
            self._clicked = True
            event.accept()

        else:
            event.ignore()
Exemplo n.º 6
0
def dragFile(widget, filename, icon=None, dropactions=Qt.CopyAction):
    """Starts dragging the given local file from the widget."""
    if icon is None or icon.isNull():
        icon = QFileIconProvider().icon(QFileInfo(filename))
    drag = QDrag(widget)
    data = QMimeData()
    data.setUrls([QUrl.fromLocalFile(filename)])
    drag.setMimeData(data)
    drag.setPixmap(icon.pixmap(32))
    drag.exec_(dropactions)
Exemplo n.º 7
0
 def startDrag(self,event):
     drag = QDrag(event.widget())
     drag.setPixmap(self.mute.icon().pixmap(self.size().height(),self.size().height()))
     mimedata = QMimeData()
     liste = []
     liste.append(QUrl( "veromix://sink_index:"+str(int(self.index)) ))
     mimedata.setUrls(liste)
     drag.setMimeData(mimedata)
     #drag.setHotSpot(event.pos() - self.rect().topLeft())
     dropAction = drag.start(Qt.MoveAction)
Exemplo n.º 8
0
def dragFile(widget, filename, icon=None, dropactions=Qt.CopyAction):
    """Starts dragging the given local file from the widget."""
    if icon is None or icon.isNull():
        icon = QFileIconProvider().icon(QFileInfo(filename))
    drag = QDrag(widget)
    data = QMimeData()
    data.setUrls([QUrl.fromLocalFile(filename)])
    drag.setMimeData(data)
    drag.setPixmap(icon.pixmap(32))
    drag.exec_(dropactions)
Exemplo n.º 9
0
 def startDrag(self):
     image = self.image()
     data = QMimeData()
     data.setImageData(image)
     drag = QDrag(self)
     drag.setMimeData(data)
     if max(image.width(), image.height()) > 256:
         image = image.scaled(QSize(256, 256), Qt.KeepAspectRatio, Qt.SmoothTransformation)
     pixmap = QPixmap.fromImage(image)
     drag.setPixmap(pixmap)
     drag.setHotSpot(pixmap.rect().center())
     drag.exec_(Qt.CopyAction)
Exemplo n.º 10
0
 def __startDrag(self, button):
     """
     Start a drag from button
     """
     action = button.defaultAction()
     desc = action.data()  # Widget Description
     icon = action.icon()
     drag_data = QMimeData()
     drag_data.setData("application/vnv.orange-canvas.registry.qualified-name", desc.qualified_name.encode("utf-8"))
     drag = QDrag(button)
     drag.setPixmap(icon.pixmap(self.iconSize()))
     drag.setMimeData(drag_data)
     drag.exec_(Qt.CopyAction)
Exemplo n.º 11
0
 def drag(self, tile=None, meld=None):
     """returns a drag object"""
     drag = QDrag(self)
     mimeData = MimeData(tile, meld)
     drag.setMimeData(mimeData)
     tile = tile or meld[0]
     graphics = tile.graphics
     tRect = graphics.boundingRect()
     tRect = self.viewportTransform().mapRect(tRect)
     pmapSize = QSize(tRect.width() * graphics.scale(), tRect.height() * graphics.scale())
     pMap = graphics.pixmapFromSvg(pmapSize)
     drag.setPixmap(pMap)
     drag.setHotSpot(QPoint(pMap.width()/2, pMap.height()/2))
     return drag
Exemplo n.º 12
0
 def drag(self, tile=None, meld=None):
     """returns a drag object"""
     drag = QDrag(self)
     mimeData = MimeData(tile, meld)
     drag.setMimeData(mimeData)
     tile = tile or meld[0]
     graphics = tile.graphics
     tRect = graphics.boundingRect()
     tRect = self.viewportTransform().mapRect(tRect)
     pmapSize = QSize(tRect.width() * graphics.scale(), tRect.height() * graphics.scale())
     pMap = graphics.pixmapFromSvg(pmapSize)
     drag.setPixmap(pMap)
     drag.setHotSpot(QPoint(pMap.width()/2, pMap.height()/2))
     return drag
Exemplo n.º 13
0
 def __startDrag(self, button):
     """
     Start a drag from button
     """
     action = button.defaultAction()
     desc = action.data()  # Widget Description
     icon = action.icon()
     drag_data = QMimeData()
     drag_data.setData(
         "application/vnv.orange-canvas.registry.qualified-name",
         desc.qualified_name.encode("utf-8"))
     drag = QDrag(button)
     drag.setPixmap(icon.pixmap(self.iconSize()))
     drag.setMimeData(drag_data)
     drag.exec_(Qt.CopyAction)
Exemplo n.º 14
0
 def startDrag(self, mainwin, ev):
     d = mainwin.currentDocument()
     if not d:
         return
     url = d.url()
     if url.isEmpty():
         return
     drag = QDrag(mainwin)
     data = QMimeData()
     data.setUrls([url])
     drag.setMimeData(data)
     pixmap = mainwin.style().standardPixmap(QStyle.SP_FileIcon, 0, mainwin)
     hotspot = QPoint(pixmap.width() - 5, 5)
     drag.setPixmap(pixmap)
     drag.setHotSpot(hotspot)
     drag.start(Qt.LinkAction | Qt.CopyAction)
Exemplo n.º 15
0
    def start_drag(self, info_id):
        _logger.info( "started dragging" )
        mimeData = QMimeData()
        mimeData.data =("/" + info_id.partition("/")[2].partition("/")[0], moose.element(info_id))
        mimeData.setText(info_id)
        drag = QDrag(self)
        drag.setMimeData(mimeData)
        pixmap = QPixmap("")

        drag.setPixmap(pixmap)
        # drag.setHotSpot(e.pos() - self.rect().topLeft())
        dropAction = drag.start(QtCore.Qt.MoveAction)
        print((" => ", dropAction))
        self.select_info.set_event_type(0)
        self._timer.start(0)
        return
 def startDrag(self, mainwin, ev):
     d = mainwin.currentDocument()
     if not d:
         return
     url = d.url()
     if url.isEmpty():
         return
     drag = QDrag(mainwin)
     data = QMimeData()
     data.setUrls([url])
     drag.setMimeData(data)
     pixmap = mainwin.style().standardPixmap(QStyle.SP_FileIcon, 0, mainwin)
     hotspot = QPoint(pixmap.width() - 5, 5)
     drag.setPixmap(pixmap)
     drag.setHotSpot(hotspot)
     drag.start(Qt.LinkAction | Qt.CopyAction)
Exemplo n.º 17
0
    def mouseMoveEvent(self, event):
        if not (event.buttons() and Qt.LeftButton):
            return

        if ((event.pos() - self.drag_start_position).manhattanLength() <
                QApplication.startDragDistance()):
            return
        drag = QDrag(self)
        pix = QPixmap.grabWidget(self)
        drag.setPixmap(pix)
        mime_data = QMimeData()
        mime_data.setText(self.map.text())
        # mime_data.setImageData(self.currentmap)
        drag.setMimeData(mime_data)

        self.drop_action = drag.exec_(Qt.CopyAction | Qt.MoveAction)
Exemplo n.º 18
0
 def startDrag(self, event):
     index = self.indexAt(event.pos())
     if not index.isValid():
         return
     drag = QDrag(self)
     mimeData = QtCore.QMimeData()
     el = self.model().listdata[index.row()]
     print("dragging device with id: " + str(el['deviceid']))
     mimeData.setData("application/x-xinputdevice", pickle.dumps(el))
     drag.setMimeData(mimeData)
     pixmap = QtGui.QPixmap()
     pixmap = pixmap.grabWidget(self, self.rectForIndex(index))
     drag.setPixmap(pixmap)
     #drag.setHotSpot(QtCore.QPoint(pixmap.width()/2, pixmap.height()/2))
     result = drag.start(QtCore.Qt.MoveAction)
     if result == 1:
         self.model().listdata.remove(el)
Exemplo n.º 19
0
 def startDrag(self):
     image = self.image()
     data = QMimeData()
     data.setImageData(image)
     drag = QDrag(self)
     drag.setMimeData(data)
     if max(image.width(), image.height()) > 256:
         image = image.scaled(QSize(256, 256), Qt.KeepAspectRatio, Qt.SmoothTransformation)
     p = QPainter()
     p.begin(image)
     p.setCompositionMode(QPainter.CompositionMode_DestinationIn)
     p.fillRect(image.rect(), QColor(0, 0, 0, 160))
     p.end()
     pixmap = QPixmap.fromImage(image)
     drag.setPixmap(pixmap)
     drag.setHotSpot(pixmap.rect().center())
     drag.exec_(Qt.CopyAction)
Exemplo n.º 20
0
 def startDrag(self):
     image = self.image()
     data = QMimeData()
     data.setImageData(image)
     drag = QDrag(self)
     drag.setMimeData(data)
     if max(image.width(), image.height()) > 256:
         image = image.scaled(QSize(256, 256), Qt.KeepAspectRatio,
                              Qt.SmoothTransformation)
     p = QPainter()
     p.begin(image)
     p.setCompositionMode(QPainter.CompositionMode_DestinationIn)
     p.fillRect(image.rect(), QColor(0, 0, 0, 160))
     p.end()
     pixmap = QPixmap.fromImage(image)
     drag.setPixmap(pixmap)
     drag.setHotSpot(pixmap.rect().center())
     drag.exec_(Qt.CopyAction)
Exemplo n.º 21
0
    def start_drag(self, info_id):
        # pixmap = QPixmap()
        # painter = QPainter( pixmap )
        # painter.setFont( QFont("Arial") );
        # painter.drawText( QPoint(100, 100), info_id );
        mimeData = QMimeData()
        mimeData.data =("/" + info_id.partition("/")[2].partition("/")[0], moose.element(info_id))
        mimeData.setText(info_id)
        drag = QDrag(self)
        drag.setMimeData(mimeData)
        pixmap = QPixmap("")

        drag.setPixmap(pixmap)
        # drag.setHotSpot(e.pos() - self.rect().topLeft())
        dropAction = drag.start(QtCore.Qt.MoveAction)
        print(" => ", dropAction)
        self.select_info.set_event_type(0)
        self._timer.start(0)
        return
Exemplo n.º 22
0
    def startDrag(self, supportedActions):
        """ Overwritten function of QTreeWidget.

        This function creates a QDrag object representing the selected element of this TreeWidget.
        """
        logging.debug(self.__class__.__name__ +": startDrag()")
        indexes = self.selectedIndexes()
        if len(indexes) > 0:
            data = self.model().mimeData(indexes)
            if not data:
                return
            drag = QDrag(self)
            drag.setMimeData(data)
            if self.model().data(indexes[0], Qt.DecorationRole).type() == QVariant.Icon:
                icon = QIcon(self.model().data(indexes[0], Qt.DecorationRole))
                drag.setPixmap(icon.pixmap(QSize(50, 50)))
                drag.setHotSpot(QPoint(drag.pixmap().width()/2, drag.pixmap().height()/2))  # center icon in respect to cursor
            defaultDropAction = Qt.IgnoreAction
            drag.exec_(supportedActions, defaultDropAction)
Exemplo n.º 23
0
    def mouseMoveEvent(self, e):
        if self.drag_start is None:
            pass
        x = e.x() - self.drag_start.x()
        y = e.y() - self.drag_start.y()
        dist = QApplication.startDragDistance()
        if not self.draggable or x > dist or y > dist:
            return

        drag = QDrag(self)
        mime = QMimeData()
        mime.setText(self.__class__.__name__)
        mime.part = self
        drag.setMimeData(mime)
        pixmap = QPixmap.grabWidget(self)
        pixmap.setAlphaChannel(pixmap)
        drag.setPixmap(pixmap)
        drag.setHotSpot(QPoint(drag.pixmap().width() / 2,
                               drag.pixmap().height()))
        drag.start(Qt.CopyAction)
Exemplo n.º 24
0
    def mouseMoveEvent(self, e):
        if self.drag_start is None:
            pass
        x = e.x() - self.drag_start[0]
        y = e.y() - self.drag_start[1]
        dist = QApplication.startDragDistance()
        if (self.draggable is False) or (abs(x) < dist and abs(y) < dist):
            return

        drag = QDrag(self)
        mime = QMimeData()
        mime.setText(self.__class__.__name__)
        mime.part = self
        drag.setMimeData(mime)
        pixmap = QPixmap.grabWidget(self)
        pixmap.setAlphaChannel(pixmap)
        drag.setPixmap(pixmap)
        drag.setHotSpot(QPoint(drag.pixmap().width() / 2,
                               drag.pixmap().height()))
        self.dragging = True
        drag.start(Qt.CopyAction)
Exemplo n.º 25
0
    def mouseMoveEvent(self, event):
        drag = QDrag(event.widget())
        data = QMimeData()
        data.setText(self.commit.name())

        drag.setMimeData(data)

        #data.setColorData(GREEN)
        pixmap = QPixmap(COMMIT_WIDTH, COMMIT_HEIGHT)
        pixmap.fill(WHITE)
        painter = QPainter(pixmap)
        painter.translate(0, 0)
        painter.setRenderHint(QPainter.Antialiasing)
        painter.setPen(Qt.NoPen)
        painter.setBrush(QBrush(self.color))
        painter.drawPath(self.setup_display(0, 0))
        painter.end()

        pixmap.setMask(pixmap.createHeuristicMask())
        drag.setPixmap(pixmap)
        drag.setHotSpot(QPoint(0, 0))
        drag.start()
	def mouseMoveEvent(self, e):
		# Chequear que se esté presionando el botón izquierdo
		if e.buttons() != Qt.LeftButton:
			return

		# posicion del click dentro del gmod
		mimeData = QMimeData()

		pixmap = QPixmap.grabWidget(self)
		painter = QPainter(pixmap)
		painter.setCompositionMode(painter.CompositionMode_DestinationIn)
		painter.fillRect(pixmap.rect(), QColor(0, 0, 0, 127))
		painter.end()

		drag = QDrag(self)
		# escribir el MimeData
		drag.setMimeData(mimeData)
		# establecer el Pixmap
		drag.setPixmap(pixmap)
		# posicionar correctamente el pixmap
		drag.setHotSpot(e.pos())

		drag.exec_(Qt.MoveAction)
Exemplo n.º 27
0
    def mouseMoveEvent(self, event):
        if not (event.buttons() and Qt.LeftButton):
            return
        currentItem = self.currentItem()
        if(currentItem.isFile()):
            if(currentItem.isPic()):
                currentItemName = self.currentItem().getPath()
                data = QByteArray()
                stream = QDataStream(data, QIODevice.WriteOnly)
                stream.writeQString(currentItemName)
                
                icon = Icons.image
                pixmap = icon.pixmap(64, 64)
 
                mimeData = QMimeData()
                mimeData.setText(currentItemName)
                mimeData.setData('application/x-item', data)
 
                drag = QDrag(self)
                drag.setPixmap(pixmap)
                drag.setHotSpot(QPoint(pixmap.width()/2, pixmap.height()/2))  
                drag.setMimeData(mimeData)
                dropAction = drag.start(Qt.CopyAction)
Exemplo n.º 28
0
 def startDrag(self, supportedActions):
     """ Overwritten function of QTreeWidget.
     
     This function creates a QDrag object representing the selected element of this TreeWidget.
     """
     logging.debug(self.__class__.__name__ + ": startDrag()")
     indexes = self.selectedIndexes()
     if len(indexes) > 0:
         data = self.model().mimeData(indexes)
         if not data:
             return
         drag = QDrag(self)
         drag.setMimeData(data)
         if self.model().data(indexes[0],
                              Qt.DecorationRole).type() == QVariant.Icon:
             icon = QIcon(self.model().data(indexes[0], Qt.DecorationRole))
             drag.setPixmap(icon.pixmap(QSize(50, 50)))
             drag.setHotSpot(
                 QPoint(drag.pixmap().width() / 2,
                        drag.pixmap().height() /
                        2))  # center icon in respect to cursor
         defaultDropAction = Qt.IgnoreAction
         drag.exec_(supportedActions, defaultDropAction)
Exemplo n.º 29
0
 def startDrag(self, event):
     child = self.childAt(event.pos())
     if not child:
         return
     pos_in_child = event.pos() - child.pos()
     
     data = QByteArray()
     stream = QDataStream(data, QIODevice.WriteOnly)
     stream << QVariant(child.value()) << QPoint(pos_in_child)
     
     mime = QMimeData()
     mime.setData("application/x-fridgemagnet", data)
     
     drag = QDrag(child)
     drag.setMimeData(mime)
     drag.setPixmap(QPixmap.grabWidget(child))
     drag.setHotSpot(pos_in_child)
     
     child.hide()
     
     if (drag.start(Qt.MoveAction or Qt.CopyAction) == Qt.MoveAction):
         child.close()
     else:
         child.show()