Commit 8c45791
committed
fix: improve streaming UX, stop button, and scroll synchronization
Streaming Text Insertion:
- Disable widget updates during text insertion to prevent auto-scroll
- Append using separate QTextCursor on document (doesn't affect visible cursor)
- Only auto-scroll to bottom if user was already at bottom (watching stream)
- Preserve user's scroll position when they scroll up to read earlier content
- Qt version compatibility for QTextCursor.End enum (Qt5/Qt6)
Stop Button Fix:
- Add cancellation check inside streaming generator consumption loop
- Check cancel_request() on each character/chunk during streaming
- Raise TranslationCanceled immediately when stop is requested
- Apply to both single translation and batch mode streaming
- Fixes infinite 'Stopping...' state with large merged translations
Scroll Synchronization:
- Replace pixel-based scroll sync with line-number (block) synchronization
- Get firstVisibleBlock() number and sync to same block in other editors
- Calculate exact scroll position using block geometry and cursorRect()
- Block scrollbar signals during sync to prevent feedback loop
- Works correctly during streaming when translation is incomplete
- Works with word wrap enabled/disabled
- Eliminates lag/gap between original and translation scroll positions1 parent 9042c76 commit 8c45791
2 files changed
Lines changed: 70 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
10 | 10 | | |
11 | 11 | | |
12 | 12 | | |
| |||
973 | 973 | | |
974 | 974 | | |
975 | 975 | | |
| 976 | + | |
| 977 | + | |
976 | 978 | | |
977 | 979 | | |
978 | 980 | | |
| 981 | + | |
| 982 | + | |
| 983 | + | |
| 984 | + | |
| 985 | + | |
| 986 | + | |
| 987 | + | |
| 988 | + | |
| 989 | + | |
| 990 | + | |
| 991 | + | |
| 992 | + | |
| 993 | + | |
| 994 | + | |
| 995 | + | |
| 996 | + | |
| 997 | + | |
| 998 | + | |
| 999 | + | |
| 1000 | + | |
| 1001 | + | |
| 1002 | + | |
| 1003 | + | |
| 1004 | + | |
| 1005 | + | |
| 1006 | + | |
| 1007 | + | |
| 1008 | + | |
| 1009 | + | |
| 1010 | + | |
| 1011 | + | |
979 | 1012 | | |
980 | | - | |
| 1013 | + | |
981 | 1014 | | |
982 | 1015 | | |
983 | 1016 | | |
| |||
1139 | 1172 | | |
1140 | 1173 | | |
1141 | 1174 | | |
1142 | | - | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
| 1187 | + | |
| 1188 | + | |
| 1189 | + | |
| 1190 | + | |
| 1191 | + | |
| 1192 | + | |
| 1193 | + | |
| 1194 | + | |
| 1195 | + | |
| 1196 | + | |
| 1197 | + | |
| 1198 | + | |
| 1199 | + | |
1143 | 1200 | | |
1144 | 1201 | | |
1145 | 1202 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
169 | 169 | | |
170 | 170 | | |
171 | 171 | | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
172 | 175 | | |
173 | 176 | | |
174 | 177 | | |
175 | 178 | | |
176 | 179 | | |
177 | 180 | | |
178 | 181 | | |
179 | | - | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
180 | 189 | | |
181 | 190 | | |
182 | 191 | | |
| |||
0 commit comments