focus fixes focus lost in translation
- SHA
b4f503df20ba2a33a95b1d198aa6fe4e36c9b40d- Parents
-
423a8f2 - Tree
e8b37d8
b4f503d
b4f503df20ba2a33a95b1d198aa6fe4e36c9b40d423a8f2
e8b37d8| Status | File | + | - |
|---|---|---|---|
| M |
src/wulftp/ui/main_window.py
|
15 | 2 |
src/wulftp/ui/main_window.pymodified@@ -231,13 +231,26 @@ class WulFTPClient(QMainWindow): | |||
| 231 | AppConfig.STATUS_MESSAGE_TIMEOUT | 231 | AppConfig.STATUS_MESSAGE_TIMEOUT |
| 232 | ) | 232 | ) |
| 233 | 233 | ||
| 234 | - # Set focus to remote pane after connection | 234 | + # Defer focus setting to avoid conflicts |
| 235 | - self.remote_pane.tree_view.setFocus() | 235 | + QTimer.singleShot(100, lambda: self._set_remote_focus()) |
| 236 | 236 | ||
| 237 | except Exception as e: | 237 | except Exception as e: |
| 238 | fast_message(self, "Connection Error", str(e), "error") | 238 | fast_message(self, "Connection Error", str(e), "error") |
| 239 | self._update_connection_state(False) | 239 | self._update_connection_state(False) |
| 240 | 240 | ||
| 241 | + def _set_remote_focus(self): | ||
| 242 | + """Set focus to remote pane after connection stabilizes.""" | ||
| 243 | + # Ensure main window has focus first | ||
| 244 | + self.activateWindow() | ||
| 245 | + self.raise_() | ||
| 246 | + | ||
| 247 | + # Then set focus to remote pane | ||
| 248 | + if self.remote_pane.isEnabled(): | ||
| 249 | + self.remote_pane.tree_view.setFocus() | ||
| 250 | + self.remote_pane.tree_view.setCurrentIndex( | ||
| 251 | + self.remote_pane.model.index(0, 0) | ||
| 252 | + ) | ||
| 253 | + | ||
| 241 | def disconnect(self): | 254 | def disconnect(self): |
| 242 | """Close SFTP connection.""" | 255 | """Close SFTP connection.""" |
| 243 | if self.sftp: | 256 | if self.sftp: |