[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [calligra/krita-scripting-rempt] krita: Add a method to add scripts to a scripting menu.
From: Boudewijn Rempt <boud () valdyas ! org>
Date: 2014-07-31 6:24:27
Message-ID: E1XCjmt-00064k-TH () scm ! kde ! org
[Download RAW message or body]
Git commit 8369baf95d865985ad0a6fd8d9fa8e7df8fe82e2 by Boudewijn Rempt.
Committed on 30/07/2014 at 14:54.
Pushed by rempt into branch 'krita-scripting-rempt'.
Add a method to add scripts to a scripting menu.
M +3 -1 krita/krita.rc
M +17 -0 krita/plugins/extensions/pykrita/libkis/application.cpp
M +17 -0 krita/plugins/extensions/pykrita/libkis/application.h
M +17 -0 krita/plugins/extensions/pykrita/libkis/document.cpp
M +17 -0 krita/plugins/extensions/pykrita/libkis/document.h
M +17 -0 krita/plugins/extensions/pykrita/libkis/image.cpp
M +17 -0 krita/plugins/extensions/pykrita/libkis/image.h
M +40 -3 krita/plugins/extensions/pykrita/libkis/krita.cpp
M +20 -0 krita/plugins/extensions/pykrita/libkis/krita.h
M +17 -0 krita/plugins/extensions/pykrita/libkis/mainwindow.cpp
M +17 -0 krita/plugins/extensions/pykrita/libkis/mainwindow.h
M +17 -0 krita/plugins/extensions/pykrita/libkis/node.cpp
M +17 -0 krita/plugins/extensions/pykrita/libkis/node.h
M +17 -0 krita/plugins/extensions/pykrita/libkis/view.cpp
M +17 -0 krita/plugins/extensions/pykrita/libkis/view.h
M +1 -0 krita/plugins/extensions/pykrita/sip/krita/krita.sip
M +1 -0 krita/ui/CMakeLists.txt
M +12 -8 krita/ui/kis_action.h
A +84 -0 krita/ui/kis_script_manager.cpp [License: LGPL (v2+)]
A +48 -0 krita/ui/kis_script_manager.h [License: LGPL (v2+)]
M +13 -1 krita/ui/kis_view2.cpp
M +3 -0 krita/ui/kis_view2.h
http://commits.kde.org/calligra/8369baf95d865985ad0a6fd8d9fa8e7df8fe82e2
diff --git a/krita/krita.rc b/krita/krita.rc
index 50faa31..b5b636e 100644
--- a/krita/krita.rc
+++ b/krita/krita.rc
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<!DOCTYPE kpartgui SYSTEM "kpartgui.dtd">
-<kpartgui name="Krita" version="52">
+<kpartgui name="Krita" version="53">
<MenuBar>
<Menu name="file"><text>&File</text>
@@ -159,6 +159,8 @@
<Menu name="Tools"><text>&Tools</text>
</Menu>
+<Action name="scripts"/>
+
<Menu name="settings"><text>Settings</text>
<!--Action name="view_fullscreen" group="settings_show"/-->
<Action name="view_toggledockers" group="settings_show"/>
diff --git a/krita/plugins/extensions/pykrita/libkis/application.cpp \
b/krita/plugins/extensions/pykrita/libkis/application.cpp index bc646d1..1ef9ba9 \
100644
--- a/krita/plugins/extensions/pykrita/libkis/application.cpp
+++ b/krita/plugins/extensions/pykrita/libkis/application.cpp
@@ -1,3 +1,20 @@
+/*
+ * Copyright (c) 2014 Boudewijn Rempt <boud@valdyas.org>
+ *
+ * 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) :
diff --git a/krita/plugins/extensions/pykrita/libkis/application.h \
b/krita/plugins/extensions/pykrita/libkis/application.h index 55346ab..4033386 100644
--- a/krita/plugins/extensions/pykrita/libkis/application.h
+++ b/krita/plugins/extensions/pykrita/libkis/application.h
@@ -1,3 +1,20 @@
+/*
+ * Copyright (c) 2014 Boudewijn Rempt <boud@valdyas.org>
+ *
+ * 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
diff --git a/krita/plugins/extensions/pykrita/libkis/document.cpp \
b/krita/plugins/extensions/pykrita/libkis/document.cpp index eacb5d9..dd573f3 100644
--- a/krita/plugins/extensions/pykrita/libkis/document.cpp
+++ b/krita/plugins/extensions/pykrita/libkis/document.cpp
@@ -1,3 +1,20 @@
+/*
+ * Copyright (c) 2014 Boudewijn Rempt <boud@valdyas.org>
+ *
+ * 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"
diff --git a/krita/plugins/extensions/pykrita/libkis/document.h \
b/krita/plugins/extensions/pykrita/libkis/document.h index fbc4cfc..da1bf2b 100644
--- a/krita/plugins/extensions/pykrita/libkis/document.h
+++ b/krita/plugins/extensions/pykrita/libkis/document.h
@@ -1,3 +1,20 @@
+/*
+ * Copyright (c) 2014 Boudewijn Rempt <boud@valdyas.org>
+ *
+ * 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
diff --git a/krita/plugins/extensions/pykrita/libkis/image.cpp \
b/krita/plugins/extensions/pykrita/libkis/image.cpp index 83316b0..4c7d4f5 100644
--- a/krita/plugins/extensions/pykrita/libkis/image.cpp
+++ b/krita/plugins/extensions/pykrita/libkis/image.cpp
@@ -1,3 +1,20 @@
+/*
+ * Copyright (c) 2014 Boudewijn Rempt <boud@valdyas.org>
+ *
+ * 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)
diff --git a/krita/plugins/extensions/pykrita/libkis/image.h \
b/krita/plugins/extensions/pykrita/libkis/image.h index 4f23613..405cc16 100644
--- a/krita/plugins/extensions/pykrita/libkis/image.h
+++ b/krita/plugins/extensions/pykrita/libkis/image.h
@@ -1,3 +1,20 @@
+/*
+ * Copyright (c) 2014 Boudewijn Rempt <boud@valdyas.org>
+ *
+ * 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
diff --git a/krita/plugins/extensions/pykrita/libkis/krita.cpp \
b/krita/plugins/extensions/pykrita/libkis/krita.cpp index d12fc77..c7a6905 100644
--- a/krita/plugins/extensions/pykrita/libkis/krita.cpp
+++ b/krita/plugins/extensions/pykrita/libkis/krita.cpp
@@ -1,12 +1,31 @@
+/*
+ * Copyright (c) 2014 Boudewijn Rempt <boud@valdyas.org>
+ *
+ * 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 <KoApplication.h>
#include <KoPart.h>
#include <KoMainWindow.h>
-#include "kis_view2.h"
-#include "kis_doc2.h"
-#include "kis_image.h"
+#include <kis_view2.h>
+#include <kis_doc2.h>
+#include <kis_image.h>
+#include <kis_action.h>
+#include <kis_script_manager.h>
Krita::Krita(QObject *parent) :
QObject(parent)
@@ -58,3 +77,21 @@ QList<Image *> Krita::images()
}
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<KisView2*>(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 c04839e..189551b 100644
--- a/krita/plugins/extensions/pykrita/libkis/krita.h
+++ b/krita/plugins/extensions/pykrita/libkis/krita.h
@@ -1,8 +1,26 @@
+/*
+ * Copyright (c) 2014 Boudewijn Rempt <boud@valdyas.org>
+ *
+ * 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 <QObject>
#include <QPointer>
+#include <QAction>
#include "application.h"
#include "mainwindow.h"
@@ -23,6 +41,8 @@ public:
QList<Document*> documents();
QList<Image*> images();
+ QAction *createAction(const QString &text);
+
signals:
public slots:
diff --git a/krita/plugins/extensions/pykrita/libkis/mainwindow.cpp \
b/krita/plugins/extensions/pykrita/libkis/mainwindow.cpp index 1a7abe7..8166679 \
100644
--- a/krita/plugins/extensions/pykrita/libkis/mainwindow.cpp
+++ b/krita/plugins/extensions/pykrita/libkis/mainwindow.cpp
@@ -1,3 +1,20 @@
+/*
+ * Copyright (c) 2014 Boudewijn Rempt <boud@valdyas.org>
+ *
+ * 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 <KoMainWindow.h>
diff --git a/krita/plugins/extensions/pykrita/libkis/mainwindow.h \
b/krita/plugins/extensions/pykrita/libkis/mainwindow.h index 3304859..6e06a53 100644
--- a/krita/plugins/extensions/pykrita/libkis/mainwindow.h
+++ b/krita/plugins/extensions/pykrita/libkis/mainwindow.h
@@ -1,3 +1,20 @@
+/*
+ * Copyright (c) 2014 Boudewijn Rempt <boud@valdyas.org>
+ *
+ * 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
diff --git a/krita/plugins/extensions/pykrita/libkis/node.cpp \
b/krita/plugins/extensions/pykrita/libkis/node.cpp index d46273d..35c2c60 100644
--- a/krita/plugins/extensions/pykrita/libkis/node.cpp
+++ b/krita/plugins/extensions/pykrita/libkis/node.cpp
@@ -1,3 +1,20 @@
+/*
+ * Copyright (c) 2014 Boudewijn Rempt <boud@valdyas.org>
+ *
+ * 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) :
diff --git a/krita/plugins/extensions/pykrita/libkis/node.h \
b/krita/plugins/extensions/pykrita/libkis/node.h index d5d7054..2df7714 100644
--- a/krita/plugins/extensions/pykrita/libkis/node.h
+++ b/krita/plugins/extensions/pykrita/libkis/node.h
@@ -1,3 +1,20 @@
+/*
+ * Copyright (c) 2014 Boudewijn Rempt <boud@valdyas.org>
+ *
+ * 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
diff --git a/krita/plugins/extensions/pykrita/libkis/view.cpp \
b/krita/plugins/extensions/pykrita/libkis/view.cpp index 90d1084..09ca699 100644
--- a/krita/plugins/extensions/pykrita/libkis/view.cpp
+++ b/krita/plugins/extensions/pykrita/libkis/view.cpp
@@ -1,3 +1,20 @@
+/*
+ * Copyright (c) 2014 Boudewijn Rempt <boud@valdyas.org>
+ *
+ * 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 <kis_view2.h>
diff --git a/krita/plugins/extensions/pykrita/libkis/view.h \
b/krita/plugins/extensions/pykrita/libkis/view.h index b76069e..f2ecdef 100644
--- a/krita/plugins/extensions/pykrita/libkis/view.h
+++ b/krita/plugins/extensions/pykrita/libkis/view.h
@@ -1,3 +1,20 @@
+/*
+ * Copyright (c) 2014 Boudewijn Rempt <boud@valdyas.org>
+ *
+ * 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
diff --git a/krita/plugins/extensions/pykrita/sip/krita/krita.sip \
b/krita/plugins/extensions/pykrita/sip/krita/krita.sip index 9a7d30e..26d3f69 100644
--- a/krita/plugins/extensions/pykrita/sip/krita/krita.sip
+++ b/krita/plugins/extensions/pykrita/sip/krita/krita.sip
@@ -15,5 +15,6 @@ public:
QList<Document*> documents();
QList<Image*> images();
+ QAction *createAction(const QString &text);
};
diff --git a/krita/ui/CMakeLists.txt b/krita/ui/CMakeLists.txt
index 031efc0..6187c97 100644
--- a/krita/ui/CMakeLists.txt
+++ b/krita/ui/CMakeLists.txt
@@ -115,6 +115,7 @@ set(kritaui_LIB_SRCS
kis_png_converter.cpp
kis_preference_set_registry.cpp
kis_print_job.cpp
+ kis_script_manager.cpp
kis_resource_server_provider.cpp
kis_selection_decoration.cc
kis_selection_manager.cc
diff --git a/krita/ui/kis_action.h b/krita/ui/kis_action.h
index 18cca90..53b38f2 100644
--- a/krita/ui/kis_action.h
+++ b/krita/ui/kis_action.h
@@ -67,14 +67,9 @@ public:
virtual void setActionEnabled(bool enabled);
- /**
- * Set the action manager. Only used by KisActionManager
- */
- void setActionManager(KisActionManager* actionManager);
-
- /**
- * Set operation id. This will used to run an operation in the KisActionManager
- */
+ /**
+ * Set operation id. This will used to run an operation in the KisActionManager
+ */
void setOperationID(const QString& id);
signals:
@@ -85,6 +80,15 @@ private slots:
void slotChanged();
private:
+
+ friend class KisActionManager;
+ /**
+ * Set the action manager. Only used by KisActionManager
+ */
+ void setActionManager(KisActionManager* actionManager);
+
+
+private:
class Private;
Private* const d;
};
diff --git a/krita/ui/kis_script_manager.cpp b/krita/ui/kis_script_manager.cpp
new file mode 100644
index 0000000..b293bdb
--- /dev/null
+++ b/krita/ui/kis_script_manager.cpp
@@ -0,0 +1,84 @@
+/*
+ * Copyright (c) 2014 Boudewijn Rempt <boud@valdyas.org>
+ *
+ * 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 "kis_script_manager.h"
+
+#include <klocale.h>
+#include <kaction.h>
+#include <kactionmenu.h>
+#include <kactioncollection.h>
+
+#include "kis_view2.h"
+
+struct KisScriptManager::Private {
+ Private()
+ : actionCollection(0)
+ , view(0)
+ , scriptMenu(0)
+ {
+ }
+
+ QHash<KisFilter*, KAction*> script2Action;
+
+ KActionCollection *actionCollection;
+ KisView2 *view;
+ KActionMenu *scriptMenu;
+};
+
+
+KisScriptManager::KisScriptManager(KisView2 *view)
+ : QObject(view)
+ , d(new Private())
+{
+ d->view = view;
+ d->actionCollection = view->actionCollection();
+ d->scriptMenu = new KActionMenu(i18n("Scripts"),this);
+ d->actionCollection->addAction("scripting", d->scriptMenu);
+}
+
+KisScriptManager::~KisScriptManager()
+{
+ delete d;
+}
+
+
+void KisScriptManager::setup(KActionCollection * ac)
+{
+ d->actionCollection = ac;
+}
+
+void KisScriptManager::updateGUI()
+{
+ if (!d->view) return;
+
+// bool enable = false;
+
+// KisNodeSP activeNode = d->view->activeNode();
+// enable = activeNode && activeNode->hasEditablePaintDevice();
+
+// d->reapplyAction->setEnabled(enable);
+
+// foreach(KAction *action, d->script2Action.values()) {
+// action->setEnabled(enable);
+ // }
+}
+
+void KisScriptManager::addAction(QAction *action)
+{
+ d->scriptMenu->addAction(action);
+}
diff --git a/krita/ui/kis_script_manager.h b/krita/ui/kis_script_manager.h
new file mode 100644
index 0000000..4ea4e0d
--- /dev/null
+++ b/krita/ui/kis_script_manager.h
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2014 Boudewijn Rempt <boud@valdyas.org>
+ *
+ * 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 KIS_SCRIPT_MANAGER_H
+#define KIS_SCRIPT_MANAGER_H
+
+#include <QObject>
+
+#include <krita_export.h>
+
+class QAction;
+
+class KisView2;
+class KActionCollection;
+
+class KRITAUI_EXPORT KisScriptManager : public QObject
+{
+ Q_OBJECT
+public:
+ explicit KisScriptManager(KisView2 * view);
+ ~KisScriptManager();
+
+ void setup(KActionCollection * ac);
+ void updateGUI();
+
+ void addAction(QAction *action);
+
+private:
+ struct Private;
+ Private * const d;
+};
+
+#endif // KIS_SCRIPT_MANAGER_H
diff --git a/krita/ui/kis_view2.cpp b/krita/ui/kis_view2.cpp
index a5e7c67..32f18fc 100644
--- a/krita/ui/kis_view2.cpp
+++ b/krita/ui/kis_view2.cpp
@@ -134,6 +134,8 @@
#include "kis_tooltip_manager.h"
#include <kis_tool_freehand.h>
+#include "kis_script_manager.h"
+
class BlockingUserInputEventFilter : public QObject
{
bool eventFilter(QObject *watched, QEvent *event)
@@ -175,6 +177,7 @@ public:
, mainWindow(0)
, tooltipManager(0)
, showFloatingMessage(true)
+ , scriptManager(0)
{
}
@@ -199,7 +202,7 @@ public:
delete actionManager;
delete canvasControlsManager;
delete tooltipManager;
-
+ delete scriptManager;
/**
* Push a timebomb, which will try to release the memory after
* the document has been deleted
@@ -237,6 +240,7 @@ public:
KisTooltipManager* tooltipManager;
QPointer<KisFloatingMessage> savedFloatingMessage;
bool showFloatingMessage;
+ KisScriptManager *scriptManager;
};
@@ -1071,6 +1075,9 @@ void KisView2::createManagers()
m_d->mirrorAxis = new KisMirrorAxis(m_d->resourceProvider, this);
m_d->canvas->addDecoration(m_d->mirrorAxis);
+
+ m_d->scriptManager = new KisScriptManager(this);
+ m_d->scriptManager->setup(actionCollection());
}
void KisView2::updateGUI()
@@ -1205,6 +1212,11 @@ KisDoc2 * KisView2::document() const
return m_d->doc;
}
+KisScriptManager *KisView2::scriptManager() const
+{
+ return m_d->scriptManager;
+}
+
KoPrintJob * KisView2::createPrintJob()
{
return new KisPrintJob(image());
diff --git a/krita/ui/kis_view2.h b/krita/ui/kis_view2.h
index 278a9ff..cbcca4e 100644
--- a/krita/ui/kis_view2.h
+++ b/krita/ui/kis_view2.h
@@ -57,6 +57,7 @@ class KisPaintopBox;
class KisCanvasController;
class KisFlipbook;
class KisActionManager;
+class KisScriptManager;
/**
* Krita view class
@@ -170,6 +171,8 @@ public: // Krita specific interfaces
KisDoc2* document() const;
+ KisScriptManager *scriptManager() const;
+
public:
virtual KoPrintJob * createPrintJob();
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic