Skip to content

armgit / krita

Public Imported from GitHub
0

Krita is a free and open source cross-platform application that offers an end-to-end solution for creating digital art files from scratch built on the KDE and Qt frameworks.

C++

Expose tool and brush change signals to PyKrita

Moritz Staudinger8bc70c18d720
diff --git a/libs/libkis/View.cpp b/libs/libkis/View.cpp
index 0b9cd78191..bba35533e1 100644
--- a/libs/libkis/View.cpp
+++ b/libs/libkis/View.cpp
@@ -18,6 +18,7 @@
#include <kis_paintop_box.h>
#include <KisMainWindow.h>
#include <KoCanvasBase.h>
+#include <KoToolProxy.h>
#include <kis_canvas2.h>
#include <KisResourceTypes.h>
#include <KisDocument.h>
@@ -40,6 +41,12 @@ View::View(KisView* view, QObject *parent)
, d(new Private)
{
d->view = view;
+ if (d->view) {
+ if (KoToolProxy *toolProxy = d->view->canvasBase()->toolProxy()) {
+ connect(toolProxy, SIGNAL(toolChanged(QString)), this, SIGNAL(currentToolChanged(QString)));
+ }
+ connect(d->view->resourceProvider(), SIGNAL(sigPaintOpPresetChanged(KisPaintOpPresetSP)), this, SIGNAL(currentBrushPresetChanged()));
+ }
}
View::~View()
diff --git a/libs/libkis/View.h b/libs/libkis/View.h
index 282c9c3ac6..932c76a62c 100644
--- a/libs/libkis/View.h
+++ b/libs/libkis/View.h
@@ -356,6 +356,28 @@ print(selected_nodes)
*/
QTransform flakeToImageTransform() const;
+Q_SIGNALS:
+ /**
+ * Emitted when the active tool for this view changes.
+ *
+ * @param toolId the identifier of the new active tool.
+ */
+ void currentToolChanged(const QString &toolId);
+
+ /**
+ * Emitted when the current brush preset for this view changes.
+ */
+ void currentBrushPresetChanged();
+
+ /**
+ * Emitted when this view's foreground color changes.
+ */
+ void foregroundColorChanged();
+
+ /**
+ * Emitted when this view's background color changes.
+ */
+ void backgroundColorChanged();
private:
friend class Window;
diff --git a/plugins/extensions/pykrita/sip/krita/View.sip b/plugins/extensions/pykrita/sip/krita/View.sip
index 053c6cb38e..399e9e049b 100644
--- a/plugins/extensions/pykrita/sip/krita/View.sip
+++ b/plugins/extensions/pykrita/sip/krita/View.sip
@@ -87,5 +87,10 @@ public Q_SLOTS:
QTransform flakeToDocumentTransform() const;
QTransform flakeToCanvasTransform() const;
QTransform flakeToImageTransform() const;
+Q_SIGNALS:
+ void currentToolChanged(const QString &toolId);
+ void currentBrushPresetChanged();
+ void foregroundColorChanged();
+ void backgroundColorChanged();
private:
};