I’m customizing the appearance of Krita (it’s lovely but claustrophobic!) and one panel I can’t fully get to is the layer panel. I’d love to alter the size of the icons (lock, alpha, visbility, etc) or even the icons themselves and change the appearance of selected layers row.
It’s possible to change the appearance of all rows at once through css (QTreeView::item), of folder rows (QTreeView::item:has-children), and of the middle column containing layer name and type icon of selected layers (QTreeView::item:selected), but not the complete row of selected layers (containing also the vis icon and the other icons at the end) nor the icons themselves.
Through Qt I managed to access to the layer name and icon of the layer type but that’s about it. Models, styles, delegates for QTreeView are above my pay grade.
I’ve got this so far (please don’t judge, still testing what can be done before deciding on the design):
I couldn’t find a way to apply the intended fixes: reduce icons sizes and access and apply the original layer color when there’s one (css inherit doesn’t work, nor transparent which is used in the example). And because I can’t access the full row I can’t try out different ways to highlight a selected layer like applying a continuous border because it’ll stop at the middle column without including the visibility column.
Thanks to the current worsening of search engines I was struggling to find clear examples of how to re-implement delegates, and in hindsight I should have searched for “QTreeView” here at krita-artists instead of keyword combinations about styling layers.
I’ve modified your example to hijack the QAbstractItemDelegate and peek into what it’s doing to get an insight on modifying the target elements.
I’ll post the resulting code for the posterity when I figure it out.
I’ve spent a little more time working on the layer docker. Because all relevant methods used in the paint method are C++ I had to convert them to python code to re-implement them.
It’s a lot of work but I’m very pleased with how it’s coming along, I could even change the icons to a small-but-readable set (thanks Blender!).
The major hindrance is an inaccessible QModelIndex.data() value, the KisNodeModel::PropertiesRole. It returns a KisBaseNode::PropertyList storing values like inherit alpha and opacity lock states, but whatever is in that prop list it’s pure C++, python throws an error when I try to read it.
I might be able to lift the values from elsewhere in the GUI, but I’d rather not.
And a minor inconvenience is the weird “z-index” of some elements. No matter what the visibility icon is always drawn before and under the middle column with name and thumbnail, which is an issue because states like selected are only informed by that column, so I’m just stretching its rect to cover everything and it ends up eating the poor icon.