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(schema);
|
||||||
Q_INIT_RESOURCE(flags);
|
Q_INIT_RESOURCE(flags);
|
||||||
Q_INIT_RESOURCE(style);
|
Q_INIT_RESOURCE(style);
|
||||||
|
Q_INIT_RESOURCE(cursor);
|
||||||
|
|
||||||
QT_REQUIRE_VERSION(argc, argv, "5.4.0")// clazy:exclude=qstring-arg,qstring-allocations
|
QT_REQUIRE_VERSION(argc, argv, "5.4.0")// clazy:exclude=qstring-arg,qstring-allocations
|
||||||
|
|
||||||
|
|
|
@ -60,6 +60,7 @@ UI_DIR = uic
|
||||||
include(puzzle.pri)
|
include(puzzle.pri)
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
|
share/resources/cursor.qrc \
|
||||||
share/resources/puzzleicon.qrc
|
share/resources/puzzleicon.qrc
|
||||||
|
|
||||||
include(../translations.pri)
|
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 |
|
@ -139,9 +139,9 @@ void VPCarrouselPieceList::startDrag(Qt::DropActions supportedActions)
|
||||||
VPPiece* piece = pieceItem->GetPiece();
|
VPPiece* piece = pieceItem->GetPiece();
|
||||||
mimeData->SetPiecePtr(piece);
|
mimeData->SetPiecePtr(piece);
|
||||||
|
|
||||||
QPixmap pixmap = pieceItem->CreatePieceIcon(QSize(120,120), true).pixmap(QSize(120,120));
|
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);
|
drag->setMimeData(mimeData);
|
||||||
if(drag->exec() == Qt::MoveAction)
|
if(drag->exec() == Qt::MoveAction)
|
||||||
{
|
{
|
||||||
|
|
|
@ -28,6 +28,9 @@
|
||||||
|
|
||||||
#include "vpmimedatapiece.h"
|
#include "vpmimedatapiece.h"
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
#include <QPixmap>
|
||||||
|
|
||||||
const QString VPMimeDataPiece::mineFormatPiecePtr = QStringLiteral("application/vnd.puzzle.piece.ptr");
|
const QString VPMimeDataPiece::mineFormatPiecePtr = QStringLiteral("application/vnd.puzzle.piece.ptr");
|
||||||
|
|
||||||
//---------------------------------------------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------------------------------------------
|
||||||
|
@ -47,3 +50,16 @@ void VPMimeDataPiece::SetPiecePtr(VPPiece* piece)
|
||||||
{
|
{
|
||||||
m_piece = 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);
|
void SetPiecePtr(VPPiece* piece);
|
||||||
|
|
||||||
|
static auto DragCursor(const QPixmap &piecePixmap) -> QPixmap;
|
||||||
|
|
||||||
static const QString mineFormatPiecePtr;
|
static const QString mineFormatPiecePtr;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user