|
1 | 1 | from PyQt6.QtWidgets import (QMainWindow, QWidget, QTabWidget, QVBoxLayout, QMessageBox, QLabel, QStatusBar, QPushButton, QFrame, QTableView) |
2 | 2 | from PyQt6.QtCore import Qt, QTimer, QModelIndex |
3 | | -from PyQt6.QtGui import QAction, QKeySequence |
| 3 | +from PyQt6.QtGui import QAction, QKeySequence, QShortcut |
4 | 4 |
|
5 | 5 | import re |
6 | 6 | from .menu import MenuBar |
@@ -41,10 +41,33 @@ def __init__(self): |
41 | 41 | self.center_status_label.setObjectName("StatusLabel") |
42 | 42 | self.center_status_label.hide() |
43 | 43 | self._setup_find_and_replace() |
| 44 | + self.create_shortcuts() |
44 | 45 |
|
45 | 46 | self.setCentralWidget(self.main_tab) |
46 | 47 | self.show_welcome_screen() |
47 | 48 |
|
| 49 | + def create_shortcuts(self): |
| 50 | + for i in range(1, 10): |
| 51 | + shortcut = QShortcut(QKeySequence(f"Ctrl+{i}"), self) |
| 52 | + shortcut.activated.connect(lambda idx=i-1: self.switch_main_tab(idx)) |
| 53 | + |
| 54 | + self.shortcut_ctrl_tab = QShortcut(QKeySequence("Ctrl+Tab"), self) |
| 55 | + self.shortcut_ctrl_tab.activated.connect(self.toggle_table) |
| 56 | + |
| 57 | + self.shortcut_ctrl_w = QShortcut(QKeySequence("Ctrl+W"), self) |
| 58 | + self.shortcut_ctrl_w.activated.connect(lambda: self.close_tab(self.main_tab.currentIndex())) |
| 59 | + |
| 60 | + def switch_main_tab(self, index): |
| 61 | + if index < self.main_tab.count(): |
| 62 | + self.main_tab.setCurrentIndex(index) |
| 63 | + |
| 64 | + def toggle_table(self): |
| 65 | + current_tab = self.get_current_tab() |
| 66 | + if current_tab and hasattr(current_tab, 'inner_tabs'): |
| 67 | + current_index = current_tab.inner_tabs.currentIndex() |
| 68 | + new_index = 1 - current_index |
| 69 | + current_tab.inner_tabs.setCurrentIndex(new_index) |
| 70 | + |
48 | 71 | def create_new_tab(self, module_name=None, scenario_path=None, obj_path=None, project_name=None): |
49 | 72 | self.hide_welcome_screen() |
50 | 73 |
|
|
0 commit comments