Krita Source Code Documentation
Loading...
Searching...
No Matches
Krita Class Reference

#include <Krita.h>

+ Inheritance diagram for Krita:

Public Slots

QAction * action (const QString &name) const
 
QList< QAction * > actions () const
 
DocumentactiveDocument () const
 
WindowactiveWindow () const
 
void addDockWidgetFactory (DockWidgetFactoryBase *factory)
 addDockWidgetFactory Add the given docker factory to the application. For scripts loaded on startup, this means that every window will have one of the dockers created by the factory.
 
void addExtension (Extension *extension)
 addExtension add the given plugin to Krita. There will be a single instance of each Extension in the Krita process.
 
bool addProfile (const QString &profilePath)
 addProfile load the given profile into the profile registry.
 
bool batchmode () const
 batchmode determines whether the script is run in batch mode. If batchmode is true, scripts should now show messageboxes or dialog boxes.
 
QStringList colorDepths (const QString &colorModel) const
 colorDepths creates a list with the names of all color depths compatible with the given color model.
 
QStringList colorModels () const
 colorModels creates a list with all color models id's registered.
 
DocumentcreateDocument (int width, int height, const QString &name, const QString &colorModel, const QString &colorDepth, const QString &profile, double resolution)
 
QList< QDockWidget * > dockers () const
 
QList< Document * > documents () const
 
QList< Extension * > extensions ()
 
Filterfilter (const QString &name) const
 filter construct a Filter object with a default configuration.
 
QStringList filters () const
 Filters are identified by an internal name. This function returns a list of all existing registered filters.
 
QStringList filterStrategies () const
 filterStrategies Retrieves all installed filter strategies. A filter strategy is used when transforming (scaling, shearing, rotating) an image to calculate the value of the new pixels. You can use th
 
static QObject * fromVariant (const QVariant &v)
 
static QString getAppDataLocation ()
 
QIcon icon (QString &iconName) const
 icon This allows you to get icons from Krita's internal icons.
 
static Kritainstance ()
 instance retrieve the singleton instance of the Application object.
 
static QString krita_i18n (const QString &text)
 
static QString krita_i18nc (const QString &context, const QString &text)
 
Notifiernotifier () const
 notifier the Notifier singleton emits signals when documents are opened and closed, the configuration changes, views are opened and closed or windows are opened.
 
DocumentopenDocument (const QString &filename)
 openDocument creates a new Document, registers it with the Krita application and loads the given file.
 
WindowopenWindow ()
 openWindow create a new main window. The window is not shown by default.
 
QStringList profiles (const QString &colorModel, const QString &colorDepth) const
 profiles creates a list with the names of all color profiles compatible with the given color model and color depth.
 
QString readSetting (const QString &group, const QString &name, const QString &defaultValue)
 readSetting read the given setting value from the kritarc file.
 
QStringList recentDocuments () const
 return all recent documents registered in the RecentFiles group of the kritarc
 
QMap< QString, Resource * > resources (QString &type) const
 resources returns a list of Resource objects of the given type
 
void setActiveDocument (Document *value)
 setActiveDocument activates the first view that shows the given document
 
void setBatchmode (bool value)
 setBatchmode sets the batchmode to
 
QString version () const
 version Determine the version of Krita
 
QList< View * > views () const
 
QList< Window * > windows () const
 
void writeSetting (const QString &group, const QString &name, const QString &value)
 writeSetting write the given setting under the given name to the kritarc file in the given settings group.
 

Public Member Functions

 Krita (QObject *parent=0)
 
 ~Krita () override
 

Private Slots

void mainWindowIsBeingCreated (KisMainWindow *window)
 This is called from the constructor of the window, before the xmlgui file is loaded.
 

Private Attributes

Private *const d
 

Static Private Attributes

static Kritas_instance = 0
 

Detailed Description

Krita is a singleton class that offers the root access to the Krita object hierarchy.

The Krita.instance() is aliased as two builtins: Scripter and Application.

Definition at line 27 of file Krita.h.

Constructor & Destructor Documentation

◆ Krita()

Krita::Krita ( QObject * parent = 0)
explicit

Definition at line 68 of file Krita.cpp.

69 : QObject(parent)
70 , d(new Private)
71{
72 qRegisterMetaType<Notifier*>();
73 connect(KisPart::instance(), SIGNAL(sigMainWindowIsBeingCreated(KisMainWindow*)), SLOT(mainWindowIsBeingCreated(KisMainWindow*)));
74}
connect(this, SIGNAL(optionsChanged()), this, SLOT(saveOptions()))
Main window for Krita.
static KisPart * instance()
Definition KisPart.cpp:131
void mainWindowIsBeingCreated(KisMainWindow *window)
This is called from the constructor of the window, before the xmlgui file is loaded.
Definition Krita.cpp:438
Private *const d
Definition Krita.h:337

References connect(), KisPart::instance(), and mainWindowIsBeingCreated().

◆ ~Krita()

Krita::~Krita ( )
override

Definition at line 76 of file Krita.cpp.

77{
78 qDeleteAll(d->extensions);
79 delete d->notifier;
80 delete d;
81}
QList< Extension * > extensions
Definition Krita.cpp:63
Notifier * notifier
Definition Krita.cpp:65

References d, krita::Krita::Private::extensions, and krita::Krita::Private::notifier.

Member Function Documentation

◆ action

QAction * Krita::action ( const QString & name) const
slot
Returns
the action that has been registered under the given name, or 0 if no such action exists.

Definition at line 93 of file Krita.cpp.

94{
96 if (!mainWindow) {
97 return 0;
98 }
99 KisKActionCollection *actionCollection = mainWindow->actionCollection();
100 QAction *action = actionCollection->action(name);
101 return action;
102}
A container for a set of QAction objects.
QAction * action(int index) const
virtual KisKActionCollection * actionCollection() const
KisMainWindow * currentMainwindow() const
Definition KisPart.cpp:483
QAction * action(const QString &name) const
Definition Krita.cpp:93

References action(), KisKActionCollection::action(), KisKXMLGUIClient::actionCollection(), KisPart::currentMainwindow(), and KisPart::instance().

◆ actions

QList< QAction * > Krita::actions ( ) const
slot
Returns
return a list of all actions for the currently active mainWindow.

Definition at line 83 of file Krita.cpp.

84{
86 if (!mainWindow) {
87 return QList<QAction*>();
88 }
89 KisKActionCollection *actionCollection = mainWindow->actionCollection();
90 return actionCollection->actions();
91}
QList< QAction * > actions() const

References KisKXMLGUIClient::actionCollection(), KisKActionCollection::actions(), KisPart::currentMainwindow(), and KisPart::instance().

◆ activeDocument

Document * Krita::activeDocument ( ) const
slot
Returns
the currently active document, if there is one.

Definition at line 104 of file Krita.cpp.

105{
107 if (!mainWindow) {
108 return 0;
109 }
110 KisView *view = mainWindow->activeView();
111 if (!view) {
112 return 0;
113 }
114 KisDocument *document = view->document();
115 Document *d = new Document(document, false);
116 return d;
117}
QPointer< KisView > activeView
QPointer< KisDocument > document
Definition KisView.cpp:121

References KisMainWindow::activeView, KisPart::currentMainwindow(), d, KisView::document, and KisPart::instance().

◆ activeWindow

Window * Krita::activeWindow ( ) const
slot
Returns
the currently active window or None if there is no window

Definition at line 233 of file Krita.cpp.

234{
236 if (!mainWindow) {
237 return 0;
238 }
239 return new Window(mainWindow);
240}

References KisPart::currentMainwindow(), and KisPart::instance().

◆ addDockWidgetFactory

void Krita::addDockWidgetFactory ( DockWidgetFactoryBase * factory)
slot

addDockWidgetFactory Add the given docker factory to the application. For scripts loaded on startup, this means that every window will have one of the dockers created by the factory.

Parameters
factoryThe factory object.

Definition at line 385 of file Krita.cpp.

386{
387 KoDockRegistry::instance()->add(factory);
388}
static KoDockRegistry * instance()

References KoGenericRegistry< T >::add(), and KoDockRegistry::instance().

◆ addExtension

void Krita::addExtension ( Extension * extension)
slot

addExtension add the given plugin to Krita. There will be a single instance of each Extension in the Krita process.

Parameters
extensionthe extension to add.

Definition at line 358 of file Krita.cpp.

359{
360 d->extensions.append(extension);
361}

References d, and krita::Krita::Private::extensions.

◆ addProfile

bool Krita::addProfile ( const QString & profilePath)
slot

addProfile load the given profile into the profile registry.

Parameters
profilePaththe path to the profile.
Returns
true if adding the profile succeeded.

Definition at line 207 of file Krita.cpp.

208{
210 KIS_ASSERT(iccEngine);
211 return iccEngine->addProfile(profilePath);
212}
static KoColorSpaceEngineRegistry * instance()
T get(const QString &id) const
#define KIS_ASSERT(cond)
Definition kis_assert.h:33
virtual const KoColorProfile * addProfile(const QString &filename)=0

References KoColorSpaceEngine::addProfile(), KoGenericRegistry< T >::get(), KoColorSpaceEngineRegistry::instance(), and KIS_ASSERT.

◆ batchmode

bool Krita::batchmode ( ) const
slot

batchmode determines whether the script is run in batch mode. If batchmode is true, scripts should now show messageboxes or dialog boxes.

Note that this separate from Document.setBatchmode(), which determines whether export/save option dialogs are shown.

Returns
true if the script is run in batchmode

Definition at line 129 of file Krita.cpp.

130{
131 return d->batchMode;
132}

References krita::Krita::Private::batchMode, and d.

◆ colorDepths

QStringList Krita::colorDepths ( const QString & colorModel) const
slot

colorDepths creates a list with the names of all color depths compatible with the given color model.

Parameters
colorModelthe id of a color model.
Returns
a list of all color depths or a empty list if there is no such color depths.

Definition at line 179 of file Krita.cpp.

180{
181 QSet<QString> colorDepthsIds;
183 Q_FOREACH(KoID id, ids) {
184 colorDepthsIds << id.id();
185 }
186 return QStringList(colorDepthsIds.begin(), colorDepthsIds.end());
187}
QList< QString > QStringList
Definition KoID.h:30
QList< KoID > colorDepthList(const KoID &colorModelId, ColorSpaceListVisibility option) const
static KoColorSpaceRegistry * instance()
@ AllColorSpaces
All color space even those not visible to the user.

References KoColorSpaceRegistry::AllColorSpaces, KoColorSpaceRegistry::colorDepthList(), and KoColorSpaceRegistry::instance().

◆ colorModels

QStringList Krita::colorModels ( ) const
slot

colorModels creates a list with all color models id's registered.

Returns
a list of all color models or a empty list if there is no such color models.

Definition at line 169 of file Krita.cpp.

170{
171 QSet<QString> colorModelsIds;
173 Q_FOREACH(KoID id, ids) {
174 colorModelsIds << id.id();
175 }
176 return QStringList(colorModelsIds.begin(), colorModelsIds.end());
177}
QList< KoID > colorModelsList(ColorSpaceListVisibility option) const

References KoColorSpaceRegistry::AllColorSpaces, KoColorSpaceRegistry::colorModelsList(), and KoColorSpaceRegistry::instance().

◆ createDocument

Document * Krita::createDocument ( int width,
int height,
const QString & name,
const QString & colorModel,
const QString & colorDepth,
const QString & profile,
double resolution )
slot
   @brief createDocument creates a new document and image and registers
   the document with the Krita application.

   Unless you explicitly call Document::close() the document will remain
   known to the Krita document registry. The document and its image will
   only be deleted when Krita exits.

   The document will have one transparent layer.

   To create a new document and show it, do something like:
from Krita import *
def add_document_to_window():
d = Application.createDocument(100, 100, "Test", "RGBA", "U8", "", 120.0)
Application.activeWindow().addView(d)
add_document_to_window()
Definition Krita.h:28
Window * activeWindow() const
Definition Krita.cpp:233
View * addView(Document *document)
Definition Window.cpp:82
   @param width the width in pixels
   @param height the height in pixels
   @param name the name of the image (not the filename of the document)
   @param colorModel A string describing the color model of the image:
   <ul>
   <li>A: Alpha mask</li>
   <li>RGBA: RGB with alpha channel (The actual order of channels is most often BGR!)</li>
   <li>XYZA: XYZ with alpha channel</li>
   <li>LABA: LAB with alpha channel</li>
   <li>CMYKA: CMYK with alpha channel</li>
   <li>GRAYA: Gray with alpha channel</li>
   <li>YCbCrA: YCbCr with alpha channel</li>
   </ul>
   @param colorDepth A string describing the color depth of the image:
   <ul>
   <li>U8: unsigned 8 bits integer, the most common type</li>
   <li>U16: unsigned 16 bits integer</li>
   <li>F16: half, 16 bits floating point. Only available if Krita was built with OpenEXR</li>
   <li>F32: 32 bits floating point</li>
   </ul>
   @param profile The name of an icc profile that is known to Krita. If an empty string is passed, the default is
   taken.
   @param resolution the resolution in points per inch.
   @return the created document.

Definition at line 317 of file Krita.cpp.

318{
320 document->setObjectName(name);
321
322 KisPart::instance()->addDocument(document, false);
323 const KoColorSpace *cs = KoColorSpaceRegistry::instance()->colorSpace(colorModel, colorDepth, profile);
324 Q_ASSERT(cs);
325
326 QColor qc(Qt::white);
327 KoColor bgColor(qc, cs);
328
329 if (!document->newImage(name, width, height, cs, bgColor, KisConfig::RASTER_LAYER, 1, "", double(resolution / 72) )) {
330 return 0;
331 }
332
333 Q_ASSERT(document->image());
334 Document *doc = new Document(document, true);
335
336 return doc;
337}
void addDocument(KisDocument *document, bool notify=true)
Definition KisPart.cpp:211
KisDocument * createDocument() const
Definition KisPart.cpp:230
const KoColorSpace * colorSpace(const QString &colorModelId, const QString &colorDepthId, const KoColorProfile *profile)

References KisPart::addDocument(), KoColorSpaceRegistry::colorSpace(), KisPart::createDocument(), KoColorSpaceRegistry::instance(), KisPart::instance(), and KisConfig::RASTER_LAYER.

◆ dockers

QList< QDockWidget * > Krita::dockers ( ) const
slot
Returns
a list of all the dockers

Definition at line 296 of file Krita.cpp.

297{
299
300 if (!mainWindow) return {};
301 return mainWindow->dockWidgets();
302}
QList< QDockWidget * > dockWidgets() const
Return the list of dock widgets belonging to this main window.

References KisPart::currentMainwindow(), KisMainWindow::dockWidgets(), and KisPart::instance().

◆ documents

QList< Document * > Krita::documents ( ) const
slot
Returns
a list of all open Documents

Definition at line 140 of file Krita.cpp.

141{
144 ret << new Document(doc, false);
145 }
146 return ret;
147}
QList< Document * > documents() const
Definition Krita.cpp:140

References documents(), and KisPart::instance().

◆ extensions

QList< Extension * > Krita::extensions ( )
slot

return a list with all registered extension objects.

Definition at line 363 of file Krita.cpp.

364{
365 return d->extensions;
366}

References d, and krita::Krita::Private::extensions.

◆ filter

Filter * Krita::filter ( const QString & name) const
slot

filter construct a Filter object with a default configuration.

Parameters
namethe name of the filter. Use Krita.instance().filters() to get a list of all possible filters.
Returns
the filter or None if there is no such filter.

Definition at line 156 of file Krita.cpp.

157{
158 if (!filters().contains(name)) return 0;
159
160 Filter *filter = new Filter();
161 filter->setName(name);
164 InfoObject *info = new InfoObject(fc);
166 return filter;
167}
void setConfiguration(InfoObject *value)
setConfiguration set the configuration object for the filter
Definition Filter.cpp:80
void setName(const QString &name)
setName set the filter's name to the given name.
Definition Filter.cpp:66
static KisFilterRegistry * instance()
static KisResourcesInterfaceSP instance()
const T value(const QString &id) const
Filter * filter(const QString &name) const
filter construct a Filter object with a default configuration.
Definition Krita.cpp:156
QStringList filters() const
Filters are identified by an internal name. This function returns a list of all existing registered f...
Definition Krita.cpp:149

References filter(), filters(), KisFilterRegistry::instance(), KisGlobalResourcesInterface::instance(), Filter::setConfiguration(), Filter::setName(), and KoGenericRegistry< T >::value().

◆ filters

QStringList Krita::filters ( ) const
slot

Filters are identified by an internal name. This function returns a list of all existing registered filters.

Returns
a list of all registered filters

Definition at line 149 of file Krita.cpp.

150{
152 std::sort(ls.begin(), ls.end());
153 return ls;
154}
QList< QString > keys() const

References KisFilterRegistry::instance(), and KoGenericRegistry< T >::keys().

◆ filterStrategies

QStringList Krita::filterStrategies ( ) const
slot

filterStrategies Retrieves all installed filter strategies. A filter strategy is used when transforming (scaling, shearing, rotating) an image to calculate the value of the new pixels. You can use th

Returns
the id's of all available filters.

Definition at line 189 of file Krita.cpp.

190{
192}
static KisFilterStrategyRegistry * instance()

References KisFilterStrategyRegistry::instance(), and KoGenericRegistry< T >::keys().

◆ fromVariant

QObject * Krita::fromVariant ( const QVariant & v)
staticslot

Scripter.fromVariant(variant) variant is a QVariant returns instance of QObject-subclass

This is a helper method for PyQt because PyQt cannot cast a variant to a QObject or QWidget

Definition at line 406 of file Krita.cpp.

407{
408
409 if (v.canConvert< QWidget* >())
410 {
411 QObject* obj = qvariant_cast< QWidget* >(v);
412 return obj;
413 }
414 else if (v.canConvert< QObject* >())
415 {
416 QObject* obj = qvariant_cast< QObject* >(v);
417 return obj;
418 }
419 else
420 return 0;
421}
qreal v

References v.

◆ getAppDataLocation

QString Krita::getAppDataLocation ( )
staticslot

Definition at line 433 of file Krita.cpp.

434{
436}
static QString getAppDataLocation()

References KoResourcePaths::getAppDataLocation().

◆ icon

QIcon Krita::icon ( QString & iconName) const
slot

icon This allows you to get icons from Krita's internal icons.

Parameters
iconNamename of the icon.
Returns
the icon related to this name.

Definition at line 380 of file Krita.cpp.

381{
382 return KisIconUtils::loadIcon(iconName);
383}
QIcon loadIcon(const QString &name)

References KisIconUtils::loadIcon().

◆ instance

Krita * Krita::instance ( )
staticslot

instance retrieve the singleton instance of the Application object.

Definition at line 390 of file Krita.cpp.

391{
392 if (!s_instance)
393 {
394 s_instance = new Krita;
395 }
396 return s_instance;
397}
static Krita * s_instance
Definition Krita.h:338
Krita(QObject *parent=0)
Definition Krita.cpp:68

References Krita(), and s_instance.

◆ krita_i18n

QString Krita::krita_i18n ( const QString & text)
staticslot

Definition at line 423 of file Krita.cpp.

424{
425 return i18n(text.toUtf8().constData());
426}

◆ krita_i18nc

QString Krita::krita_i18nc ( const QString & context,
const QString & text )
staticslot

Definition at line 428 of file Krita.cpp.

429{
430 return i18nc(context.toUtf8().constData(), text.toUtf8().constData());
431}

◆ mainWindowIsBeingCreated

void Krita::mainWindowIsBeingCreated ( KisMainWindow * window)
privateslot

This is called from the constructor of the window, before the xmlgui file is loaded.

Definition at line 438 of file Krita.cpp.

439{
440 Q_FOREACH(Extension *extension, d->extensions) {
441 Window window(kisWindow);
442 extension->createActions(&window);
443 }
444}

References d, and krita::Krita::Private::extensions.

◆ notifier

Notifier * Krita::notifier ( ) const
slot

notifier the Notifier singleton emits signals when documents are opened and closed, the configuration changes, views are opened and closed or windows are opened.

Returns
the notifier object

Definition at line 214 of file Krita.cpp.

215{
216 return d->notifier;
217}

References d, and krita::Krita::Private::notifier.

◆ openDocument

Document * Krita::openDocument ( const QString & filename)
slot

openDocument creates a new Document, registers it with the Krita application and loads the given file.

Parameters
filenamethe file to open in the document
Returns
the document

Definition at line 339 of file Krita.cpp.

340{
342 document->setFileBatchMode(this->batchmode());
343 if (!document->openPath(filename, KisDocument::DontAddToRecent)) {
344 delete document;
345 return 0;
346 }
347 KisPart::instance()->addDocument(document);
348 document->setFileBatchMode(false);
349 return new Document(document, true);
350}
void setFileBatchMode(const bool batchMode)
bool openPath(const QString &path, OpenFlags flags=None)
openPath Open a Path
bool batchmode() const
batchmode determines whether the script is run in batch mode. If batchmode is true,...
Definition Krita.cpp:129

References KisPart::addDocument(), batchmode(), KisPart::createDocument(), KisDocument::DontAddToRecent, KisPart::instance(), KisDocument::openPath(), and KisDocument::setFileBatchMode().

◆ openWindow

Window * Krita::openWindow ( )
slot

openWindow create a new main window. The window is not shown by default.

Definition at line 352 of file Krita.cpp.

353{
355 return new Window(mw);
356}
KisMainWindow * createMainWindow(QUuid id=QUuid())
Definition KisPart.cpp:260

References KisPart::createMainWindow(), and KisPart::instance().

◆ profiles

QStringList Krita::profiles ( const QString & colorModel,
const QString & colorDepth ) const
slot

profiles creates a list with the names of all color profiles compatible with the given color model and color depth.

Parameters
colorModelA string describing the color model of the image:
  • A: Alpha mask
  • RGBA: RGB with alpha channel (The actual order of channels is most often BGR!)
  • XYZA: XYZ with alpha channel
  • LABA: LAB with alpha channel
  • CMYKA: CMYK with alpha channel
  • GRAYA: Gray with alpha channel
  • YCbCrA: YCbCr with alpha channel
colorDepthA string describing the color depth of the image:
  • U8: unsigned 8 bits integer, the most common type
  • U16: unsigned 16 bits integer
  • F16: half, 16 bits floating point. Only available if Krita was built with OpenEXR
  • F32: 32 bits floating point
Returns
a list with valid names

Definition at line 194 of file Krita.cpp.

195{
196 QSet<QString> profileNames;
197 QString id = KoColorSpaceRegistry::instance()->colorSpaceId(colorModel, colorDepth);
199 Q_FOREACH(const KoColorProfile *profile, profiles) {
200 profileNames << profile->name();
201 }
202 QStringList r(profileNames.begin(), profileNames.end());
203 r.sort();
204 return r;
205}
QStringList profiles(const QString &colorModel, const QString &colorDepth) const
profiles creates a list with the names of all color profiles compatible with the given color model an...
Definition Krita.cpp:194
QString colorSpaceId(const QString &colorModelId, const QString &colorDepthId) const
QList< const KoColorProfile * > profilesFor(const QString &csID) const

References KoColorSpaceRegistry::colorSpaceId(), KoColorSpaceRegistry::instance(), KoColorProfile::name, profiles(), and KoColorSpaceRegistry::profilesFor().

◆ readSetting

QString Krita::readSetting ( const QString & group,
const QString & name,
const QString & defaultValue )
slot

readSetting read the given setting value from the kritarc file.

Parameters
groupThe group the setting is part of. If empty, then the setting is read from the general group.
nameThe name of the setting
defaultValueThe default value of the setting
Returns
a string representing the setting.

Definition at line 374 of file Krita.cpp.

375{
376 KConfigGroup grp = KSharedConfig::openConfig()->group(group);
377 return grp.readEntry(name, defaultValue);
378}

◆ recentDocuments

QStringList Krita::recentDocuments ( ) const
slot

return all recent documents registered in the RecentFiles group of the kritarc

Definition at line 305 of file Krita.cpp.

306{
307 KConfigGroup grp = KSharedConfig::openConfig()->group(QString("RecentFiles"));
308 QStringList keys = grp.keyList();
310
311 for(int i = 0; i <= keys.filter("File").count(); i++)
312 recentDocuments << grp.readEntry(QString("File%1").arg(i), QString(""));
313
314 return recentDocuments;
315}
QStringList recentDocuments() const
return all recent documents registered in the RecentFiles group of the kritarc
Definition Krita.cpp:305

References recentDocuments().

◆ resources

QMap< QString, Resource * > Krita::resources ( QString & type) const
slot

resources returns a list of Resource objects of the given type

Parameters
typeValid types are:
  • pattern
  • gradient
  • brush
  • preset
  • palette
  • workspace

Definition at line 251 of file Krita.cpp.

252{
253 QMap<QString, Resource*> resources;
254 KisResourceModel *resourceModel = 0;
255 if (type == "pattern") {
258 }
259 else if (type == "gradient") {
262 }
263 else if (type == "brush") {
266 }
267 else if (type == "palette") {
270 }
271 else if (type == "workspace") {
274 }
275 else if (type == "preset") {
277 }
278
279 if (resourceModel) {
280 for (int i = 0; i < resourceModel->rowCount(); ++i) {
281
282 QModelIndex idx = resourceModel->index(i, 0);
283 int id = resourceModel->data(idx, Qt::UserRole + KisAbstractResourceModel::Id).toInt();
284 QString name = resourceModel->data(idx, Qt::UserRole + KisAbstractResourceModel::Name).toString();
285 QString filename = resourceModel->data(idx, Qt::UserRole + KisAbstractResourceModel::Filename).toString();
286 QImage image = resourceModel->data(idx, Qt::UserRole + KisAbstractResourceModel::Thumbnail).value<QImage>();
287
288 resources[name] = new Resource(id, type, name, filename, image, 0);
289 }
290 }
291
292 return resources;
293}
static KisBrushServerProvider * instance()
KoResourceServer< KisBrush > * brushServer()
The KisResourceModel class provides the main access to resources. It is possible to filter the resour...
static KisResourceServerProvider * instance()
KoResourceServer< KisWorkspaceResource > * workspaceServer()
KisPaintOpPresetResourceServer * paintOpPresetServer()
KisResourceModel * resourceModel() const
QMap< QString, Resource * > resources(QString &type) const
resources returns a list of Resource objects of the given type
Definition Krita.cpp:251
const char * name(StandardAction id)
const QString Palettes
const QString Brushes
const QString Patterns
const QString Gradients
const QString Workspaces
static KoResourceServerProvider * instance()
KoResourceServer< KoPattern > * patternServer
KoResourceServer< KoColorSet > * paletteServer
KoResourceServer< KoAbstractGradient > * gradientServer

References ResourceType::Brushes, KisBrushServerProvider::brushServer(), KisAbstractResourceModel::Filename, ResourceType::Gradients, KoResourceServerProvider::gradientServer, KisAbstractResourceModel::Id, KisBrushServerProvider::instance(), KisResourceServerProvider::instance(), KoResourceServerProvider::instance(), KisAbstractResourceModel::Name, KisResourceServerProvider::paintOpPresetServer(), ResourceType::Palettes, KoResourceServerProvider::paletteServer, ResourceType::Patterns, KoResourceServerProvider::patternServer, KoResourceServer< T >::resourceModel(), resources(), KisAbstractResourceModel::Thumbnail, ResourceType::Workspaces, and KisResourceServerProvider::workspaceServer().

◆ setActiveDocument

void Krita::setActiveDocument ( Document * value)
slot

setActiveDocument activates the first view that shows the given document

Parameters
valuethe document we want to activate

Definition at line 119 of file Krita.cpp.

120{
121 Q_FOREACH(KisView *view, KisPart::instance()->views()) {
122 if (view->document() == value->document().data()) {
123 view->activateWindow();
124 break;
125 }
126 }
127}
float value(const T *src, size_t ch)
QList< View * > views() const
Definition Krita.cpp:224

References KisView::document, KisPart::instance(), value(), and views().

◆ setBatchmode

void Krita::setBatchmode ( bool value)
slot

setBatchmode sets the batchmode to

Parameters
value;if true, scripts should not show dialogs or messageboxes.

Definition at line 134 of file Krita.cpp.

135{
136 d->batchMode = value;
137}

References krita::Krita::Private::batchMode, d, and value().

◆ version

QString Krita::version ( ) const
slot

version Determine the version of Krita

Usage: print(Application.version ())

Returns
the version string including git sha1 if Krita was built from git

Definition at line 219 of file Krita.cpp.

220{
222}
KRITAVERSION_EXPORT QString versionString(bool checkGit=false)

References KritaVersionWrapper::versionString().

◆ views

QList< View * > Krita::views ( ) const
slot
Returns
a list of all views. A Document can be shown in more than one view.

Definition at line 224 of file Krita.cpp.

225{
226 QList<View *> ret;
227 foreach(QPointer<KisView> view, KisPart::instance()->views()) {
228 ret << new View(view);
229 }
230 return ret;
231}

References KisPart::instance(), and views().

◆ windows

QList< Window * > Krita::windows ( ) const
slot
Returns
a list of all windows

Definition at line 242 of file Krita.cpp.

243{
244 QList<Window*> ret;
245 foreach(QPointer<KisMainWindow> mainWin, KisPart::instance()->mainWindows()) {
246 ret << new Window(mainWin);
247 }
248 return ret;
249}

References KisPart::instance().

◆ writeSetting

void Krita::writeSetting ( const QString & group,
const QString & name,
const QString & value )
slot

writeSetting write the given setting under the given name to the kritarc file in the given settings group.

Parameters
groupThe group the setting belongs to. If empty, then the setting is written in the general section
nameThe name of the setting
valueThe value of the setting. Script settings are always written as strings.

Definition at line 368 of file Krita.cpp.

369{
370 KConfigGroup grp = KSharedConfig::openConfig()->group(group);
371 grp.writeEntry(name, value);
372}

References value().

Member Data Documentation

◆ d

Private* const Krita::d
private

Definition at line 337 of file Krita.h.

◆ s_instance

Krita * Krita::s_instance = 0
staticprivate

Definition at line 338 of file Krita.h.


The documentation for this class was generated from the following files: