From 5903d642406c843c4ca460fb5180c64121cd3932 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Thu, 20 Oct 2022 20:10:14 +0300 Subject: [PATCH] convert default DnD pixmap to KAT format NOTE: DnD requires PPM image format support, KAT only for the default pixmap but should function even without default image Signed-off-by: Ivailo Monev --- src/core/global/qconfig.h.cmake | 2 +- src/gui/kernel/qdnd_x11.cpp | 38 ++++++++++++++++-------------- src/gui/kernel/qwhatsthis.cpp | 32 +++---------------------- tests/auto/qdatastream/tst_qdatastream.cpp | 1 + 4 files changed, 25 insertions(+), 48 deletions(-) diff --git a/src/core/global/qconfig.h.cmake b/src/core/global/qconfig.h.cmake index 6676de481..79f70c5eb 100644 --- a/src/core/global/qconfig.h.cmake +++ b/src/core/global/qconfig.h.cmake @@ -314,7 +314,7 @@ #endif // Drag and drop -#if !defined(QT_NO_DRAGANDDROP) && (defined(QT_NO_CLIPBOARD) || defined(QT_NO_IMAGEFORMAT_XPM)) +#if !defined(QT_NO_DRAGANDDROP) && (defined(QT_NO_CLIPBOARD) || defined(QT_NO_IMAGEFORMAT_PPM)) # define QT_NO_DRAGANDDROP #endif diff --git a/src/gui/kernel/qdnd_x11.cpp b/src/gui/kernel/qdnd_x11.cpp index f453e1d25..d105f5d4f 100644 --- a/src/gui/kernel/qdnd_x11.cpp +++ b/src/gui/kernel/qdnd_x11.cpp @@ -233,22 +233,20 @@ static QPixmap *defaultPm = 0; static const int default_pm_hotx = -2; static const int default_pm_hoty = -16; -/* XPM */ -static const char* const default_pm[] = { -"13 9 3 1", -". c None", -" c #000000", -"X c #FFFFFF", -"X X X X X X X", -" X X X X X X ", -"X ......... X", -" X.........X ", -"X ......... X", -" X.........X ", -"X ......... X", -" X X X X X X ", -"X X X X X X X" +#ifndef QT_NO_IMAGEFORMAT_KAT +// generated via `xxd -i ` +static const unsigned char default_pm_kat[] = { + 0x4b, 0x41, 0x54, 0x49, 0x45, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x01, 0xd4, 0x00, 0x00, 0x00, 0x34, 0x78, 0x01, + 0xbd, 0x8a, 0xc1, 0x09, 0x00, 0x40, 0x0c, 0xc2, 0xdc, 0x7f, 0x69, 0xaf, + 0x15, 0xf1, 0xeb, 0xbd, 0x1a, 0x68, 0x03, 0x12, 0x92, 0x04, 0x30, 0xff, + 0xc6, 0x73, 0x3f, 0xa4, 0xb7, 0x2b, 0xee, 0x56, 0xb2, 0xc6, 0x4e, 0x7a, + 0xbb, 0xe2, 0x6e, 0x25, 0x6b, 0xec, 0xa4, 0xbf, 0xf0, 0x03, 0x12, 0xc4, + 0xb3, 0x4d }; +static const unsigned int default_pm_kat_len = 86; +#endif // QT_NO_IMAGEFORMAT_KAT class QShapedPixmapWidget : public QWidget { @@ -538,7 +536,7 @@ QVariant QX11Data::xdndMimeConvertToFormat(Atom a, const QByteArray &data, const } } - // special cas for images + // special case for images if (format == QLatin1String("image/ppm")) { if (a == XA_PIXMAP && data.size() == sizeof(Pixmap)) { Pixmap xpm = *((Pixmap*)data.data()); @@ -1949,8 +1947,12 @@ void QDragManager::updatePixmap() pm_hot = dragPrivate()->hotspot; } if (pm.isNull()) { - if (!defaultPm) - defaultPm = new QPixmap(default_pm); + if (!defaultPm) { + defaultPm = new QPixmap(); +#ifndef QT_NO_IMAGEFORMAT_KAT + defaultPm->loadFromData(default_pm_kat, default_pm_kat_len, "KAT"); +#endif + } pm = *defaultPm; } xdnd_data.deco->pm_hot = pm_hot; diff --git a/src/gui/kernel/qwhatsthis.cpp b/src/gui/kernel/qwhatsthis.cpp index 77edc9fae..c253d430e 100644 --- a/src/gui/kernel/qwhatsthis.cpp +++ b/src/gui/kernel/qwhatsthis.cpp @@ -310,7 +310,7 @@ void QWhatsThat::paintEvent(QPaintEvent*) #if !defined(QT_NO_IMAGEFORMAT_KAT) // generated via `xxd -i ` -static const unsigned char button_image_bits[] = { +static const unsigned char button_image_bits_kat[] = { 0x4b, 0x41, 0x54, 0x49, 0x45, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x83, 0x78, 0x01, @@ -326,30 +326,7 @@ static const unsigned char button_image_bits[] = { 0xb0, 0xb7, 0x0d, 0x77, 0x51, 0xc1, 0x1a, 0xf6, 0xf6, 0x2d, 0xee, 0xe3, 0x1b, 0xdc, 0xc5, 0x2d, 0x3f, 0x1d, 0xde, 0x8d, 0x0b }; -static const unsigned int button_image_len = 165; -#elif !defined(QT_NO_IMAGEFORMAT_XPM) -/* XPM */ -static const char * const button_image[] = { -"16 16 3 1", -" c None", -"o c #000000", -"a c #000080", -"o aaaaa ", -"oo aaa aaa ", -"ooo aaa aaa", -"oooo aa aa", -"ooooo aa aa", -"oooooo a aaa", -"ooooooo aaa ", -"oooooooo aaa ", -"ooooooooo aaa ", -"ooooo aaa ", -"oo ooo ", -"o ooo aaa ", -" ooo aaa ", -" ooo ", -" ooo ", -" ooo "}; +static const unsigned int button_image_kat_len = 165; #endif // QT_NO_IMAGEFORMAT_KAT class QWhatsThisPrivate : public QObject @@ -481,10 +458,7 @@ QWhatsThisAction::QWhatsThisAction(QObject *parent) : QAction(tr("What's This?") { #if !defined(QT_NO_IMAGEFORMAT_KAT) QPixmap p; - p.loadFromData(button_image_bits, button_image_len, "KAT"); - setIcon(p); -#elif !defined(QT_NO_IMAGEFORMAT_XPM) - QPixmap p((const char**)button_image); + p.loadFromData(button_image_bits_kat, button_image_kat_len, "KAT"); setIcon(p); #endif setCheckable(true); diff --git a/tests/auto/qdatastream/tst_qdatastream.cpp b/tests/auto/qdatastream/tst_qdatastream.cpp index ea5cbe054..6bcb881b6 100644 --- a/tests/auto/qdatastream/tst_qdatastream.cpp +++ b/tests/auto/qdatastream/tst_qdatastream.cpp @@ -322,6 +322,7 @@ void tst_QDataStream::stream_data(int noOfElements) } } +/* XPM */ static const char* open_xpm[]={ "16 13 6 1", ". c None", -- 2.11.0