[Qt-interest] Windows: Copy from Qt app into GIMP fails?
Oliver.Knoll at comit.ch
Oliver.Knoll at comit.ch
Wed Feb 16 17:14:00 CET 2011
On 2011-02-16 Jason Jason H wrote:
> ...
> What I meant with the URL thing was use that as MIME type Content-
> type:application/url etc.
Yes, I understood what you meant with the "workaround". But a) Gimp does not accept URLs for copy/paste, e.g. copying a file path in File Explorer and then trying to paste that into Gimp does not work (note that DRAG'n'dropping the same URL does work off course, GIMP will open that file). And most importantly b) that would not be an option in my case anyway, since I do not have the images on disk - the image data exists entirely in memory (until saved off course to some data file), hence I could not specify a URL.
> Drag an image from Firefox to GIMP, and see how FF does it.
Left apart from looking at either the GIMP or FF code, how would I do that? ;)
Oh and note, I am talking about COPY and paste, not DRAG and drop (that does make a difference, different code paths are executed, at least in my application which ALSO supports both COPY/paste and DRAG'n'drop INTO my application). So I am really talking about right-click on an image in FF, choose "Copy" and then pasting it into GIMP (or into my application).
> Also, if you haven't
> already, make your app accept drops
Again, we are talking COPY/paste, not DRAG'n'drops ;) But my application supports both anyway ;)
> and log the mime data,
As a matter of fact I also tried this before: For instance, when copy/paste an image from Firefox to my Qt application I get:
// upon paste action triggered
const QMimeData *mimeData = clipboard->mimeData();
foreach(QString format, mimeData->formats()) {
qDebug("MIME: %s", qPrintable(format));
}
MIME: application/x-moz-nativeimage
MIME: application/x-qt-image
That is internally Qt already parses the clipboard data, recognizes that there is "image data" and converts it to a "QImage compatible" data structure and sets the MIME type to "x-qt-image". "x-moz-nativeimage" is probably the original data structure from Firefox. So no big help here.
Now when copying an image FROM GIMP and pasting to my application, I get the following MIME types:
MIME: application/x-qt-windows-mime;value="PNG"
MIME: application/x-qt-image
When copying from MS Word 2007 to my application I get:
MIME: application/x-qt-windows-mime;value="Art::GVML ClipFormat"
MIME: application/x-qt-windows-mime;value="PNG"
MIME: application/x-qt-image
MIME: application/x-qt-windows-mime;value="JFIF"
MIME: application/x-qt-windows-mime;value="GIF"
MIME: application/x-qt-windows-mime;value="Object Descriptor"
Now when copying the image from one instance of my application to another instance of the same Qt application I get:
MIME: application/x-qt-image
MIME: application/x-screenie
MIME: text/xml
So again the "generic" application/x-qt-image here (the other MIME types I also set explicitly; they are used when copying within the same instance ("memory to memory") respective serialized as XML when copying across different instances of my application).
Oh, and off course I also disabled testwise these two additional MIME types, but same result, GIMP would not accept the clipboard content - all other applications (which accept image data) that I have tested so far on Windows do. :/
So what I could try is to explicitly convert the image to PNG in a QByteArray and set the MIME type to "application/x-qt-windows-mime;value="PNG" on Windows and see whether that would make a difference... or use one of these http://doc.trolltech.com/4.7/qwindowsmime.html#formatsForMime methods, but that would result in platform-dependent code again :/ (and not guaranteed if it would work)
> and figure out which
> method works for GIMP, then drop on your app.
What do you mean by "figure out", except looking at the GIMP source code? Is there some log file generated by GIMP or can I enable debug statements with some command line switch maybe? --debug or -debug did not work...
Thanks,
Oliver
--
Oliver Knoll
Dipl. Informatik-Ing. ETH
COMIT AG - ++41 79 520 95 22
More information about the Qt-interest-old
mailing list