Windows: Use native-looking drag cursors
QWindowsDrag::defaultCursor() used xpm-based cursors which are aliased, dark and not available in different sizes. This patch uses the new cursors from QWindowsCursor::customCursor for the drag cursors and gets the ignoreDragCursor from the system. If fetching the ignoreDragCursor cursor fails, we still fall back to the ignoreDragCursor.xpm. The other xpms were moved to QWindowsDrag::defaultCursor() for the WinCE or non-png case. Change-Id: If216ffc8c9cc134529b7addd0121857d41805eac Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
This commit is contained in:
parent
14a80bd4df
commit
6577ac381e
@ -303,6 +303,104 @@ QCursor QWindowsCursor::customCursor(Qt::CursorShape cursorShape)
|
||||
0xf0,0x7f,0xf8,0x7f,0xfc,0x7f,0xfc,0x3f,0xf8,0x3f,0xf0,0x1f,
|
||||
0xe0,0x1f,0xe0,0x1f,0x00,0x00,0x00,0x00};
|
||||
|
||||
static const char * const moveDragCursorXpmC[] = {
|
||||
"11 20 3 1",
|
||||
". c None",
|
||||
"a c #FFFFFF",
|
||||
"X c #000000", // X11 cursor is traditionally black
|
||||
"aa.........",
|
||||
"aXa........",
|
||||
"aXXa.......",
|
||||
"aXXXa......",
|
||||
"aXXXXa.....",
|
||||
"aXXXXXa....",
|
||||
"aXXXXXXa...",
|
||||
"aXXXXXXXa..",
|
||||
"aXXXXXXXXa.",
|
||||
"aXXXXXXXXXa",
|
||||
"aXXXXXXaaaa",
|
||||
"aXXXaXXa...",
|
||||
"aXXaaXXa...",
|
||||
"aXa..aXXa..",
|
||||
"aa...aXXa..",
|
||||
"a.....aXXa.",
|
||||
"......aXXa.",
|
||||
".......aXXa",
|
||||
".......aXXa",
|
||||
"........aa."};
|
||||
|
||||
static const char * const copyDragCursorXpmC[] = {
|
||||
"24 30 3 1",
|
||||
". c None",
|
||||
"a c #000000",
|
||||
"X c #FFFFFF",
|
||||
"XX......................",
|
||||
"XaX.....................",
|
||||
"XaaX....................",
|
||||
"XaaaX...................",
|
||||
"XaaaaX..................",
|
||||
"XaaaaaX.................",
|
||||
"XaaaaaaX................",
|
||||
"XaaaaaaaX...............",
|
||||
"XaaaaaaaaX..............",
|
||||
"XaaaaaaaaaX.............",
|
||||
"XaaaaaaXXXX.............",
|
||||
"XaaaXaaX................",
|
||||
"XaaXXaaX................",
|
||||
"XaX..XaaX...............",
|
||||
"XX...XaaX...............",
|
||||
"X.....XaaX..............",
|
||||
"......XaaX..............",
|
||||
".......XaaX.............",
|
||||
".......XaaX.............",
|
||||
"........XX...aaaaaaaaaaa",
|
||||
".............aXXXXXXXXXa",
|
||||
".............aXXXXXXXXXa",
|
||||
".............aXXXXaXXXXa",
|
||||
".............aXXXXaXXXXa",
|
||||
".............aXXaaaaaXXa",
|
||||
".............aXXXXaXXXXa",
|
||||
".............aXXXXaXXXXa",
|
||||
".............aXXXXXXXXXa",
|
||||
".............aXXXXXXXXXa",
|
||||
".............aaaaaaaaaaa"};
|
||||
|
||||
static const char * const linkDragCursorXpmC[] = {
|
||||
"24 30 3 1",
|
||||
". c None",
|
||||
"a c #000000",
|
||||
"X c #FFFFFF",
|
||||
"XX......................",
|
||||
"XaX.....................",
|
||||
"XaaX....................",
|
||||
"XaaaX...................",
|
||||
"XaaaaX..................",
|
||||
"XaaaaaX.................",
|
||||
"XaaaaaaX................",
|
||||
"XaaaaaaaX...............",
|
||||
"XaaaaaaaaX..............",
|
||||
"XaaaaaaaaaX.............",
|
||||
"XaaaaaaXXXX.............",
|
||||
"XaaaXaaX................",
|
||||
"XaaXXaaX................",
|
||||
"XaX..XaaX...............",
|
||||
"XX...XaaX...............",
|
||||
"X.....XaaX..............",
|
||||
"......XaaX..............",
|
||||
".......XaaX.............",
|
||||
".......XaaX.............",
|
||||
"........XX...aaaaaaaaaaa",
|
||||
".............aXXXXXXXXXa",
|
||||
".............aXXXaaaaXXa",
|
||||
".............aXXXXaaaXXa",
|
||||
".............aXXXaaaaXXa",
|
||||
".............aXXaaaXaXXa",
|
||||
".............aXXaaXXXXXa",
|
||||
".............aXXaXXXXXXa",
|
||||
".............aXXXaXXXXXa",
|
||||
".............aXXXXXXXXXa",
|
||||
".............aaaaaaaaaaa"};
|
||||
|
||||
switch (cursorShape) {
|
||||
case Qt::SplitVCursor:
|
||||
return createPixmapCursorFromData(systemCursorSize(), standardCursorSize(), 32, vsplit_bits, vsplitm_bits);
|
||||
@ -313,9 +411,11 @@ QCursor QWindowsCursor::customCursor(Qt::CursorShape cursorShape)
|
||||
case Qt::ClosedHandCursor:
|
||||
return createPixmapCursorFromData(systemCursorSize(), standardCursorSize(), 16, closedhand_bits, closedhandm_bits);
|
||||
case Qt::DragCopyCursor:
|
||||
return QCursor(QPixmap(copyDragCursorXpmC), 0, 0);
|
||||
case Qt::DragMoveCursor:
|
||||
return QCursor(QPixmap(moveDragCursorXpmC), 0, 0);
|
||||
case Qt::DragLinkCursor:
|
||||
return QCursor(QGuiApplicationPrivate::instance()->getPixmapCursor(cursorShape), 0, 0);
|
||||
return QCursor(QPixmap(linkDragCursorXpmC), 0, 0);
|
||||
}
|
||||
|
||||
return QCursor();
|
||||
|
@ -69,146 +69,6 @@
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
// These pixmaps approximate the images in the Windows User Interface Guidelines.
|
||||
// XPM
|
||||
|
||||
static const char * const moveDragCursorXpmC[] = {
|
||||
"11 20 3 1",
|
||||
". c None",
|
||||
"a c #FFFFFF",
|
||||
"X c #000000", // X11 cursor is traditionally black
|
||||
"aa.........",
|
||||
"aXa........",
|
||||
"aXXa.......",
|
||||
"aXXXa......",
|
||||
"aXXXXa.....",
|
||||
"aXXXXXa....",
|
||||
"aXXXXXXa...",
|
||||
"aXXXXXXXa..",
|
||||
"aXXXXXXXXa.",
|
||||
"aXXXXXXXXXa",
|
||||
"aXXXXXXaaaa",
|
||||
"aXXXaXXa...",
|
||||
"aXXaaXXa...",
|
||||
"aXa..aXXa..",
|
||||
"aa...aXXa..",
|
||||
"a.....aXXa.",
|
||||
"......aXXa.",
|
||||
".......aXXa",
|
||||
".......aXXa",
|
||||
"........aa."};
|
||||
|
||||
|
||||
/* XPM */
|
||||
static const char * const copyDragCursorXpmC[] = {
|
||||
"24 30 3 1",
|
||||
". c None",
|
||||
"a c #000000",
|
||||
"X c #FFFFFF",
|
||||
"XX......................",
|
||||
"XaX.....................",
|
||||
"XaaX....................",
|
||||
"XaaaX...................",
|
||||
"XaaaaX..................",
|
||||
"XaaaaaX.................",
|
||||
"XaaaaaaX................",
|
||||
"XaaaaaaaX...............",
|
||||
"XaaaaaaaaX..............",
|
||||
"XaaaaaaaaaX.............",
|
||||
"XaaaaaaXXXX.............",
|
||||
"XaaaXaaX................",
|
||||
"XaaXXaaX................",
|
||||
"XaX..XaaX...............",
|
||||
"XX...XaaX...............",
|
||||
"X.....XaaX..............",
|
||||
"......XaaX..............",
|
||||
".......XaaX.............",
|
||||
".......XaaX.............",
|
||||
"........XX...aaaaaaaaaaa",
|
||||
".............aXXXXXXXXXa",
|
||||
".............aXXXXXXXXXa",
|
||||
".............aXXXXaXXXXa",
|
||||
".............aXXXXaXXXXa",
|
||||
".............aXXaaaaaXXa",
|
||||
".............aXXXXaXXXXa",
|
||||
".............aXXXXaXXXXa",
|
||||
".............aXXXXXXXXXa",
|
||||
".............aXXXXXXXXXa",
|
||||
".............aaaaaaaaaaa"};
|
||||
|
||||
/* XPM */
|
||||
static const char * const linkDragCursorXpmC[] = {
|
||||
"24 30 3 1",
|
||||
". c None",
|
||||
"a c #000000",
|
||||
"X c #FFFFFF",
|
||||
"XX......................",
|
||||
"XaX.....................",
|
||||
"XaaX....................",
|
||||
"XaaaX...................",
|
||||
"XaaaaX..................",
|
||||
"XaaaaaX.................",
|
||||
"XaaaaaaX................",
|
||||
"XaaaaaaaX...............",
|
||||
"XaaaaaaaaX..............",
|
||||
"XaaaaaaaaaX.............",
|
||||
"XaaaaaaXXXX.............",
|
||||
"XaaaXaaX................",
|
||||
"XaaXXaaX................",
|
||||
"XaX..XaaX...............",
|
||||
"XX...XaaX...............",
|
||||
"X.....XaaX..............",
|
||||
"......XaaX..............",
|
||||
".......XaaX.............",
|
||||
".......XaaX.............",
|
||||
"........XX...aaaaaaaaaaa",
|
||||
".............aXXXXXXXXXa",
|
||||
".............aXXXaaaaXXa",
|
||||
".............aXXXXaaaXXa",
|
||||
".............aXXXaaaaXXa",
|
||||
".............aXXaaaXaXXa",
|
||||
".............aXXaaXXXXXa",
|
||||
".............aXXaXXXXXXa",
|
||||
".............aXXXaXXXXXa",
|
||||
".............aXXXXXXXXXa",
|
||||
".............aaaaaaaaaaa"};
|
||||
|
||||
static const char * const ignoreDragCursorXpmC[] = {
|
||||
"24 30 3 1",
|
||||
". c None",
|
||||
"a c #000000",
|
||||
"X c #FFFFFF",
|
||||
"aa......................",
|
||||
"aXa.....................",
|
||||
"aXXa....................",
|
||||
"aXXXa...................",
|
||||
"aXXXXa..................",
|
||||
"aXXXXXa.................",
|
||||
"aXXXXXXa................",
|
||||
"aXXXXXXXa...............",
|
||||
"aXXXXXXXXa..............",
|
||||
"aXXXXXXXXXa.............",
|
||||
"aXXXXXXaaaa.............",
|
||||
"aXXXaXXa................",
|
||||
"aXXaaXXa................",
|
||||
"aXa..aXXa...............",
|
||||
"aa...aXXa...............",
|
||||
"a.....aXXa..............",
|
||||
"......aXXa.....XXXX.....",
|
||||
".......aXXa..XXaaaaXX...",
|
||||
".......aXXa.XaaaaaaaaX..",
|
||||
"........aa.XaaaXXXXaaaX.",
|
||||
"...........XaaaaX..XaaX.",
|
||||
"..........XaaXaaaX..XaaX",
|
||||
"..........XaaXXaaaX.XaaX",
|
||||
"..........XaaX.XaaaXXaaX",
|
||||
"..........XaaX..XaaaXaaX",
|
||||
"...........XaaX..XaaaaX.",
|
||||
"...........XaaaXXXXaaaX.",
|
||||
"............XaaaaaaaaX..",
|
||||
".............XXaaaaXX...",
|
||||
"...............XXXX....."};
|
||||
|
||||
/*!
|
||||
\class QWindowsDragCursorWindow
|
||||
\brief A toplevel window showing the drag icon in case of touch drag.
|
||||
@ -864,22 +724,86 @@ QPixmap QWindowsDrag::defaultCursor(Qt::DropAction action) const
|
||||
switch (action) {
|
||||
case Qt::CopyAction:
|
||||
if (m_copyDragCursor.isNull())
|
||||
m_copyDragCursor = QPixmap(copyDragCursorXpmC);
|
||||
m_copyDragCursor = QWindowsCursor::customCursor(Qt::DragCopyCursor).pixmap();
|
||||
return m_copyDragCursor;
|
||||
case Qt::TargetMoveAction:
|
||||
case Qt::MoveAction:
|
||||
if (m_moveDragCursor.isNull())
|
||||
m_moveDragCursor = QPixmap(moveDragCursorXpmC);
|
||||
m_moveDragCursor = QWindowsCursor::customCursor(Qt::DragMoveCursor).pixmap();
|
||||
return m_moveDragCursor;
|
||||
case Qt::LinkAction:
|
||||
if (m_linkDragCursor.isNull())
|
||||
m_linkDragCursor = QPixmap(linkDragCursorXpmC);
|
||||
m_linkDragCursor = QWindowsCursor::customCursor(Qt::DragLinkCursor).pixmap();
|
||||
return m_linkDragCursor;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (m_ignoreDragCursor.isNull())
|
||||
|
||||
static const char * const ignoreDragCursorXpmC[] = {
|
||||
"24 30 3 1",
|
||||
". c None",
|
||||
"a c #000000",
|
||||
"X c #FFFFFF",
|
||||
"aa......................",
|
||||
"aXa.....................",
|
||||
"aXXa....................",
|
||||
"aXXXa...................",
|
||||
"aXXXXa..................",
|
||||
"aXXXXXa.................",
|
||||
"aXXXXXXa................",
|
||||
"aXXXXXXXa...............",
|
||||
"aXXXXXXXXa..............",
|
||||
"aXXXXXXXXXa.............",
|
||||
"aXXXXXXaaaa.............",
|
||||
"aXXXaXXa................",
|
||||
"aXXaaXXa................",
|
||||
"aXa..aXXa...............",
|
||||
"aa...aXXa...............",
|
||||
"a.....aXXa..............",
|
||||
"......aXXa.....XXXX.....",
|
||||
".......aXXa..XXaaaaXX...",
|
||||
".......aXXa.XaaaaaaaaX..",
|
||||
"........aa.XaaaXXXXaaaX.",
|
||||
"...........XaaaaX..XaaX.",
|
||||
"..........XaaXaaaX..XaaX",
|
||||
"..........XaaXXaaaX.XaaX",
|
||||
"..........XaaX.XaaaXXaaX",
|
||||
"..........XaaX..XaaaXaaX",
|
||||
"...........XaaX..XaaaaX.",
|
||||
"...........XaaaXXXXaaaX.",
|
||||
"............XaaaaaaaaX..",
|
||||
".............XXaaaaXX...",
|
||||
"...............XXXX....."};
|
||||
|
||||
if (m_ignoreDragCursor.isNull()) {
|
||||
#if !defined (Q_OS_WINCE)
|
||||
HCURSOR cursor = LoadCursor(NULL, IDC_NO);
|
||||
ICONINFO iconInfo = {0, 0, 0, 0, 0};
|
||||
GetIconInfo(cursor, &iconInfo);
|
||||
BITMAP bmColor = {0, 0, 0, 0, 0, 0, 0};
|
||||
|
||||
if (iconInfo.hbmColor
|
||||
&& GetObject(iconInfo.hbmColor, sizeof(BITMAP), &bmColor)
|
||||
&& bmColor.bmWidth == bmColor.bmWidthBytes / 4) {
|
||||
const int colorBitsLength = bmColor.bmHeight * bmColor.bmWidthBytes;
|
||||
uchar *colorBits = new uchar[colorBitsLength];
|
||||
GetBitmapBits(iconInfo.hbmColor, colorBitsLength, colorBits);
|
||||
const QImage colorImage(colorBits, bmColor.bmWidth, bmColor.bmHeight,
|
||||
bmColor.bmWidthBytes, QImage::Format_ARGB32);
|
||||
|
||||
m_ignoreDragCursor = QPixmap::fromImage(colorImage);
|
||||
delete [] colorBits;
|
||||
} else {
|
||||
m_ignoreDragCursor = QPixmap(ignoreDragCursorXpmC);
|
||||
}
|
||||
|
||||
DeleteObject(iconInfo.hbmMask);
|
||||
DeleteObject(iconInfo.hbmColor);
|
||||
DestroyCursor(cursor);
|
||||
#else // !Q_OS_WINCE
|
||||
m_ignoreDragCursor = QPixmap(ignoreDragCursorXpmC);
|
||||
#endif // !Q_OS_WINCE
|
||||
}
|
||||
return m_ignoreDragCursor;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user