|
Krita Source Code Documentation
|
#include <KoDocumentResourceManager.h>
Inheritance diagram for KoDocumentResourceManager:Public Types | |
| enum | DocumentResource { UndoStack , OdfDocument , GrabSensitivity , MarkerCollection , DocumentResolution , DocumentRectInPixels , KarbonStart = 1000 , KexiStart = 2000 , FlowStart = 3000 , PlanStart = 4000 , StageStart = 5000 , KritaStart = 6000 , SheetsStart = 7000 , WordsStart = 8000 , KoPageAppStart = 9000 , KoTextStart = 10000 } |
Signals | |
| void | resourceChanged (int key, const QVariant &value) |
Public Member Functions | |
| bool | boolResource (int key) const |
| void | clearResource (int key) |
| QRectF | documentRectInPixels () const |
| qreal | documentResolution () const |
| int | grabSensitivity () const |
| Returns the actual grab sensitivity. | |
| bool | hasResource (int key) const |
| int | intResource (int key) const |
| KoColor | koColorResource (int key) const |
| KoDocumentResourceManager (QObject *parent=0) | |
| KoShape * | koShapeResource (int key) const |
| QVariant | resource (int key) const |
| void | setGrabSensitivity (int grabSensitivity) |
| void | setResource (int key, const KoColor &color) |
| void | setResource (int key, const KoUnit &unit) |
| void | setResource (int key, const QVariant &value) |
| void | setResource (int key, KoShape *shape) |
| void | setUndoStack (KUndo2Stack *undoStack) |
| QSizeF | sizeResource (int key) const |
| QString | stringResource (int key) const |
| KUndo2Stack * | undoStack () const |
| KoUnit | unitResource (int key) const |
| ~KoDocumentResourceManager () override | |
Public Attributes | |
| KoResourceManager | manager |
Private Member Functions | |
| KoDocumentResourceManager (const KoDocumentResourceManager &) | |
| KoDocumentResourceManager & | operator= (const KoDocumentResourceManager &) |
Private Member Functions inherited from Private | |
| Private (KisCanvas2 *c) | |
Private Attributes | |
| Private *const | d |
Private Attributes inherited from Private | |
| KisCanvas2 * | canvas |
| int | displayedFrame |
| int | intendedFrame |
The KoResourceManager contains a set of per-canvas or per-document properties, like current foreground color, current background color and more. All tools belonging to the current canvas are notified when a Resource changes (is set).
The properties come from the KoDocumentResourceManager::DocumentResource See KoShapeController::resourceManager
The manager can contain all sorts of variable types and there are accessors for the most common ones. All variables are always stored inside a QVariant instance internally and you can always just use the resource() method to get that directly. The way to store arbitrary data objects that are stored as pointers you can use the following code snippets;
Definition at line 19 of file KoDocumentResourceManager.cpp.
This enum holds identifiers to the resources that can be stored in here.
| Enumerator | |
|---|---|
| UndoStack | The document-wide undo stack (KUndo2Stack) |
| OdfDocument | OBSOLETE The document this canvas shows. |
| GrabSensitivity | The grab sensitivity used for grabbing handles of any kind. |
| MarkerCollection | The collection holding all markers. |
| DocumentResolution | Pixels-per-inch resolution of the document. |
| DocumentRectInPixels | Bounds of the document in pixels. |
| KarbonStart | Base number for Karbon specific values. |
| KexiStart | Base number for Kexi specific values. |
| FlowStart | Base number for Flow specific values. |
| PlanStart | Base number for Plan specific values. |
| StageStart | Base number for Stage specific values. |
| KritaStart | Base number for Krita specific values. |
| SheetsStart | Base number for Sheets specific values. |
| WordsStart | Base number for Words specific values. |
| KoPageAppStart | Base number for KoPageApp specific values. |
| KoTextStart | Base number for KoText specific values. |
Definition at line 57 of file KoDocumentResourceManager.h.
|
explicit |
Constructor.
| parent | the parent QObject, used for memory management. |
Definition at line 25 of file KoDocumentResourceManager.cpp.
References connect(), d, resourceChanged(), and KoResourceManager::resourceChanged().
|
override |
|
private |
| bool KoDocumentResourceManager::boolResource | ( | int | key | ) | const |
Return the resource determined by param key as a boolean.
| key | the identifying key for the resource |
Definition at line 75 of file KoDocumentResourceManager.cpp.
References d.
| void KoDocumentResourceManager::clearResource | ( | int | key | ) |
Remove the resource with key from the provider.
| key | the key that will be used to remove the resource There will be a signal emitted with a variable that will return true on QVariable::isNull(); |
Definition at line 100 of file KoDocumentResourceManager.cpp.
References d.
| QRectF KoDocumentResourceManager::documentRectInPixels | ( | ) | const |
Definition at line 140 of file KoDocumentResourceManager.cpp.
References DocumentRectInPixels, hasResource(), KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, and resource().
| qreal KoDocumentResourceManager::documentResolution | ( | ) | const |
Definition at line 134 of file KoDocumentResourceManager.cpp.
References DocumentResolution, hasResource(), KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE, and resource().
| int KoDocumentResourceManager::grabSensitivity | ( | ) | const |
Returns the actual grab sensitivity.
Definition at line 120 of file KoDocumentResourceManager.cpp.
References GrabSensitivity, hasResource(), and intResource().
| bool KoDocumentResourceManager::hasResource | ( | int | key | ) | const |
Returns true if there is a resource set with the requested key.
| key | the identifying key for the resource |
Definition at line 95 of file KoDocumentResourceManager.cpp.
References d.
| int KoDocumentResourceManager::intResource | ( | int | key | ) | const |
Return the resource determined by param key as an integer.
| key | the identifying key for the resource |
Definition at line 80 of file KoDocumentResourceManager.cpp.
References d.
| KoColor KoDocumentResourceManager::koColorResource | ( | int | key | ) | const |
Return the resource determined by param key as a KoColor.
| key | the identifying key for the resource |
Definition at line 69 of file KoDocumentResourceManager.cpp.
References d.
| KoShape * KoDocumentResourceManager::koShapeResource | ( | int | key | ) | const |
Return the resource determined by param key as a pointer to a KoShape.
| key | the identifying key for the resource |
|
private |
| QVariant KoDocumentResourceManager::resource | ( | int | key | ) | const |
Returns a qvariant containing the specified resource or a standard one if the specified resource does not exist.
| key | the key |
Definition at line 43 of file KoDocumentResourceManager.cpp.
References d.
|
signal |
This signal is emitted every time a resource is set that is either new or different from the previous set value.
| key | the identifying key for the resource |
| value | the variants new value. |
| void KoDocumentResourceManager::setGrabSensitivity | ( | int | grabSensitivity | ) |
Tools that are used to grab handles or similar with the mouse should use this value to determine if the mouse is near enough
| grabSensitivity | the grab sensitivity in pixels |
Definition at line 112 of file KoDocumentResourceManager.cpp.
References GrabSensitivity, grabSensitivity(), and setResource().
Set a resource of type KoColor.
| key | the integer key |
| color | the new value for the key. |
Definition at line 48 of file KoDocumentResourceManager.cpp.
References setResource(), and v.
Set a resource of type KoUnit
| key | the integer key |
| id | the new value for the key. |
Definition at line 62 of file KoDocumentResourceManager.cpp.
References setResource(), and v.
| void KoDocumentResourceManager::setResource | ( | int | key, |
| const QVariant & | value ) |
Set a resource of any type.
| key | the integer key |
| value | the new value for the key. |
Definition at line 38 of file KoDocumentResourceManager.cpp.
Set a resource of type KoShape*.
| key | the integer key |
| id | the new value for the key. |
Definition at line 55 of file KoDocumentResourceManager.cpp.
References setResource(), and v.
| void KoDocumentResourceManager::setUndoStack | ( | KUndo2Stack * | undoStack | ) |
Definition at line 127 of file KoDocumentResourceManager.cpp.
References setResource(), and undoStack().
| QSizeF KoDocumentResourceManager::sizeResource | ( | int | key | ) | const |
Return the resource determined by param key as a QSizeF.
| key | the identifying key for the resource |
Definition at line 90 of file KoDocumentResourceManager.cpp.
References d.
| QString KoDocumentResourceManager::stringResource | ( | int | key | ) | const |
Return the resource determined by param key as a QString .
| key | the identifying key for the resource |
Definition at line 85 of file KoDocumentResourceManager.cpp.
References d.
| KUndo2Stack * KoDocumentResourceManager::undoStack | ( | ) | const |
Definition at line 105 of file KoDocumentResourceManager.cpp.
References hasResource(), and resource().
| KoUnit KoDocumentResourceManager::unitResource | ( | int | key | ) | const |
Return the resource determined by param key as a KoUnit.
| key | the identifying key for the resource |
|
private |
Definition at line 221 of file KoDocumentResourceManager.h.
| KoResourceManager KoDocumentResourceManager::manager |
Definition at line 22 of file KoDocumentResourceManager.cpp.