diff --git a/plugins/extensions/pykrita/libkis/Document.cpp b/plugins/extensions/pykrita/libkis/Document.cpp index d8f84567a5..58ae70829e 100644 --- a/plugins/extensions/pykrita/libkis/Document.cpp +++ b/plugins/extensions/pykrita/libkis/Document.cpp @@ -1,244 +1,296 @@ /* * Copyright (c) 2016 Boudewijn Rempt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "Document.h" #include - +#include #include +#include +#include +#include + +#include +#include struct Document::Private { Private() {} QPointer document; + bool ownsDocument {false}; }; -Document::Document(KisDocument *document, QObject *parent) +Document::Document(KisDocument *document, bool ownsDocument, QObject *parent) : QObject(parent) , d(new Private) { d->document = document; + d->ownsDocument = ownsDocument; } Document::~Document() { delete d; } -Node* Document::activeNode() const +Node *Document::activeNode() const { - return 0; + QList activeNodes; + Q_FOREACH(QPointer view, KisPart::instance()->views()) { + if (view && view->document() == d->document) { + activeNodes << view->currentNode(); + } + } + if (activeNodes.size() > 0) { + return new Node(activeNodes.first()); + } + return new Node(d->document->image()->root()->firstChild()); } void Document::setActiveNode(Node* value) { } ColorDepth* Document::colorDepth() const { return 0; } void Document::setColorDepth(ColorDepth* value) { } ColorManager* Document::colorManager() const { return 0; } void Document::setColorManager(ColorManager* value) { } ColorModel* Document::colorModel() const { return 0; } void Document::setColorModel(ColorModel* value) { } ColorProfile* Document::colorProfile() const { return 0; } void Document::setColorProfile(ColorProfile* value) { } InfoObject* Document::documentInfo() const { return 0; } void Document::setDocumentInfo(InfoObject* value) { } QString Document::fileName() const { - return QString(); + if (!d->document) return QString::null; + return d->document->url().toLocalFile(); } void Document::setFileName(QString value) { } int Document::height() const { - return 0; + if (!d->document) return 0; + KisImageSP image = d->document->image(); + if (!image) return 0; + return image->height(); } void Document::setHeight(int value) { + if (!d->document) return; + KisImageSP image = d->document->image(); + if (!image) return; + QRect rc = image->bounds(); + rc.setHeight(value); + image->resizeImage(rc); } InfoObject* Document::metaData() const { return 0; } void Document::setMetaData(InfoObject* value) { } QString Document::name() const { return QString(); } void Document::setName(QString value) { } int Document::resolution() const { return 0; } void Document::setResolution(int value) { } -Node* Document::rootNode() const +Node *Document::rootNode() const { - return 0; -} + if (!d->document) return 0; + KisImageSP image = d->document->image(); + if (!image) return 0; -void Document::setRootNode(Node* value) -{ + return new Node(image->root()); } - -Selection* Document::selection() const +Selection *Document::selection() const { return 0; } void Document::setSelection(Selection* value) { } int Document::width() const { - return 0; + if (!d->document) return 0; + KisImageSP image = d->document->image(); + if (!image) return 0; + return image->width(); } void Document::setWidth(int value) { + if (!d->document) return; + KisImageSP image = d->document->image(); + if (!image) return; + QRect rc = image->bounds(); + rc.setWidth(value); + image->resizeImage(rc); } QByteArray Document::pixelData() const { - return QByteArray(); -} - -void Document::setPixelData(QByteArray value) -{ -} + QByteArray ba; + if (!d->document) return ba; + KisImageSP image = d->document->image(); + if (!image) return ba; - - -Document * Document::clone() -{ - return 0; + KisPaintDeviceSP dev = image->projection(); + quint8 *data = new quint8[image->width() * image->height() * dev->pixelSize()]; + dev->readBytes(data, 0, 0, image->width(), image->height()); + ba = QByteArray((const char*)data, (int)(image->width() * image->height() * dev->pixelSize())); + delete[] data; + return ba; } bool Document::close() { - return false; + if (d->ownsDocument) { + KisPart::instance()->removeDocument(d->document); + } + return d->document->closeUrl(false); } bool Document::convert(const QString &colorModel, const ColorProfile *profile) { return false; } void Document::crop(int x, int y, int w, int h) { + if (!d->document) return; + KisImageSP image = d->document->image(); + if (!image) return; + QRect rc(x, y, w, h); + image->cropImage(rc); } -bool Document::Export(const InfoObject &exportConfiguration) +bool Document::exportImage(const QString &filename, const InfoObject &exportConfiguration) { - return false; + if (!d->document) return false; + return d->document->exportDocument(QUrl::fromLocalFile(filename)); } -void Document::Flatten() +void Document::flatten() { } -void Document::ResizeImage(int w, int h) +void Document::resizeImage(int w, int h) { + if (!d->document) return; + KisImageSP image = d->document->image(); + if (!image) return; + QRect rc = image->bounds(); + rc.setWidth(w); + rc.setHeight(h); + image->resizeImage(rc); } -bool Document::Save(const QString &url) +bool Document::save() { - return false; + if (!d->document) return false; + return d->document->save(); } -bool Document::SaveAs(const QString &url) +bool Document::saveAs(const QString &filename) { - return false; + if (!d->document) return false; + return d->document->saveAs(QUrl::fromLocalFile(filename)); } -void Document::OpenView() +void Document::openView() { } -Node* Document::CreateNode(const QString &name, const QString &nodeType) +Node* Document::createNode(const QString &name, const QString &nodeType) { return 0; } diff --git a/plugins/extensions/pykrita/libkis/Document.h b/plugins/extensions/pykrita/libkis/Document.h index d26467ce5d..3872c17ad2 100644 --- a/plugins/extensions/pykrita/libkis/Document.h +++ b/plugins/extensions/pykrita/libkis/Document.h @@ -1,131 +1,111 @@ /* * Copyright (c) 2016 Boudewijn Rempt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef LIBKIS_DOCUMENT_H #define LIBKIS_DOCUMENT_H #include #include "kritalibkis_export.h" #include "libkis.h" class KisDocument; /** * Document */ class KRITALIBKIS_EXPORT Document : public QObject { Q_OBJECT Q_DISABLE_COPY(Document) - Q_PROPERTY(Node* ActiveNode READ activeNode WRITE setActiveNode) - Q_PROPERTY(ColorDepth* ColorDepth READ colorDepth WRITE setColorDepth) - Q_PROPERTY(ColorManager* ColorManager READ colorManager WRITE setColorManager) - Q_PROPERTY(ColorModel* ColorModel READ colorModel WRITE setColorModel) - Q_PROPERTY(ColorProfile* ColorProfile READ colorProfile WRITE setColorProfile) - Q_PROPERTY(InfoObject* DocumentInfo READ documentInfo WRITE setDocumentInfo) - Q_PROPERTY(QString FileName READ fileName WRITE setFileName) - Q_PROPERTY(int Height READ height WRITE setHeight) - Q_PROPERTY(InfoObject* MetaData READ metaData WRITE setMetaData) - Q_PROPERTY(QString Name READ name WRITE setName) - Q_PROPERTY(int Resolution READ resolution WRITE setResolution) - Q_PROPERTY(Node* RootNode READ rootNode WRITE setRootNode) - Q_PROPERTY(Selection* Selection READ selection WRITE setSelection) - Q_PROPERTY(int Width READ width WRITE setWidth) - Q_PROPERTY(QByteArray PixelData READ pixelData WRITE setPixelData) - public: - explicit Document(KisDocument *document, QObject *parent = 0); + explicit Document(KisDocument *document, bool ownsDocument = false, QObject *parent = 0); virtual ~Document(); Node* activeNode() const; void setActiveNode(Node* value); ColorDepth* colorDepth() const; void setColorDepth(ColorDepth* value); ColorManager* colorManager() const; void setColorManager(ColorManager* value); ColorModel* colorModel() const; void setColorModel(ColorModel* value); ColorProfile* colorProfile() const; void setColorProfile(ColorProfile* value); InfoObject* documentInfo() const; void setDocumentInfo(InfoObject* value); QString fileName() const; void setFileName(QString value); int height() const; void setHeight(int value); InfoObject* metaData() const; void setMetaData(InfoObject* value); QString name() const; void setName(QString value); int resolution() const; void setResolution(int value); Node* rootNode() const; - void setRootNode(Node* value); Selection* selection() const; void setSelection(Selection* value); int width() const; void setWidth(int value); QByteArray pixelData() const; - void setPixelData(QByteArray value); public Q_SLOTS: - Document * clone(); - bool close(); bool convert(const QString &colorModel, const ColorProfile *profile); void crop(int x, int y, int w, int h); - bool Export(const InfoObject &exportConfiguration); + bool exportImage(const QString &filename, const InfoObject &exportConfiguration); - void Flatten(); + void flatten(); - void ResizeImage(int w, int h); + void resizeImage(int w, int h); - bool Save(const QString &url); + bool save(); - bool SaveAs(const QString &url); + bool saveAs(const QString &filename); - void OpenView(); + void openView(); - Node* CreateNode(const QString &name, const QString &nodeType); + Node* createNode(const QString &name, const QString &nodeType); private: struct Private; Private *const d; }; #endif // LIBKIS_DOCUMENT_H diff --git a/plugins/extensions/pykrita/libkis/InfoObject.cpp b/plugins/extensions/pykrita/libkis/InfoObject.cpp index 3e91691388..8c146b0eec 100644 --- a/plugins/extensions/pykrita/libkis/InfoObject.cpp +++ b/plugins/extensions/pykrita/libkis/InfoObject.cpp @@ -1,57 +1,65 @@ /* * Copyright (c) 2016 Boudewijn Rempt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "InfoObject.h" +#include + struct InfoObject::Private { Private() {} + + KisPropertiesConfiguration properties; }; -InfoObject::InfoObject(QObject *parent) +InfoObject::InfoObject(QObject *parent) : QObject(parent) , d(new Private) { } -InfoObject::~InfoObject() +InfoObject::~InfoObject() { delete d; } QMap InfoObject::properties() const { - return QMap(); + return d->properties.getProperties(); } -void InfoObject::setproperties(QMap value) +void InfoObject::setproperties(QMap proprertyMap) { + Q_FOREACH(const QString & key, proprertyMap.keys()) { + d->properties.setProperty(key, proprertyMap[key]); + } } - - - void InfoObject::setProperty(const QString &key, QVariant value) { + d->properties.setProperty(key, value); } QVariant InfoObject::property(const QString &key) { - return QVariant(); + QVariant v; + if (d->properties.hasProperty(key)) { + d->properties.getProperty(key, v); + } + return v; } - diff --git a/plugins/extensions/pykrita/libkis/InfoObject.h b/plugins/extensions/pykrita/libkis/InfoObject.h index f3f21e8441..172b934559 100644 --- a/plugins/extensions/pykrita/libkis/InfoObject.h +++ b/plugins/extensions/pykrita/libkis/InfoObject.h @@ -1,63 +1,56 @@ /* * Copyright (c) 2016 Boudewijn Rempt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef LIBKIS_INFOOBJECT_H #define LIBKIS_INFOOBJECT_H #include +#include #include "kritalibkis_export.h" #include "libkis.h" /** * InfoObject */ class KRITALIBKIS_EXPORT InfoObject : public QObject { Q_OBJECT Q_DISABLE_COPY(InfoObject) - + Q_PROPERTY(QMap properties READ properties WRITE setproperties) public: explicit InfoObject(QObject *parent = 0); virtual ~InfoObject(); QMap properties() const; - void setproperties(QMap value); - - + void setproperties(QMap proprertyMap); public Q_SLOTS: - - void setProperty(const QString &key, QVariant value); + void setProperty(const QString &key, QVariant value); QVariant property(const QString &key); - -Q_SIGNALS: - - - private: struct Private; - const Private *const d; + Private *d; }; #endif // LIBKIS_INFOOBJECT_H diff --git a/plugins/extensions/pykrita/libkis/Krita.cpp b/plugins/extensions/pykrita/libkis/Krita.cpp index bd376a84b4..3d82e81ee2 100644 --- a/plugins/extensions/pykrita/libkis/Krita.cpp +++ b/plugins/extensions/pykrita/libkis/Krita.cpp @@ -1,271 +1,289 @@ /* * Copyright (c) 2016 Boudewijn Rempt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "Krita.h" #include #include #include #include #include #include #include #include #include #include #include "View.h" #include "Document.h" #include "Window.h" #include "ViewExtension.h" #include "DockWidgetFactoryBase.h" #include Krita* Krita::s_instance = 0; struct Krita::Private { Private() {} QList viewExtensions; bool batchMode {false}; Notifier *notifier{new Notifier()}; }; Krita::Krita(QObject *parent) : QObject(parent) , d(new Private) { qRegisterMetaType(); } Krita::~Krita() { qDeleteAll(d->viewExtensions); delete d->notifier; delete d; } QList Krita::actions() const { QList actionList; KisMainWindow *mainWindow = KisPart::instance()->currentMainwindow(); + if (!mainWindow) { + return actionList; + } KActionCollection *actionCollection = mainWindow->actionCollection(); Q_FOREACH(QAction *action, actionCollection->actions()) { actionList << new Action(action->objectName(), action); } return actionList; } Action *Krita::action(const QString &name) const { KisMainWindow *mainWindow = KisPart::instance()->currentMainwindow(); + if (!mainWindow) { + return 0; + } KActionCollection *actionCollection = mainWindow->actionCollection(); QAction *action = actionCollection->action(name); if (action) { return new Action(name, action); } return 0; } Document* Krita::activeDocument() const { - return 0; + KisMainWindow *mainWindow = KisPart::instance()->currentMainwindow(); + if (!mainWindow) { + return 0; + } + KisView *view = mainWindow->activeView(); + if (!view) { + return 0; + } + KisDocument *document = view->document(); + return new Document(document); } void Krita::setActiveDocument(Document* value) { } bool Krita::batchmode() const { return d->batchMode; } void Krita::setBatchmode(bool value) { d->batchMode = value; } QList Krita::documents() const { QList ret; foreach(QPointer doc, KisPart::instance()->documents()) { ret << new Document(doc); } return ret; } QList Krita::exporters() const { return QList(); } QList Krita::filters() const { return QList(); } QList Krita::generators() const { return QList (); } QList Krita::importers() const { return QList(); } Notifier* Krita::notifier() const { return d->notifier; } InfoObject* Krita::preferences() const { return 0; } void Krita::setPreferences(InfoObject* value) { } QString Krita::version() const { return QString(); } QList Krita::views() const { QList ret; foreach(QPointer view, KisPart::instance()->views()) { ret << new View(view); } return ret; } QList Krita::windows() const { QList ret; foreach(QPointer mainWin, KisPart::instance()->mainWindows()) { ret << new Window(mainWin); } return ret; } QList Krita::resources() const { return QList (); } void Krita::setResources(QList value) { } void Krita::addDockWidget(DockWidget *dockWidget) { } void Krita::addAction(Action *action) { } bool Krita::closeApplication() { qDebug() << "closeApplication called"; return false; } Document* Krita::createDocument() { return 0; } -Document* Krita::openDocument() +Document* Krita::openDocument(const QString &filename) { - return 0; + KisDocument *document = KisPart::instance()->createDocument(); + KisPart::instance()->addDocument(document); + document->openUrl(QUrl::fromLocalFile(filename), KisDocument::OPEN_URL_FLAG_DO_NOT_ADD_TO_RECENT_FILES); + return new Document(document); } Window* Krita::openWindow() { return 0; } QAction *Krita::createAction(const QString &text) { KisAction *action = new KisAction(text, this); KisPart::instance()->addScriptAction(action); return action; } void Krita::addViewExtension(ViewExtension* viewExtension) { d->viewExtensions.append(viewExtension); } QList< ViewExtension* > Krita::viewExtensions() { return d->viewExtensions; } void Krita::addDockWidgetFactory(DockWidgetFactoryBase* factory) { KoDockRegistry::instance()->add(factory); } Krita* Krita::instance() { if (!s_instance) { s_instance = new Krita; } return s_instance; } /** * 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 * I hope that will change some time. */ QObject *Krita::fromVariant(const QVariant& v) { if (v.canConvert< QWidget* >()) { QObject* obj = qvariant_cast< QWidget* >(v); return obj; } else if (v.canConvert< QObject* >()) { QObject* obj = qvariant_cast< QObject* >(v); return obj; } else return 0; } diff --git a/plugins/extensions/pykrita/libkis/Krita.h b/plugins/extensions/pykrita/libkis/Krita.h index 7710324aaf..b4fac98d14 100644 --- a/plugins/extensions/pykrita/libkis/Krita.h +++ b/plugins/extensions/pykrita/libkis/Krita.h @@ -1,114 +1,114 @@ /* * Copyright (c) 2016 Boudewijn Rempt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef LIBKIS_KRITA_H #define LIBKIS_KRITA_H #include #include "kritalibkis_export.h" #include "libkis.h" #include "ViewExtension.h" #include "Document.h" #include "Window.h" #include "View.h" #include "Action.h" #include "Notifier.h" class QAction; /** * Krita is a singleton class that offers the root access to the Krita object hierarchy. */ class KRITALIBKIS_EXPORT Krita : public QObject { Q_OBJECT public: explicit Krita(QObject *parent = 0); virtual ~Krita(); Document* activeDocument() const; void setActiveDocument(Document* value); bool batchmode() const; void setBatchmode(bool value); QList actions() const; Action *action(const QString &name) const; QList documents() const; QList exporters() const; QList filters() const; QList generators() const; QList importers() const; Notifier* notifier() const; InfoObject* preferences() const; void setPreferences(InfoObject* value); QString version() const; QList views() const; QList windows() const; QList resources() const; void setResources(QList value); public Q_SLOTS: void addDockWidget(DockWidget *dockWidget); void addAction(Action *action); bool closeApplication(); Document* createDocument(); - Document* openDocument(); + Document* openDocument(const QString &filename); Window* openWindow(); QAction *createAction(const QString &text); void addViewExtension(ViewExtension* viewExtension); QList viewExtensions(); void addDockWidgetFactory(DockWidgetFactoryBase* factory ); static Krita* instance(); static QObject *fromVariant(const QVariant& v); private: struct Private; Private *const d; static Krita* s_instance; }; Q_DECLARE_METATYPE(Notifier*); #endif // LIBKIS_KRITA_H diff --git a/plugins/extensions/pykrita/libkis/Node.cpp b/plugins/extensions/pykrita/libkis/Node.cpp index e986699cf8..cb6ab66532 100644 --- a/plugins/extensions/pykrita/libkis/Node.cpp +++ b/plugins/extensions/pykrita/libkis/Node.cpp @@ -1,283 +1,288 @@ /* * Copyright (c) 2016 Boudewijn Rempt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "Node.h" #include "Channel.h" #include "ColorDepth.h" #include "ColorModel.h" #include "ColorProfile.h" #include "Generator.h" #include "Filter.h" #include "Transformation.h" #include "Selection.h" +#include +#include + struct Node::Private { Private() {} + KisNodeSP node; }; -Node::Node(QObject *parent) +Node::Node(KisNodeSP node, QObject *parent) : QObject(parent) , d(new Private) { + d->node = node; } -Node::~Node() +Node::~Node() { delete d; } bool Node::alphaLocked() const { return false; } void Node::setAlphaLocked(bool value) { } QString Node::blendingMode() const { return QString(); } void Node::setBlendingMode(QString value) { } QList Node::channels() const { return QList(); } void Node::setChannels(QList value) { } QList Node::childNodes() const { return QList(); } void Node::setChildNodes(QList value) { } ColorDepth* Node::colorDepth() const { return 0; } void Node::setColorDepth(ColorDepth* value) { } QString Node::colorLabel() const { return QString(); } void Node::setColorLabel(QString value) { } ColorModel* Node::colorModel() const { return 0; } void Node::setColorModel(ColorModel* value) { } ColorProfile* Node::colorProfile() const { return 0; } void Node::setColorProfile(ColorProfile* value) { } bool Node::inheritAlpha() const { return false; } void Node::setInheritAlpha(bool value) { } bool Node::locked() const { return false; } void Node::setLocked(bool value) { } QString Node::name() const { return QString(); } void Node::setName(QString value) { } int Node::opacity() const { return 0; } void Node::setOpacity(int value) { } Node* Node::parentNode() const { return 0; } void Node::setParentNode(Node* value) { } QString Node::type() const { return QString(); } void Node::setType(QString value) { } bool Node::visible() const { return false; } void Node::setVisible(bool value) { } InfoObject* Node::metaDataInfo() const { return 0; } void Node::setMetaDataInfo(InfoObject* value) { } Generator* Node::generator() const { return 0; } void Node::setGenerator(Generator* value) { } Filter* Node::filter() const { return 0; } void Node::setFilter(Filter* value) { } Transformation* Node::transformation() const { return 0; } void Node::setTransformation(Transformation* value) { } Selection* Node::selection() const { return 0; } void Node::setSelection(Selection* value) { } QString Node::fileName() const { return QString(); } void Node::setFileName(QString value) { } QByteArray Node::pixelData() const { return QByteArray(); } void Node::setPixelData(QByteArray value) { } void Node::move(int x, int y) { } void Node::moveToParent(Node *parent) { } void Node::remove() { } Node* Node::duplicate() { return 0; } diff --git a/plugins/extensions/pykrita/libkis/Node.h b/plugins/extensions/pykrita/libkis/Node.h index 0b516faa17..f5c230ba07 100644 --- a/plugins/extensions/pykrita/libkis/Node.h +++ b/plugins/extensions/pykrita/libkis/Node.h @@ -1,151 +1,153 @@ /* * Copyright (c) 2016 Boudewijn Rempt * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef LIBKIS_NODE_H #define LIBKIS_NODE_H #include +#include + #include "kritalibkis_export.h" #include "libkis.h" /** * Node */ class KRITALIBKIS_EXPORT Node : public QObject { Q_OBJECT Q_DISABLE_COPY(Node) - + Q_PROPERTY(bool AlphaLocked READ alphaLocked WRITE setAlphaLocked) Q_PROPERTY(QString BlendingMode READ blendingMode WRITE setBlendingMode) Q_PROPERTY(QList Channels READ channels WRITE setChannels) Q_PROPERTY(QList ChildNodes READ childNodes WRITE setChildNodes) Q_PROPERTY(ColorDepth* ColorDepth READ colorDepth WRITE setColorDepth) Q_PROPERTY(QString ColorLabel READ colorLabel WRITE setColorLabel) Q_PROPERTY(ColorModel* ColorModel READ colorModel WRITE setColorModel) Q_PROPERTY(ColorProfile* ColorProfile READ colorProfile WRITE setColorProfile) Q_PROPERTY(bool InheritAlpha READ inheritAlpha WRITE setInheritAlpha) Q_PROPERTY(bool Locked READ locked WRITE setLocked) Q_PROPERTY(QString Name READ name WRITE setName) Q_PROPERTY(int Opacity READ opacity WRITE setOpacity) Q_PROPERTY(Node* ParentNode READ parentNode WRITE setParentNode) Q_PROPERTY(QString Type READ type WRITE setType) Q_PROPERTY(bool Visible READ visible WRITE setVisible) Q_PROPERTY(InfoObject* MetaDataInfo READ metaDataInfo WRITE setMetaDataInfo) Q_PROPERTY(Generator* Generator READ generator WRITE setGenerator) Q_PROPERTY(Filter* Filter READ filter WRITE setFilter) Q_PROPERTY(Transformation* Transformation READ transformation WRITE setTransformation) Q_PROPERTY(Selection* Selection READ selection WRITE setSelection) Q_PROPERTY(QString FileName READ fileName WRITE setFileName) Q_PROPERTY(QByteArray PixelData READ pixelData WRITE setPixelData) public: - explicit Node(QObject *parent = 0); + explicit Node(KisNodeSP node, QObject *parent = 0); virtual ~Node(); bool alphaLocked() const; void setAlphaLocked(bool value); QString blendingMode() const; void setBlendingMode(QString value); QList channels() const; void setChannels(QList value); QList childNodes() const; void setChildNodes(QList value); ColorDepth* colorDepth() const; void setColorDepth(ColorDepth* value); QString colorLabel() const; void setColorLabel(QString value); ColorModel* colorModel() const; void setColorModel(ColorModel* value); ColorProfile* colorProfile() const; void setColorProfile(ColorProfile* value); bool inheritAlpha() const; void setInheritAlpha(bool value); bool locked() const; void setLocked(bool value); QString name() const; void setName(QString value); int opacity() const; void setOpacity(int value); Node* parentNode() const; void setParentNode(Node* value); QString type() const; void setType(QString value); bool visible() const; void setVisible(bool value); InfoObject* metaDataInfo() const; void setMetaDataInfo(InfoObject* value); Generator* generator() const; void setGenerator(Generator* value); Filter* filter() const; void setFilter(Filter* value); Transformation* transformation() const; void setTransformation(Transformation* value); Selection* selection() const; void setSelection(Selection* value); QString fileName() const; void setFileName(QString value); QByteArray pixelData() const; void setPixelData(QByteArray value); public Q_SLOTS: - + void move(int x, int y); void moveToParent(Node *parent); void remove(); Node* duplicate(); - + Q_SIGNALS: private: struct Private; - const Private *const d; + Private *d; }; #endif // LIBKIS_NODE_H diff --git a/plugins/extensions/pykrita/sip/krita/Document.sip b/plugins/extensions/pykrita/sip/krita/Document.sip index b7d174df90..189f900719 100644 --- a/plugins/extensions/pykrita/sip/krita/Document.sip +++ b/plugins/extensions/pykrita/sip/krita/Document.sip @@ -1,52 +1,49 @@ class Document : QObject /NoDefaultCtors/ { %TypeHeaderCode #include "Document.h" %End Document(const Document & __0); public: Node * activeNode() const; void setActiveNode(Node* value); ColorDepth * colorDepth() const; void setColorDepth(ColorDepth* value); ColorManager * colorManager() const; void setColorManager(ColorManager* value); ColorModel * colorModel() const; void setColorModel(ColorModel* value); ColorProfile * colorProfile() const; void setColorProfile(ColorProfile* value); InfoObject * documentInfo() const; void setDocumentInfo(InfoObject* value); QString fileName() const; void setFileName(QString value); int height() const; void setHeight(int value); InfoObject * metaData() const; void setMetaData(InfoObject* value); QString name() const; void setName(QString value); int resolution() const; void setResolution(int value); Node * rootNode() const; - void setRootNode(Node* value); Selection * selection() const; void setSelection(Selection* value); int width() const; void setWidth(int value); QByteArray pixelData() const; - void setPixelData(QByteArray value); public Q_SLOTS: - Document * clone(); bool close(); bool convert(const QString & colorModel, const ColorProfile* profile); void crop(int x, int y, int w, int h); - bool Export(const InfoObject & exportConfiguration); - void Flatten(); - void ResizeImage(int w, int h); - bool Save(const QString & url); - bool SaveAs(const QString & url); - void OpenView(); - Node * CreateNode(const QString & name, const QString & nodeType); + bool exportImage(const QString &filename, const InfoObject & exportConfiguration); + void flatten(); + void resizeImage(int w, int h); + bool save(); + bool saveAs(const QString & filename); + void openView(); + Node * createNode(const QString & name, const QString & nodeType); private: }; diff --git a/plugins/extensions/pykrita/sip/krita/Krita.sip b/plugins/extensions/pykrita/sip/krita/Krita.sip index 8ec69f4709..9eb709d0b4 100644 --- a/plugins/extensions/pykrita/sip/krita/Krita.sip +++ b/plugins/extensions/pykrita/sip/krita/Krita.sip @@ -1,59 +1,59 @@ class Krita : QObject { %TypeHeaderCode #include "Krita.h" %End public: public: Krita(QObject* parent /TransferThis/ = 0); virtual ~Krita(); Document * activeDocument() const; void setActiveDocument(Document* value); bool batchmode() const; void setBatchmode(bool value); QList actions() const; Action * action(const QString & name) const; QList documents() const; QList exporters() const; QList filters() const; QList generators() const; QList importers() const; Notifier * notifier() const; InfoObject * preferences() const; void setPreferences(InfoObject* value); QString version() const; QList views() const; QList windows() const; QList resources() const; void setResources(QList value); public Q_SLOTS: void addDockWidget(DockWidget* dockWidget); void addAction(Action* action); bool closeApplication(); Document * createDocument(); - Document * openDocument(); + Document * openDocument(const QString &filename); Window * openWindow(); QAction * createAction(const QString & text); void addViewExtension(ViewExtension* _viewExtension /GetWrapper/); %MethodCode Py_BEGIN_ALLOW_THREADS sipCpp->addViewExtension(a0); Py_END_ALLOW_THREADS sipTransferTo(a0Wrapper, Py_None); %End void addDockWidgetFactory(DockWidgetFactoryBase* _factory /GetWrapper/); %MethodCode Py_BEGIN_ALLOW_THREADS sipCpp->addDockWidgetFactory(a0); Py_END_ALLOW_THREADS sipTransferTo(a0Wrapper, Py_None); %End static Krita * instance(); static QObject * fromVariant(const QVariant & v); private: Krita(const Krita &); // Generated }; diff --git a/plugins/extensions/pykrita/sip/krita/Node.sip b/plugins/extensions/pykrita/sip/krita/Node.sip index 76dd3af086..21aead346d 100644 --- a/plugins/extensions/pykrita/sip/krita/Node.sip +++ b/plugins/extensions/pykrita/sip/krita/Node.sip @@ -1,61 +1,60 @@ class Node : QObject { %TypeHeaderCode #include "Node.h" %End Node(const Node & __0); public: - Node(QObject* parent /TransferThis/ = 0); virtual ~Node(); bool alphaLocked() const; void setAlphaLocked(bool value); QString blendingMode() const; void setBlendingMode(QString value); QList channels() const; void setChannels(QList value); QList childNodes() const; void setChildNodes(QList value); ColorDepth * colorDepth() const; void setColorDepth(ColorDepth* value); QString colorLabel() const; void setColorLabel(QString value); ColorModel * colorModel() const; void setColorModel(ColorModel* value); ColorProfile * colorProfile() const; void setColorProfile(ColorProfile* value); bool inheritAlpha() const; void setInheritAlpha(bool value); bool locked() const; void setLocked(bool value); QString name() const; void setName(QString value); int opacity() const; void setOpacity(int value); Node * parentNode() const; void setParentNode(Node* value); QString type() const; void setType(QString value); bool visible() const; void setVisible(bool value); InfoObject * metaDataInfo() const; void setMetaDataInfo(InfoObject* value); Generator * generator() const; void setGenerator(Generator* value); Filter * filter() const; void setFilter(Filter* value); Transformation * transformation() const; void setTransformation(Transformation* value); Selection * selection() const; void setSelection(Selection* value); QString fileName() const; void setFileName(QString value); QByteArray pixelData() const; void setPixelData(QByteArray value); public Q_SLOTS: void move(int x, int y); void moveToParent(Node* parent); void remove(); Node * duplicate(); Q_SIGNALS: private: };