Layers - collapse all at once?

Krita 5.2.9, 5.3, 6.0 on Windows 11.

Is there a Krita action that collapses all layers at once?

Sometimes I loose the overview of Layers, Filters, Masks, Groups and just like to collapse them all for a fresh start.

I am asking for an action because I could add that to a button.

Found a thread from 2020 saying it is not possible, but am not sure if this is valid anymore.

Seems like it should be doable with a script and then bind it to a key with TenScripts. I don’t have a solution off hand, however.

Definitely use tenscripts, make a duplicate of this and edit that True/False value for each. From Mistral with some edits.

from krita import Krita

def collapse_all_nodes(collapse=False):
    app = Krita.instance()
    doc = app.activeDocument()
    if doc:
        # Function to iterate over nodes and set them to be collapsed
        def set_nodes_collapsed(node):
            node.setCollapsed(collapse)

            for child_node in node.childNodes():
                set_nodes_collapsed(child_node)

        for top_level_node in doc.topLevelNodes():
            set_nodes_collapsed(top_level_node)
    else:
        print("No active document found.")

collapse_all_nodes(True) #set to True or False

Thank you :folded_hands: :heart_eyes: :+1:

It works; I put it in my toolbox.

A quick additional question, what method are you using to maintain this side bar with actions as icon buttons? Does it require a plugin or is it a combination of built-in features Krita has? Thanks.

I found it in 5.3 prealpha