diff --git a/krita/plugins/extensions/pykrita/libkis/application.cpp b/krita/plugins/extensions/pykrita/libkis/application.cpp index bc646d17ef..1ef9ba9987 100644 --- a/krita/plugins/extensions/pykrita/libkis/application.cpp +++ b/krita/plugins/extensions/pykrita/libkis/application.cpp @@ -1,6 +1,23 @@ +/* + * Copyright (c) 2014 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 "application.h" Application::Application(QObject *parent) : QObject(parent) { } diff --git a/krita/plugins/extensions/pykrita/libkis/application.h b/krita/plugins/extensions/pykrita/libkis/application.h index 55346ab298..4033386010 100644 --- a/krita/plugins/extensions/pykrita/libkis/application.h +++ b/krita/plugins/extensions/pykrita/libkis/application.h @@ -1,18 +1,35 @@ +/* + * Copyright (c) 2014 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_APPLICATION_H #define LIBKIS_APPLICATION_H #include #include class LIBKIS_EXPORT Application : public QObject { Q_OBJECT public: explicit Application(QObject *parent = 0); signals: public slots: }; #endif // LIBKIS_APPLICATION_H diff --git a/krita/plugins/extensions/pykrita/libkis/document.cpp b/krita/plugins/extensions/pykrita/libkis/document.cpp index eacb5d9fcf..dd573f3c1c 100644 --- a/krita/plugins/extensions/pykrita/libkis/document.cpp +++ b/krita/plugins/extensions/pykrita/libkis/document.cpp @@ -1,15 +1,32 @@ +/* + * Copyright (c) 2014 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 "image.h" #include Document::Document(QObject *document, QObject *parent) : QObject(parent) , m_document(qobject_cast(document)) { } Image *Document::image() { return new Image(m_document->image().data(), this); } diff --git a/krita/plugins/extensions/pykrita/libkis/document.h b/krita/plugins/extensions/pykrita/libkis/document.h index fbc4cfc1d6..da1bf2b391 100644 --- a/krita/plugins/extensions/pykrita/libkis/document.h +++ b/krita/plugins/extensions/pykrita/libkis/document.h @@ -1,26 +1,43 @@ +/* + * Copyright (c) 2014 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 class KisDoc2; class Image; class LIBKIS_EXPORT Document : public QObject { Q_OBJECT public: explicit Document(QObject *document, QObject *parent = 0); Image *image(); signals: public slots: private: KisDoc2 *m_document; }; #endif // LIBKIS_DOCUMENT_H diff --git a/krita/plugins/extensions/pykrita/libkis/image.cpp b/krita/plugins/extensions/pykrita/libkis/image.cpp index 83316b0b41..4c7d4f5edb 100644 --- a/krita/plugins/extensions/pykrita/libkis/image.cpp +++ b/krita/plugins/extensions/pykrita/libkis/image.cpp @@ -1,7 +1,24 @@ +/* + * Copyright (c) 2014 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 "image.h" Image::Image(QObject *image, QObject *parent) : QObject(parent) , m_image(qobject_cast(image)) { } diff --git a/krita/plugins/extensions/pykrita/libkis/image.h b/krita/plugins/extensions/pykrita/libkis/image.h index 4f23613608..405cc163f2 100644 --- a/krita/plugins/extensions/pykrita/libkis/image.h +++ b/krita/plugins/extensions/pykrita/libkis/image.h @@ -1,21 +1,38 @@ +/* + * Copyright (c) 2014 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_IMAGE_H #define LIBKIS_IMAGE_H #include #include #include class LIBKIS_EXPORT Image : public QObject { Q_OBJECT public: explicit Image(QObject *image, QObject *parent = 0); signals: public slots: private: KisImageWSP m_image; }; #endif // LIBKIS_IMAGE_H diff --git a/krita/plugins/extensions/pykrita/libkis/krita.cpp b/krita/plugins/extensions/pykrita/libkis/krita.cpp index d12fc7733d..c7a6905914 100644 --- a/krita/plugins/extensions/pykrita/libkis/krita.cpp +++ b/krita/plugins/extensions/pykrita/libkis/krita.cpp @@ -1,60 +1,97 @@ +/* + * Copyright (c) 2014 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 "kis_view2.h" -#include "kis_doc2.h" -#include "kis_image.h" +#include +#include +#include +#include +#include Krita::Krita(QObject *parent) : QObject(parent) { } QList Krita::mainWindows() { QList ret; foreach(KoPart *part, koApp->partList()) { if (part) { foreach(KoMainWindow *mainWin, part->mainWindows()) { ret << new MainWindow(mainWin, this); } } } return ret; } QList Krita::views() { QList ret; foreach(MainWindow *mainWin, mainWindows()) { ret << mainWin->views(); } return ret; } QList Krita::documents() { QList ret; foreach(KoPart *part, koApp->partList()) { if (part) { KisDoc2 *doc = qobject_cast(part->document()); if (doc) { ret << new Document(doc, this); } } } return ret; } QList Krita::images() { QList ret; foreach(Document *doc, documents()) { ret << doc->image(); } return ret; } + +QAction *Krita::createAction(const QString &text) +{ + KisAction *action = new KisAction(text, this); + foreach(KoPart *part, koApp->partList()) { + if (part) { + foreach(KoMainWindow *mainWin, part->mainWindows()) { + if (mainWin && mainWin->rootView()) { + KisView2 *view = qobject_cast(view); + if (view) { + view->scriptManager()->addAction(action); + } + } + } + } + } + return action; +} diff --git a/krita/plugins/extensions/pykrita/libkis/krita.h b/krita/plugins/extensions/pykrita/libkis/krita.h index c04839e1a4..189551ba47 100644 --- a/krita/plugins/extensions/pykrita/libkis/krita.h +++ b/krita/plugins/extensions/pykrita/libkis/krita.h @@ -1,33 +1,53 @@ +/* + * Copyright (c) 2014 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 +#include #include "application.h" #include "mainwindow.h" #include "view.h" #include "document.h" #include "image.h" #include class LIBKIS_EXPORT Krita : public QObject { Q_OBJECT public: explicit Krita(QObject *parent = 0); QList mainWindows(); QList views(); QList documents(); QList images(); + QAction *createAction(const QString &text); + signals: public slots: private: }; #endif // LIBKIS_KRITA_H diff --git a/krita/plugins/extensions/pykrita/libkis/mainwindow.cpp b/krita/plugins/extensions/pykrita/libkis/mainwindow.cpp index 1a7abe7598..8166679d56 100644 --- a/krita/plugins/extensions/pykrita/libkis/mainwindow.cpp +++ b/krita/plugins/extensions/pykrita/libkis/mainwindow.cpp @@ -1,22 +1,39 @@ +/* + * Copyright (c) 2014 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 "mainwindow.h" #include #include #include "view.h" MainWindow::MainWindow(QObject *mainWin, QObject *parent) : QObject(parent) , m_mainWindow(qobject_cast(mainWin)) { } QList MainWindow::views() { QList ret; KisView2 *view = qobject_cast(m_mainWindow->rootView()); if (view) { ret << new View(view, this); } return ret; } diff --git a/krita/plugins/extensions/pykrita/libkis/mainwindow.h b/krita/plugins/extensions/pykrita/libkis/mainwindow.h index 3304859fba..6e06a53dc8 100644 --- a/krita/plugins/extensions/pykrita/libkis/mainwindow.h +++ b/krita/plugins/extensions/pykrita/libkis/mainwindow.h @@ -1,27 +1,44 @@ +/* + * Copyright (c) 2014 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_MAINWINDOW_H #define LIBKIS_MAINWINDOW_H #include #include class KoMainWindow; #include class LIBKIS_EXPORT MainWindow : public QObject { Q_OBJECT public: explicit MainWindow(QObject *mainWin, QObject *parent = 0); QList views(); signals: public slots: private: KoMainWindow *m_mainWindow; }; #endif // MAINWINDOW_H diff --git a/krita/plugins/extensions/pykrita/libkis/node.cpp b/krita/plugins/extensions/pykrita/libkis/node.cpp index d46273dc62..35c2c60330 100644 --- a/krita/plugins/extensions/pykrita/libkis/node.cpp +++ b/krita/plugins/extensions/pykrita/libkis/node.cpp @@ -1,6 +1,23 @@ +/* + * Copyright (c) 2014 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" Node::Node(QObject *parent) : QObject(parent) { } diff --git a/krita/plugins/extensions/pykrita/libkis/node.h b/krita/plugins/extensions/pykrita/libkis/node.h index d5d70541cf..2df7714f35 100644 --- a/krita/plugins/extensions/pykrita/libkis/node.h +++ b/krita/plugins/extensions/pykrita/libkis/node.h @@ -1,20 +1,37 @@ +/* + * Copyright (c) 2014 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 class LIBKIS_EXPORT Node : public QObject { Q_OBJECT public: explicit Node(QObject *parent = 0); signals: public slots: }; #endif // LIBKIS_NODE_H diff --git a/krita/plugins/extensions/pykrita/libkis/view.cpp b/krita/plugins/extensions/pykrita/libkis/view.cpp index 90d1084212..09ca6999af 100644 --- a/krita/plugins/extensions/pykrita/libkis/view.cpp +++ b/krita/plugins/extensions/pykrita/libkis/view.cpp @@ -1,9 +1,26 @@ +/* + * Copyright (c) 2014 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 "view.h" #include View::View(QObject *view, QObject *parent) : QObject(parent) , m_view(qobject_cast(view)) { } diff --git a/krita/plugins/extensions/pykrita/libkis/view.h b/krita/plugins/extensions/pykrita/libkis/view.h index b76069e093..f2ecdefd07 100644 --- a/krita/plugins/extensions/pykrita/libkis/view.h +++ b/krita/plugins/extensions/pykrita/libkis/view.h @@ -1,26 +1,43 @@ +/* + * Copyright (c) 2014 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_VIEW_H #define LIBKIS_VIEW_H #include #include class KisView2; class LIBKIS_EXPORT View : public QObject { Q_OBJECT public: explicit View(QObject *view, QObject *parent = 0); signals: public slots: private: KisView2 *m_view; }; #endif // LIBKIS_VIEW_H diff --git a/krita/plugins/extensions/pykrita/sip/krita/krita.sip b/krita/plugins/extensions/pykrita/sip/krita/krita.sip index 9a7d30ecfd..26d3f69f0e 100644 --- a/krita/plugins/extensions/pykrita/sip/krita/krita.sip +++ b/krita/plugins/extensions/pykrita/sip/krita/krita.sip @@ -1,19 +1,20 @@ %Import QtCore/QtCoremod.sip %Import QtGui/QtGuimod.sip class Krita : public QObject { %TypeHeaderCode #include "krita.h" %End public: Krita(QObject *parent /TransferThis/ = 0); QList mainWindows(); QList views(); QList documents(); QList images(); + QAction *createAction(const QString &text); };