Example #1
0
    def mouseDoubleClickEvent_Left(self, event):
        child = self.childAt(event.pos())
        if not child:
            return

        # Выделяем иконку
        highlight(child)

        dialog = Settings(self.parent, child, self.settings, self.s)
        res = dialog.exec_()
Example #2
0
    def mousePressEvent_Left(self, event):
        child = self.childAt(event.pos())
        if not child:
            return

        self.selected = child

        # Извлекаем отображение иконки
#       pixmap = QtGui.QPixmap(child.pixmap())
        pixmap = QtGui.QPixmap(child.taskData.get('img'))

        offset = event.pos() - child.pos()

        itemData = QtCore.QByteArray()
        dataStream = QtCore.QDataStream(itemData, QtCore.QIODevice.WriteOnly)
        dataStream << QtCore.QPoint(offset)

        mimeData = QtCore.QMimeData()
        mimeData.setData('application/x-dnditemdata', itemData)

        # Создаём QDrag
        rect = child.rect()
        w, h = rect.width(), rect.height()
        pixmap = QtGui.QPixmap(w, h)
        pixmap.fill(QtGui.QColor(255, 255, 255, 127))

        drag = QtGui.QDrag(self)
        drag.setMimeData(mimeData)
        drag.setPixmap(pixmap)
        drag.setHotSpot(offset)

        # Выделяем иконку
        highlight(child)

        res = drag.exec_(QtCore.Qt.CopyAction | QtCore.Qt.MoveAction, QtCore.Qt.MoveAction)
#       print res
        if res == QtCore.Qt.MoveAction:
            child.close()
        else:
            redraw(child)