Changeset View
Standalone View
src/ExportManager.cpp
Context not available. | |||||
29 | #include <QPainter> | 29 | #include <QPainter> | ||
---|---|---|---|---|---|
30 | #include <QFileDialog> | 30 | #include <QFileDialog> | ||
31 | #include <QBuffer> | 31 | #include <QBuffer> | ||
32 | #include <QMimeData> | ||||
32 | 33 | | |||
33 | #include <KLocalizedString> | 34 | #include <KLocalizedString> | ||
34 | #include <KSharedConfig> | 35 | #include <KSharedConfig> | ||
rkflx: This does not compile, you'll need `QStringLiteral` around both string arguments.
Also, please… | |||||
@rkflx I'll edit this line of code and add QStringLiteral around both string literals. When we setImageData then format is "application/x-qt-image" ( using mimeData->formats() ) but setData() sets another mimeType "x-kde-force-image-copy" with same data returned for mimeType "application/x-qt-image". Now if we call mimeData->formats() then we have a QStringList of 2 mime types: kapillamba4: @rkflx I'll edit this line of code and add QStringLiteral around both string literals.
When we… | |||||
Thanks for explanation, but I know very well what this code does ;) I meant that you should add it to the summary of this Diff, which will become the commit message. This way if someone git blames this odd-looking x-kde-force-image-copy, he'll know what it is for. Also, I think you should describe it on a higher level, i.e. that Klipper ignores images by default, and therefore "Quit after Copy" or "Hotkey for capture to clipboard" do not work because without support by a clipboard manager on X11 access to the application's clipboard is lost as soon at the application exits. The new mimetype then will indicate to Klipper to always remember the new clipboard entry. rkflx: > Also, please describe in the summary how this mechanism is supposed to work and why you added… | |||||
rkflx: Use `QApplication::clipboard()->setMimeData`. | |||||
Context not available. | |||||
379 | void ExportManager::doCopyToClipboard() | 380 | void ExportManager::doCopyToClipboard() | ||
380 | { | 381 | { | ||
381 | QApplication::clipboard()->setPixmap(mSavePixmap, QClipboard::Clipboard); | 382 | QApplication::clipboard()->setPixmap(mSavePixmap, QClipboard::Clipboard); | ||
383 | QMimeData *mimeData = new QMimeData(); | ||||
384 | mimeData->setImageData(mSavePixmap.toImage()); | ||||
385 | mimeData->setData(QStringLiteral("x-kde-force-image-copy"), mimeData->data(QStringLiteral("application/x-qt-image"))); | ||||
386 | QApplication::clipboard()->setMimeData(mimeData, QClipboard::Clipboard); | ||||
382 | } | 387 | } | ||
383 | 388 | | |||
384 | void ExportManager::doPrint(QPrinter *printer) | 389 | void ExportManager::doPrint(QPrinter *printer) | ||
Context not available. |
This does not compile, you'll need QStringLiteral around both string arguments.
Also, please describe in the summary how this mechanism is supposed to work and why you added it.