Diffusion Krita e9b0661657f6

Create actions per-window instead of per-application

Authored by rempt on Mar 14 2018, 1:20 PM.

Description

Create actions per-window instead of per-application

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

Details

Committed
remptMar 14 2018, 1:24 PM
Parents
R37:aeb753e41d1a: Fix animation cache regeneration being stuck in the middle of recalculation
Branches
Unknown
Tags
Unknown