Krita 5.0 & animation docker

That’s possible :slight_smile:

But, I don’t know if solution could be accepted…

The trick is to implement event filter.

Example made with a python plugin:

Save content to ~/.local/share/krita/pykrita/keycatcherdocker/__init__.py

from krita import *
from PyQt5.Qt import *

class KeyCatcherDocker(DockWidget):
    """Class to manage current selection"""

    def __init__(self):
        super(KeyCatcherDocker, self).__init__()

        self.__installed=False
        self.setWindowTitle("Key Catcher")
        self.__lbl=QLabel('[Waiting to catch key]')
        self.setWidget(self.__lbl)

    def canvasChanged(self, canvas):
        """Notify when views are added or removed"""
        if not self.__installed:
            if Krita.instance().activeWindow():
                # I'm very lazy too implement a better solution for this exemple
                # for testing, just initialise catcher once a view has been created
                w=Krita.instance().activeWindow().qwindow()
                w.installEventFilter(self)
                self.__installed=True

    def eventFilter(self, source, event):
        if isinstance(event, QKeyEvent):
            if event.type()==QEvent.KeyRelease:
                self.__lbl.setText("[Waiting to catch key]")
            else:
                modifiers=[]
                if int(event.modifiers()) & Qt.ControlModifier == Qt.ControlModifier:
                    modifiers.append('CTRL')
                if int(event.modifiers()) & Qt.ShiftModifier == Qt.ShiftModifier:
                    modifiers.append('SHIFT')
                if int(event.modifiers()) & Qt.AltModifier == Qt.AltModifier:
                    modifiers.append('ALT')
                
                if len(modifiers)>0:
                    self.__lbl.setText(f"Key({event.key()}) {' '.join(modifiers)}")
                else:
                    self.__lbl.setText(f"Key({event.key()})")    
                
                print("Key event", event.key(), event.type())
            return False
        else:
          return QObject.eventFilter(self, source, event)

testKeyCatcherDocker = DockWidgetFactory(f'Test_KeyCatcherDocker',
                                    DockWidgetFactoryBase.DockRight,
                                    KeyCatcherDocker)
Krita.instance().addDockWidgetFactory(testKeyCatcherDocker)

Save content to ~/.local/share/krita/pykrita/keycatcherdocker.desktop

[Desktop Entry]
Type=Service
ServiceTypes=Krita/PythonPlugin
X-KDE-Library=keycatcherdocker
X-Python-2-Compatible=false
X-Krita-Manual=Manual.html
Name=KeyCatcherDocker
Comment=testing key catching

Install plugin/restart Krita

Example of docker catching keys while I’m drawing:

  • It catch key event but doesn’t stop/modify: shortcut and all other based key function will continue to work
  • Catch keys even if docker don’t have focus

Notes: Plugin written in quick&dirty mode, sorry, especially for initialization part…

That’s my preferred solution
:heart_eyes:

But I gave you tip if you really prefer the solution of CTRL key :wink:

Grum999

3 Likes

Oh nice! I’m not sure I should be installing an event filter on the window for this purpose though.

I think the best thing to do is just include the buttons, since I don’t want to over-complicate things too much. :slight_smile:

1 Like

The solution with ctrl key wouldn’t work with a tablet. Also it is not very discoverable.
I leave some ideas:

  • Maybe a dropdown button to the right to select from different configurations of buttons.
  • Can a configurable toolbar be put there?
  • Double click in the button to go to the next keyframe, and maybe 3 clicks to go to the end (although this is not discoverable and would prevent fast advance to ne next frames).
  • Press/drag left/release to go next keyframe. This also is not fast if you want to quickly advance various keyframes.

Simplest things are sometime the best :slight_smile:

That’s right…
I’m wondering how Krita currently work with a tablet… :thinking:
I always use CTRL and SHIFT as modifiers when drawing :upside_down_face:

Maybe the best option for me; being able to choose the best layout configuration that match how I use it…

Other ideas are some workaround to access functionalities but not very efficient in use I think.

Grum999

1 Like

This plugin can be repurposed into a docker which shows key presses and clicks like the “Keymon” application on Linux but inbuilt with Krita. This can be really helpful to time-lapse recording and tutorials etc.

Such a big function should not be hidden in a ctrl key yeah. I am glad you guys came to that conclusion.

1 Like