|
Krita Source Code Documentation
|
#include <kis_clipboard.h>
Inheritance diagram for KisClipboard:Public Types | |
| enum | PasteBehaviour { PASTE_ASSUME_WEB = 0 , PASTE_ASSUME_MONITOR , PASTE_ASK } |
| enum | PasteFormatBehaviour { PASTE_FORMAT_ASK = 0 , PASTE_FORMAT_DOWNLOAD , PASTE_FORMAT_LOCAL , PASTE_FORMAT_CLIP } |
Signals | |
| void | clipChanged () |
Public Member Functions | |
| QPair< bool, PasteFormatBehaviour > | askUserForSource (const QMimeData *data, bool useClipboardFallback=false) const |
| QPair< bool, PasteFormatBehaviour > | askUserForSourceWithData (QImage qimage, const QList< QUrl > urls, bool useClipboardFallback=false) const |
| KisPaintDeviceSP | clip (KisDefaultBoundsBaseSP defaultBounds, bool showPopup, int overridePasteBehaviour=-1) const |
| KisImageSP | clipFromBoardContentsWithData (QImage image, const QList< QUrl > urls, bool showPopup, int overridePasteBehaviour=-1, QPair< bool, PasteFormatBehaviour > source={false, PasteFormatBehaviour::PASTE_FORMAT_ASK}) const |
| KisPaintDeviceSP | clipFromKritaLayers (const KoColorSpace *cs, KisDefaultBoundsBaseSP defaultBounds) const |
| KisImageSP | clipImage (bool showPopup, int overridePasteBehaviour=-1) const |
| KisImageSP | clipImageFromBoardContents (bool showPopup, int overridePasteBehaviour, QPair< bool, PasteFormatBehaviour > source={false, PasteFormatBehaviour::PASTE_FORMAT_ASK}) const |
| KisImageSP | clipImageFromKritaLayers (const KoColorSpace *cs=nullptr) const |
| KisImageSP | fetchImageByURL (const QUrl &originalUrl) const |
| QImage | getImageWithFallback (const QMimeData *cbData, bool useClipboardFallback=false) const |
| bool | hasClip () const |
| bool | hasImage () const |
| bool | hasLayers () const |
| bool | hasLayerStyles () const |
| bool | hasUrls () const |
| KisClipboard () | |
| const QMimeData * | layersMimeData () const |
| const KoColorSpace * | referenceColorSpace () const |
| void | setLayers (KisNodeList nodes, KisImageSP image, const QRect referenceRect, bool forceCopy=false) |
| ~KisClipboard () override | |
Static Public Member Functions | |
| static KisClipboard * | instance () |
Properties | |
| bool | clip |
Private Slots | |
| void | clipboardDataChanged () |
Private Member Functions | |
| QImage | getImageFromMimeData (const QMimeData *cbData) const |
| Q_DISABLE_COPY (KisClipboard) | |
Private Attributes | |
| KisClipboardPrivate *const | d |
The Krita clipboard is a clipboard that can store paint devices instead of just qimage's.
Definition at line 34 of file kis_clipboard.h.
| Enumerator | |
|---|---|
| PASTE_ASSUME_WEB | |
| PASTE_ASSUME_MONITOR | |
| PASTE_ASK | |
Definition at line 41 of file kis_clipboard.h.
| Enumerator | |
|---|---|
| PASTE_FORMAT_ASK | |
| PASTE_FORMAT_DOWNLOAD | |
| PASTE_FORMAT_LOCAL | |
| PASTE_FORMAT_CLIP | |
Definition at line 43 of file kis_clipboard.h.
| KisClipboard::KisClipboard | ( | ) |
Definition at line 71 of file kis_clipboard.cc.
References KisClipboardPrivate::clipboard, clipboardDataChanged(), and d.
|
override |
| QPair< bool, KisClipboard::PasteFormatBehaviour > KisClipboard::askUserForSource | ( | const QMimeData * | data, |
| bool | useClipboardFallback = false ) const |
Given the mimedata for a paste event, ask user which source they'll want to use for the image.
Definition at line 184 of file kis_clipboard.cc.
References askUserForSourceWithData(), getImageWithFallback(), and PASTE_FORMAT_ASK.
| QPair< bool, KisClipboard::PasteFormatBehaviour > KisClipboard::askUserForSourceWithData | ( | QImage | qimage, |
| const QList< QUrl > | urls, | ||
| bool | useClipboardFallback = false ) const |
Definition at line 196 of file kis_clipboard.cc.
References dbgUI, PASTE_FORMAT_ASK, PASTE_FORMAT_CLIP, PASTE_FORMAT_DOWNLOAD, PASTE_FORMAT_LOCAL, KisConfig::pasteFormat(), KisDlgPasteFormat::remember(), KisConfig::setPasteFormat(), KisDlgPasteFormat::setSourceAvailable(), and KisDlgPasteFormat::source().
| KisPaintDeviceSP KisClipboard::clip | ( | KisDefaultBoundsBaseSP | defaultBounds, |
| bool | showPopup, | ||
| int | overridePasteBehaviour = -1 ) const |
Get the contents of the clipboard in the form of a paint device.
If the paint device originates from Krita itself, it may have non-transparent default pixel and hence infinite visual extent. To handle the case properly, the caller must provide a valid defaultBounds object, which will make the infinite clip to limit itself inside the bounds of the relevant image.
Definition at line 92 of file kis_clipboard.cc.
References clip, KisClipboardPrivate::clipboard, clipFromKritaLayers(), clipImage(), clipImageFromBoardContents(), d, dbgUI, and KisImage::projection().
|
privateslot |
Definition at line 359 of file kis_clipboard.cc.
References KisClipboardPrivate::clipboard, clipChanged(), d, KisClipboardPrivate::hasClip, KisClipboardPrivate::referenceColorSpace, and KisMimeData::referenceColorSpace().
|
signal |
| KisImageSP KisClipboard::clipFromBoardContentsWithData | ( | QImage | image, |
| const QList< QUrl > | urls, | ||
| bool | showPopup, | ||
| int | overridePasteBehaviour = -1, | ||
| QPair< bool, PasteFormatBehaviour > | source = {false, PasteFormatBehaviour::PASTE_FORMAT_ASK} ) const |
Definition at line 270 of file kis_clipboard.cc.
References KisNodeFacade::addNode(), askUserForSourceWithData(), clipImage(), KisPaintDevice::convertFromQImage(), KisMimeData::displayConfigForMimePastes(), fetchImageByURL(), KoColorSpaceRegistry::instance(), KIS_SAFE_ASSERT_RECOVER, OPACITY_OPAQUE_U8, KisPaintLayer::paintDevice, PASTE_ASK, PASTE_ASSUME_MONITOR, PASTE_FORMAT_ASK, PASTE_FORMAT_CLIP, PASTE_FORMAT_LOCAL, KisConfig::pasteBehaviour(), KoColorSpace::profile(), KisDisplayConfig::profile, KisDlgMissingColorProfile::remember(), KoColorSpaceRegistry::rgb8(), KisConfig::setPasteBehaviour(), KisImage::setResolution(), KisDlgMissingColorProfile::source(), source(), and warnKrita.
| KisPaintDeviceSP KisClipboard::clipFromKritaLayers | ( | const KoColorSpace * | cs, |
| KisDefaultBoundsBaseSP | defaultBounds ) const |
Definition at line 157 of file kis_clipboard.cc.
References KisMimeData::clipFromKritaLayers(), instance(), and layersMimeData().
| KisImageSP KisClipboard::clipImage | ( | bool | showPopup, |
| int | overridePasteBehaviour = -1 ) const |
Get the contents of the clipboard in a form of a bounded image. To get the contents of the image just use the normal image->projection() device.
The origin of the "clip" is always placed at point (0,0) of the image. The size of the image equals to the size of the original "clip"
The meaning of the "clip size" depends on where the clip comes from:
when pasted from a URL, the size of the image also equals the size of the image in the file.
There is small complication though: if the source file is .kra, then image->projection() may have non-transparent default pixel. The caller should be ready to handle that by either keeping the parent KisImage alive all the time or by setting his own defaultBounds object on it.
Definition at line 120 of file kis_clipboard.cc.
References KisClipboardPrivate::clipboard, clipImage(), clipImageFromBoardContents(), clipImageFromKritaLayers(), d, and dbgUI.
| KisImageSP KisClipboard::clipImageFromBoardContents | ( | bool | showPopup, |
| int | overridePasteBehaviour, | ||
| QPair< bool, PasteFormatBehaviour > | source = {false, PasteFormatBehaviour::PASTE_FORMAT_ASK} ) const |
Definition at line 142 of file kis_clipboard.cc.
References KisClipboardPrivate::clipboard, clipFromBoardContentsWithData(), d, getImageWithFallback(), and source().
| KisImageSP KisClipboard::clipImageFromKritaLayers | ( | const KoColorSpace * | cs = nullptr | ) | const |
Definition at line 170 of file kis_clipboard.cc.
References KisMimeData::clipImageFromKritaLayers(), instance(), and layersMimeData().
| KisImageSP KisClipboard::fetchImageByURL | ( | const QUrl & | originalUrl | ) | const |
Definition at line 476 of file kis_clipboard.cc.
References KisNodeFacade::addNode(), clipImage(), KisDocument::DontAddToRecent, KisImportExportErrorCode::errorMessage(), KisRemoteFileFetcher::fetchFile(), ImportExportCodes::FileFormatNotSupported, KisLayerUtils::forceAllDelayedNodesUpdate(), KisImportExportManager::Import, KisPart::instance(), KisMimeDatabase::mimeTypeForFile(), OPACITY_OPAQUE_U8, KisImage::setResolution(), and KisImportExportManager::supportedMimeTypes().
|
private |
Definition at line 438 of file kis_clipboard.cc.
References ClipboardImageFormat::format, and ClipboardImageFormat::mimeTypes.
| QImage KisClipboard::getImageWithFallback | ( | const QMimeData * | cbData, |
| bool | useClipboardFallback = false ) const |
Definition at line 373 of file kis_clipboard.cc.
References KisClipboardPrivate::clipboard, d, and getImageFromMimeData().
| bool KisClipboard::hasClip | ( | ) | const |
Definition at line 384 of file kis_clipboard.cc.
References d, and KisClipboardPrivate::hasClip.
| bool KisClipboard::hasImage | ( | ) | const |
Definition at line 433 of file kis_clipboard.cc.
References KisClipboardPrivate::clipboard, and d.
| bool KisClipboard::hasLayers | ( | ) | const |
Definition at line 406 of file kis_clipboard.cc.
References KisClipboardPrivate::clipboard, and d.
| bool KisClipboard::hasLayerStyles | ( | ) | const |
Definition at line 412 of file kis_clipboard.cc.
References KisClipboardPrivate::clipboard, and d.
| bool KisClipboard::hasUrls | ( | ) | const |
Definition at line 427 of file kis_clipboard.cc.
References KisClipboardPrivate::clipboard, and d.
|
static |
Definition at line 87 of file kis_clipboard.cc.
| const QMimeData * KisClipboard::layersMimeData | ( | ) | const |
Definition at line 421 of file kis_clipboard.cc.
References KisClipboardPrivate::clipboard, and d.
|
private |
| const KoColorSpace * KisClipboard::referenceColorSpace | ( | ) | const |
Definition at line 389 of file kis_clipboard.cc.
References d, and KisClipboardPrivate::referenceColorSpace.
| void KisClipboard::setLayers | ( | KisNodeList | nodes, |
| KisImageSP | image, | ||
| const QRect | referenceRect, | ||
| bool | forceCopy = false ) |
See a comment in KisMimeData::deepCopyNodes()
Definition at line 394 of file kis_clipboard.cc.
References KisClipboardPrivate::clipboard, d, and KisMimeData::mimeForLayersDeepCopy().
|
private |
Definition at line 153 of file kis_clipboard.h.
|
read |
Definition at line 38 of file kis_clipboard.h.