From ca7e23db7c0ab6c1b66fc8d5da2aa070e552561e Mon Sep 17 00:00:00 2001
From: Jiri Kalvoda <jirikalvoda@kam.mff.cuni.cz>
Date: Sun, 28 Aug 2022 12:27:58 +0200
Subject: [PATCH] Qt: Tree show opening brackets

---
 woman/qt.py      |  2 +-
 woman/qt_util.py | 17 +++++++++++++++++
 2 files changed, 18 insertions(+), 1 deletion(-)

diff --git a/woman/qt.py b/woman/qt.py
index 0e63b29..cf301b6 100755
--- a/woman/qt.py
+++ b/woman/qt.py
@@ -399,7 +399,7 @@ def qt_main():
         def __init__(self, t, workspace_widget, is_root, parent=None):
             super().__init__(t, workspace_widget, is_root, parent)
             self._hlay = no_space(QHBoxLayout(self))
-            self._head = QLabel(self)
+            self._head = QLabelOpeningBracket(self)
             self._list = no_space(QVBoxLayout())
 
             self.setAutoFillBackground(True)
diff --git a/woman/qt_util.py b/woman/qt_util.py
index b0a018b..895eff9 100644
--- a/woman/qt_util.py
+++ b/woman/qt_util.py
@@ -339,3 +339,20 @@ def key_to_str(key, mod):
         if mod & Qt.ShiftModifier != 0:
             c.upper()
     return c
+
+class QLabelOpeningBracket(QLabel):
+    @qtoverride
+    def paintEvent(self, event):
+        super().paintEvent(event)
+        painter = QPainter(self)
+
+        x = self.width()
+        y = self.height()
+        line_x = x//3
+        text_h = 12
+        padding = 3
+        if y > text_h + 2*padding:
+            painter.drawLine(line_x, padding, x-2, padding)
+            painter.drawLine(line_x, padding, line_x, y//2-text_h//2)
+            painter.drawLine(line_x, y-1-padding, line_x, y//2+text_h//2)
+            painter.drawLine(line_x, y-1-padding, x-2, y-1-padding)
-- 
GitLab