Diffusion Krita 3de294bc4643

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
(cherry picked from commit e9b0661657f67ac4d1186641a78357f695a9a717)

Details

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