Handle empty piece icon when drag it on sheet.
This commit is contained in:
parent
23fd31ca08
commit
7e9222dabe
|
@ -184,7 +184,12 @@ void VPCarrouselPieceList::startDrag(Qt::DropActions supportedActions)
|
||||||
VPPiecePtr piece = pieceItem->GetPiece();
|
VPPiecePtr piece = pieceItem->GetPiece();
|
||||||
mimeData->SetPiecePtr(piece);
|
mimeData->SetPiecePtr(piece);
|
||||||
|
|
||||||
QPixmap pixmap = pieceItem->CreatePieceIcon(QSize(120, 120), true).pixmap(QSize(120, 120));
|
QIcon pieceIcon = pieceItem->CreatePieceIcon(QSize(120, 120), true);
|
||||||
|
QPixmap pixmap;
|
||||||
|
if (!pieceIcon.isNull())
|
||||||
|
{
|
||||||
|
pieceIcon.pixmap(QSize(120, 120));
|
||||||
|
}
|
||||||
|
|
||||||
drag->setDragCursor(VPMimeDataPiece::DragCursor(pixmap), Qt::MoveAction);
|
drag->setDragCursor(VPMimeDataPiece::DragCursor(pixmap), Qt::MoveAction);
|
||||||
drag->setMimeData(mimeData);
|
drag->setMimeData(mimeData);
|
||||||
|
|
|
@ -63,15 +63,22 @@ void VPMimeDataPiece::SetPiecePtr(const VPPiecePtr &piece)
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
auto VPMimeDataPiece::DragCursor(const QPixmap &piecePixmap) -> QPixmap
|
auto VPMimeDataPiece::DragCursor(const QPixmap &piecePixmap) -> QPixmap
|
||||||
{
|
{
|
||||||
QPixmap dragCursor(piecePixmap.width() * 2, piecePixmap.height() * 2);
|
|
||||||
dragCursor.fill(Qt::transparent);
|
|
||||||
QPainter painter(&dragCursor);
|
|
||||||
painter.drawPixmap(dragCursor.width() / 2, dragCursor.height() / 2, piecePixmap);
|
|
||||||
QPixmap cursor(QStringLiteral("://puzzlecursor/collect.png"));
|
QPixmap cursor(QStringLiteral("://puzzlecursor/collect.png"));
|
||||||
painter.drawPixmap(dragCursor.width() / 2 - cursor.width() / 2, dragCursor.height() / 2 - cursor.height() / 2,
|
|
||||||
cursor);
|
if (!piecePixmap.isNull())
|
||||||
painter.end();
|
{
|
||||||
return dragCursor;
|
QPixmap dragCursor(piecePixmap.width() * 2, piecePixmap.height() * 2);
|
||||||
|
dragCursor.fill(Qt::transparent);
|
||||||
|
QPainter painter(&dragCursor);
|
||||||
|
painter.drawPixmap(dragCursor.width() / 2, dragCursor.height() / 2, piecePixmap);
|
||||||
|
|
||||||
|
painter.drawPixmap(dragCursor.width() / 2 - cursor.width() / 2, dragCursor.height() / 2 - cursor.height() / 2,
|
||||||
|
cursor);
|
||||||
|
painter.end();
|
||||||
|
return dragCursor;
|
||||||
|
}
|
||||||
|
|
||||||
|
return cursor;
|
||||||
}
|
}
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
Loading…
Reference in New Issue
Block a user