Fix issue with drag pixmap.
It disappears if move cursor far enough. Instead draw a cursor which will include a piece pixmap.
This commit is contained in:
parent
5242b4ed54
commit
78382b5c97
|
@ -58,6 +58,7 @@ int main(int argc, char *argv[])
|
|||
Q_INIT_RESOURCE(schema);
|
||||
Q_INIT_RESOURCE(flags);
|
||||
Q_INIT_RESOURCE(style);
|
||||
Q_INIT_RESOURCE(cursor);
|
||||
|
||||
QT_REQUIRE_VERSION(argc, argv, "5.4.0")// clazy:exclude=qstring-arg,qstring-allocations
|
||||
|
||||
|
|
|
@ -60,6 +60,7 @@ UI_DIR = uic
|
|||
include(puzzle.pri)
|
||||
|
||||
RESOURCES += \
|
||||
share/resources/cursor.qrc \
|
||||
share/resources/puzzleicon.qrc
|
||||
|
||||
include(../translations.pri)
|
||||
|
|
6
src/app/puzzle/share/resources/cursor.qrc
Normal file
6
src/app/puzzle/share/resources/cursor.qrc
Normal file
|
@ -0,0 +1,6 @@
|
|||
<RCC>
|
||||
<qresource prefix="/">
|
||||
<file>cursor/collect.png</file>
|
||||
<file>cursor/collect@2x.png</file>
|
||||
</qresource>
|
||||
</RCC>
|
BIN
src/app/puzzle/share/resources/cursor/collect.png
Normal file
BIN
src/app/puzzle/share/resources/cursor/collect.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 294 B |
BIN
src/app/puzzle/share/resources/cursor/collect@2x.png
Normal file
BIN
src/app/puzzle/share/resources/cursor/collect@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 547 B |
|
@ -141,7 +141,7 @@ void VPCarrouselPieceList::startDrag(Qt::DropActions supportedActions)
|
|||
|
||||
QPixmap pixmap = pieceItem->CreatePieceIcon(QSize(120, 120), true).pixmap(QSize(120, 120));
|
||||
|
||||
drag->setPixmap(pixmap);
|
||||
drag->setDragCursor(VPMimeDataPiece::DragCursor(pixmap), Qt::MoveAction);
|
||||
drag->setMimeData(mimeData);
|
||||
if(drag->exec() == Qt::MoveAction)
|
||||
{
|
||||
|
|
|
@ -28,6 +28,9 @@
|
|||
|
||||
#include "vpmimedatapiece.h"
|
||||
|
||||
#include <QPainter>
|
||||
#include <QPixmap>
|
||||
|
||||
const QString VPMimeDataPiece::mineFormatPiecePtr = QStringLiteral("application/vnd.puzzle.piece.ptr");
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
|
@ -47,3 +50,16 @@ void VPMimeDataPiece::SetPiecePtr(VPPiece* piece)
|
|||
{
|
||||
m_piece = piece;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
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 = QPixmap("://cursor/collect.png");
|
||||
painter.drawPixmap(dragCursor.width()/2 - cursor.width()/2, dragCursor.height()/2 - cursor.height()/2, cursor);
|
||||
painter.end();
|
||||
return dragCursor;
|
||||
}
|
||||
|
|
|
@ -55,6 +55,8 @@ public:
|
|||
*/
|
||||
void SetPiecePtr(VPPiece* piece);
|
||||
|
||||
static auto DragCursor(const QPixmap &piecePixmap) -> QPixmap;
|
||||
|
||||
static const QString mineFormatPiecePtr;
|
||||
|
||||
private:
|
||||
|
|
Loading…
Reference in New Issue
Block a user