|
Krita Source Code Documentation
|
#include <kis_mimedata.h>
Inheritance diagram for KisMimeData:Public Types | |
| enum | MimeSource { MimeFromDragAndDrop = 0x0 , MimeFromClipboard = 0x1 } |
Public Member Functions | |
| KisPaintDeviceSP | clipFromKritaLayers (const KoColorSpace *cs, KisDefaultBoundsBaseSP defaultBounds) const |
| KisImageSP | clipImageFromKritaLayers (const KoColorSpace *cs) const |
| void | deepCopyNodes () |
| QStringList | formats () const override |
| KisMimeData (QList< KisNodeSP > nodes, KisImageSP image, const QRect referenceRect, bool forceCopy=false) | |
| QList< KisNodeSP > | nodes () const |
| return the node set on this mimedata object – for internal use | |
| const KoColorSpace * | referenceColorSpace () const |
Static Public Member Functions | |
| static KisDisplayConfig | displayConfigForMimePastes () |
| static bool | insertMimeLayers (const QMimeData *data, MimeSource mimeSource, KisImageSP image, KisShapeController *shapeController, KisNodeDummy *parentDummy, KisNodeDummy *aboveThisDummy, bool copyNode, KisNodeInsertionAdapter *nodeInsertionAdapter, std::optional< QPoint > preferredClipCenter=std::nullopt, KisProcessingApplicator *applicator=nullptr) |
| static bool | isNodeMimeDataFromSameImage (const QMimeData *data, KisImageSP image) |
| static KisNodeList | loadNodesFast (const QMimeData *data, MimeSource mimeSource, KisImageSP image, KisShapeController *shapeController, bool ©Node) |
| static KisNodeList | loadNodesFastAndRecenter (const QPoint &preferredCenter, const QMimeData *data, MimeSource mimeSource, KisImageSP image, KisShapeController *shapeController, bool ©Node) |
| static QMimeData * | mimeForLayers (const KisNodeList &nodes, KisImageSP image, bool forceCopy=false) |
| static QMimeData * | mimeForLayersDeepCopy (const KisNodeList &nodes, KisImageSP image, const QRect referenceRect, bool forceCopy) |
Protected Member Functions | |
| QVariant | retrieveData (const QString &mimetype, QMetaType preferredType) const override |
Private Member Functions | |
| KisPaintDeviceSP | clipFromKritaLayersImpl (const KoColorSpace *cs, const QRect &referenceImageRect) const |
Static Private Member Functions | |
| static void | initializeExternalNode (KisNodeSP *nodes, KisImageSP srcImage, KisImageSP dstImage, KisShapeController *shapeController) |
| static KisNodeList | loadNonNativeNodes (const QMimeData *data, KisImageWSP image) |
| static KisNodeList | tryLoadInternalNodes (const QMimeData *data, MimeSource mimeSource, KisImageSP image, KisShapeController *shapeController, bool ©Node) |
Private Attributes | |
| bool | m_forceCopy |
| KisImageSP | m_image |
| QList< KisNodeSP > | m_nodes |
| const KoColorSpace * | m_referenceColorSpace {nullptr} |
| QRect | m_referenceRect |
| qreal | m_referenceResX {1.0} |
| qreal | m_referenceResY {1.0} |
KisMimeData implements delayed retrieval of nodes for d&d and copy/paste.
TODO: implement support for the ora format.
Definition at line 33 of file kis_mimedata.h.
| Enumerator | |
|---|---|
| MimeFromDragAndDrop | |
| MimeFromClipboard | |
Definition at line 37 of file kis_mimedata.h.
| KisMimeData::KisMimeData | ( | QList< KisNodeSP > | nodes, |
| KisImageSP | image, | ||
| const QRect | referenceRect, | ||
| bool | forceCopy = false ) |
Definition at line 62 of file kis_mimedata.cpp.
References KisImage::colorSpace(), KIS_SAFE_ASSERT_RECOVER_RETURN, m_nodes, m_referenceColorSpace, m_referenceRect, m_referenceResX, m_referenceResY, nodes(), KisLayerUtils::recursiveTightNodeVisibleBounds(), KisImage::xRes(), and KisImage::yRes().
| KisPaintDeviceSP KisMimeData::clipFromKritaLayers | ( | const KoColorSpace * | cs, |
| KisDefaultBoundsBaseSP | defaultBounds ) const |
Definition at line 254 of file kis_mimedata.cpp.
References KisDefaultBoundsBase::bounds(), clipFromKritaLayersImpl(), and KisPaintDevice::setDefaultBounds().
|
private |
HACK ALERT: here we just initialize parent image link and skip initializing shapeController! Ideally, we should call initializeExternalNode() instead.
Definition at line 155 of file kis_mimedata.cpp.
References KisNodeFacade::addNode(), KisImage::bounds(), KisBaseNode::colorSpace(), KisLayerUtils::filterMergeableNodes(), KisBaseNode::image, KoColorSpaceRegistry::instance(), KIS_SAFE_ASSERT_RECOVER, m_image, m_nodes, m_referenceColorSpace, m_referenceResX, m_referenceResY, KisPaintDevice::moveTo(), nodes(), KisPaintDevice::offset(), KisImage::projection(), KisImage::refreshGraphAsync(), KisLayerUtils::refreshHiddenAreaAsync(), KoColorSpaceRegistry::rgb8(), KisNodeFacade::root, KisNode::setImage(), KisImage::setResolution(), KisBaseNode::setX(), KisBaseNode::setY(), KisImage::waitForDone(), KisBaseNode::x(), and KisBaseNode::y().
| KisImageSP KisMimeData::clipImageFromKritaLayers | ( | const KoColorSpace * | cs | ) | const |
Definition at line 267 of file kis_mimedata.cpp.
References KisNodeFacade::addNode(), clipFromKritaLayersImpl(), KisPaintDevice::colorSpace(), m_referenceRect, m_referenceResX, m_referenceResY, OPACITY_OPAQUE_U8, and KisImage::setResolution().
| void KisMimeData::deepCopyNodes | ( | ) |
For Cut/Copy/Paste operations we should detach the contents of the mime data from the actual image because the user can modify our image between the Copy/Cut and Paste calls. So we just copy all our nodes into the internal array.
It also fixes the problem of Cutting group layers. If we don't copy the node and all its children, it'll be deleted by the Cut operation and we will not be able to paste it correctly later.
Definition at line 111 of file kis_mimedata.cpp.
References m_image, m_nodes, and KisNode::setImage().
|
static |
Conversion options for mime clips when they are pasted into clipboard or fetched from clipboard (with user selecting "display" space)
On unmanaged compositors they should coincide with the space of the display. On managed ones they should be set to the default color space, e.g. sRGB.
When the surface is managed, we just put the data in sRGB mode, because the compositor expects untagged data to be sRGB.
Definition at line 85 of file kis_mimedata.cpp.
References KisDisplayConfig::conversionFlags, KisConfig::displayProfile(), KisPortingUtils::getScreenNumberForWidget(), KoColorSpaceRegistry::instance(), KisPlatformPluginInterfaceFactory::instance(), KisOpenGLModeProber::instance(), KisDisplayConfig::intent, KoColorConversionTransformation::internalConversionFlags(), KoColorConversionTransformation::internalRenderingIntent(), KisDisplayConfig::isHDR, KIS_SAFE_ASSERT_RECOVER, KoColorSpaceRegistry::p709SRGBProfile(), and KisDisplayConfig::profile.
|
override |
KisMimeData provides the following formats if a node has been set:
Definition at line 143 of file kis_mimedata.cpp.
References m_nodes.
|
staticprivate |
Definition at line 371 of file kis_mimedata.cpp.
References qFuzzyCompare(), KoShape::setTransformation(), KoShape::transformation(), KisImage::xRes(), and KisImage::yRes().
|
static |
We have the node juggler running, so it will delay the update of the generator layers that might be included into the paste. To avoid that we should forcefully to make it stop
Definition at line 623 of file kis_mimedata.cpp.
References KisNodeInsertionAdapter::addNodes(), KisProcessingApplicator::applyCommand(), KisImage::bounds(), correctNewNodeLocation(), KisSharedPtr< T >::data(), KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, loadNodesFast(), KisNodeInsertionAdapter::moveNodes(), KisNodeDummy::node(), nodes(), KisBaseNode::projection(), KisLayerUtils::recursiveApplyNodes(), KisImage::requestStrokeEnd(), KisBaseNode::setX(), KisBaseNode::setY(), KisBaseNode::x(), and KisBaseNode::y().
|
static |
|
static |
Don't try to move a node originating from another image, just copy it.
Definition at line 582 of file kis_mimedata.cpp.
References loadNonNativeNodes(), nodes(), and tryLoadInternalNodes().
|
static |
Definition at line 608 of file kis_mimedata.cpp.
References KisBaseNode::exactBounds(), loadNodesFast(), nodes(), KisBaseNode::setX(), KisBaseNode::setY(), KisBaseNode::x(), and KisBaseNode::y().
|
staticprivate |
Loads a node from a mime container Supports image and color types.
Definition at line 466 of file kis_mimedata.cpp.
References KisImage::bounds(), KisSwatch::color(), KisPaintDevice::convertFromQImage(), KisWeakSharedPtr< T >::data(), KisPaintDevice::exactBounds(), KisBaseProcessor::factoryConfiguration(), KisSwatch::fromByteArray(), KisImage::globalSelection(), KisGeneratorRegistry::instance(), KoColorSpaceRegistry::instance(), KisGlobalResourcesInterface::instance(), KisImage::nextLayerName(), nodes(), OPACITY_OPAQUE_U8, KisBaseNode::projection(), KisBaseNode::setX(), KisBaseNode::setY(), KoColor::toQColor(), and KoGenericRegistry< T >::value().
|
static |
Definition at line 520 of file kis_mimedata.cpp.
References KisMimeData(), nodes(), KisNodeFacade::root, and KisLayerUtils::sortMergeableNodes().
|
static |
Definition at line 531 of file kis_mimedata.cpp.
References deepCopyNodes(), KisMimeData(), nodes(), KisNodeFacade::root, and KisLayerUtils::sortMergeableNodes().
return the node set on this mimedata object – for internal use
Definition at line 133 of file kis_mimedata.cpp.
References m_nodes.
| const KoColorSpace * KisMimeData::referenceColorSpace | ( | ) | const |
If mime data contains Krita layers, then referenceColorSpace() will return the color space associated with those layers.
NOTE: this color space may be not the color space the layers are written in. Usually, it is the color space of the image that contained the layers.
Definition at line 138 of file kis_mimedata.cpp.
References m_referenceColorSpace.
|
overrideprotected |
HACK ALERT:
Sometimes Qt requests the data after destruction of Krita, we cannot load the nodes in that case, because we need signals and timers. So we just skip serializing.
In Krita, when adding an image to the clipboard (via "application/x-qt-image"), we always add alpha channel. We need to notify Qt about that separately, to make sure Qt does not request "application/x-qt-image" to build the entire QImage every time we add something to clipboard.
[Windows-only] If we don't do that, for biggger imaged Krita may hang up for 500-800ms every time we create a mime data, i.e. press Ctrl+C or start D&D operation.
NOTE: this mime type is a custom type that we patch into our version of Qt, it is not present upstream!
Definition at line 291 of file kis_mimedata.cpp.
References KisImage::bounds(), KisDisplayConfig::conversionFlags, KisPaintDevice::convertToQImage(), KisSharedPtr< T >::data(), KisPart::instance(), KisDisplayConfig::intent, KisDisplayConfig::profile, KisImage::projection(), KisImage::xRes(), and KisImage::yRes().
|
staticprivate |
Try load the node, which belongs to the same Krita instance, that is can be fetched without serialization
Definition at line 395 of file kis_mimedata.cpp.
References KisLayerUtils::addCopyOfNameTag(), initializeExternalNode(), m_forceCopy, m_image, MimeFromDragAndDrop, and nodes().
|
private |
Definition at line 160 of file kis_mimedata.h.
|
private |
Definition at line 161 of file kis_mimedata.h.
Definition at line 159 of file kis_mimedata.h.
|
private |
Definition at line 165 of file kis_mimedata.h.
|
private |
Definition at line 162 of file kis_mimedata.h.
|
private |
Definition at line 163 of file kis_mimedata.h.
|
private |
Definition at line 164 of file kis_mimedata.h.