-
Halla Rempt authored
Note that this changes the libkis scripting api. The Extension class now has two methods: setup and createActions. Old code was like this: from PyQt5.QtGui import * from PyQt5.QtWidgets import * from krita import * def hello(): QMessageBox.information(QWidget(), "Test", "Hello World") class HelloExtension(Extension): def __init__(self, parent): super().__init__(parent) def setup(self): action = Krita.createAction("Hello") action.triggered.connect(hello) Krita.instance().addExtension(HelloExtension(Krita.instance())) New code is like this: from PyQt5.QtGui import * from PyQt5.QtWidgets import * from krita import * def hello(): QMessageBox.information(QWidget(), "Test", "Hello World") class HelloExtension(Extension): def __init__(self, parent): super().__init__(parent) def setup(self): pass def createActions(self, window): action = window.createAction("Hello") action.triggered.connect(hello) Krita.instance().addExtension(HelloExtension(Krita.instance())) This also adds a new parameter to createAction: the menu location. This is a path separated by /, for instance tools/scripts. Note that this path must exist, otherwise a crash will happen. The paths are defined in krita4.xmlgui... BUG:391705 Note: we're still leaking Action objects created in Window::createAction; that's the next fix. CCMAIL:kimageshop@kde.org (cherry picked from commit e9b06616)
3de294bc