Commit 5787f52
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
- Stops immediately instead of waiting for paragraph completion
Scroll Synchronization:
- Replace pixel-based scroll sync with line-number (block) synchronization
- Get first visible block number and sync to same block in other editors
- Works correctly during streaming when translation is incomplete
- Works with word wrap enabled/disabled (syncs wrapped lines properly)
- If target line doesn't exist yet during streaming, skip sync gracefully
- Keeps original and translation aligned by actual content position1 parent 9042c76 commit 5787f52
2 files changed
Lines changed: 57 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 | + | |
979 | 999 | | |
980 | | - | |
| 1000 | + | |
981 | 1001 | | |
982 | 1002 | | |
983 | 1003 | | |
| |||
1139 | 1159 | | |
1140 | 1160 | | |
1141 | 1161 | | |
1142 | | - | |
| 1162 | + | |
| 1163 | + | |
| 1164 | + | |
| 1165 | + | |
| 1166 | + | |
| 1167 | + | |
| 1168 | + | |
| 1169 | + | |
| 1170 | + | |
| 1171 | + | |
| 1172 | + | |
| 1173 | + | |
| 1174 | + | |
| 1175 | + | |
| 1176 | + | |
| 1177 | + | |
| 1178 | + | |
| 1179 | + | |
| 1180 | + | |
| 1181 | + | |
| 1182 | + | |
| 1183 | + | |
| 1184 | + | |
| 1185 | + | |
| 1186 | + | |
1143 | 1187 | | |
1144 | 1188 | | |
1145 | 1189 | | |
| |||
| 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