@@ -25,6 +25,7 @@ def __init__(self, window=None):
25
25
self .active_idx = 0
26
26
self .prev_idx = 0
27
27
self .initialized = False
28
+ self .appended = False
28
29
self .current = 0
29
30
30
31
def setup (self ):
@@ -52,14 +53,9 @@ def append(self, type: int, idx: int):
52
53
:param type: Tab type
53
54
:param idx: Tab index
54
55
"""
55
- meta = None
56
+ self . appended = True # lock reload in previous tab
56
57
self .window .core .tabs .append (type , idx )
57
- if type == Tab .TAB_CHAT :
58
- meta = self .window .controller .ctx .new () # new context
59
58
self .switch_tab_by_idx (idx + 1 ) # switch to new tab
60
- if type == Tab .TAB_CHAT :
61
- if meta is not None :
62
- self .window .controller .ctx .load (meta .id ) # reload
63
59
64
60
def reload_titles (self ):
65
61
"""Reload tab titles"""
@@ -77,7 +73,6 @@ def reload_after(self):
77
73
self .switch_tab (Tab .TAB_CHAT )
78
74
self .window .controller .ctx .load_first ()
79
75
80
-
81
76
def on_tab_changed (self , idx : int ):
82
77
"""
83
78
Output tab changed
@@ -86,8 +81,16 @@ def on_tab_changed(self, idx: int):
86
81
"""
87
82
tab = self .window .core .tabs .get_tab_by_index (idx )
88
83
if tab is None :
84
+ self .appended = False
89
85
return
90
86
87
+ if self .appended :
88
+ self .appended = False
89
+ if tab .type == Tab .TAB_CHAT :
90
+ meta = self .window .controller .ctx .new () # new context
91
+ if meta is not None :
92
+ self .window .controller .ctx .load (meta .id ) # reload
93
+
91
94
prev_tab = self .current
92
95
self .current = idx
93
96
self .window .controller .ui .mode .update ()
@@ -96,23 +99,15 @@ def on_tab_changed(self, idx: int):
96
99
# check type
97
100
if tab .type == Tab .TAB_NOTEPAD :
98
101
self .window .controller .notepad .opened_once = True
99
- if tab .type == Tab .TAB_CHAT :
100
- ctx_meta = self .window .core .ctx .current
102
+ elif tab .type == Tab .TAB_CHAT :
101
103
pid_meta = self .window .core .ctx .output .get_meta (tab .pid )
102
- if ctx_meta != pid_meta and pid_meta is not None :
103
- if self .get_type_by_idx (prev_tab ) == Tab .TAB_CHAT :
104
- self .window .controller .ctx .load (pid_meta ) # only if switching between chat tabs
105
- else :
106
- curr_pid = tab .pid
107
- meta = self .window .core .ctx .get_meta_by_id (ctx_meta )
108
- if meta is not None :
109
- render_pid = self .window .controller .chat .render .get_pid (meta ) # get PID from renderer
110
- self .window .controller .ctx .load (pid_meta ) # reload renderer
111
-
112
- # self.window.controller.notepad.opened_once = True
104
+ meta = self .window .core .ctx .get_meta_by_id (pid_meta )
105
+ if meta is not None :
106
+ self .window .controller .ctx .load (pid_meta ) # reload renderer
113
107
elif tab .type == Tab .TAB_TOOL_DRAW :
114
108
if self .window .core .config .get ('vision.capture.enabled' ):
115
109
self .window .controller .camera .enable_capture ()
110
+
116
111
if prev_tab != idx :
117
112
self .window .core .dispatcher .dispatch (AppEvent (AppEvent .TAB_SELECTED )) # app event
118
113
@@ -256,6 +251,14 @@ def get_current_tab_name(self) -> str:
256
251
"""
257
252
return self .window .ui .tabs ['output' ].tabText (self .current )
258
253
254
+ def update_tooltip (self , tooltip : str ):
255
+ """
256
+ Update tab tooltip
257
+
258
+ :param tooltip: tooltip
259
+ """
260
+ self .window .ui .tabs ['output' ].setTabToolTip (self .current , tooltip )
261
+
259
262
def rename (self , idx : int ):
260
263
"""
261
264
Rename tab
0 commit comments