Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-134313

can't drag application/x-color from one Qt application to another (is it hex or raw?)

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.10
    • GUI: Drag and Drop
    • None

    Description

      QInternalMimeData::retrieveData() expects the application/x-color mime type to provide 8 bytes, apparently raw RGBA:

      QVariant QInternalMimeData::retrieveData(const QString &mimeType, QMetaType type) const
      {
      ...
          } else if (mimeType == "application/x-color"_L1 && data.metaType().id() == QMetaType::QByteArray) {
              QColor c;
              QByteArray ba = data.toByteArray();
              if (ba.size() == 8) {
                  ushort * colBuf = (ushort *)ba.data();
                  c.setRgbF(qreal(colBuf[0]) / qreal(0xFFFF),
                            qreal(colBuf[1]) / qreal(0xFFFF),
                            qreal(colBuf[2]) / qreal(0xFFFF),
                            qreal(colBuf[3]) / qreal(0xFFFF));
                  data = c;
              } else {
                  qWarning("Qt: Invalid color format");
              }
      

      But QMimeDataPrivate::retrieveTypedData() provides a 7-byte hex color representation (e.g. "#440044" or so, the ASCII bytes):

          } else if (typeId == QMetaType::QByteArray) {
      
              // try to convert to bytearray
              switch (data.metaType().id()) {
              case QMetaType::QByteArray:
              case QMetaType::QColor:
      qDebug() << "color -> BA" << data << data.toByteArray();
                  return data.toByteArray();
      

      The result is that the fix https://codereview.qt-project.org/c/qt/qtdeclarative/+/626673 for QTBUG-134226 doesn't actually allow me to drag a QColor from a QML application to qtbase/examples/widgets/draganddrop/dropsite.

      The question is, which one is right. I can drag a color from the QML application to GIMP's toolbox, FWIW.

      But we should support alpha somehow. I guess that's the reason for expecting a raw RGBA color. But there is also a valid hex representation for a color with alpha; so I guess QInternalMimeData::retrieveData() needs to be more flexible.

      It would be best to find a spec for this first, where the expectations for application/x-color are documented. (Should we support named colors too, for example?)

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              srutledg Shawn Rutledge
              srutledg Shawn Rutledge
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes