Skip to content

Commit 916885a

Browse files
committed
Added shortcuts for navigation to improve QOL and productivity
1 parent c5325ea commit 916885a

2 files changed

Lines changed: 31 additions & 7 deletions

File tree

ui/menu.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ def create_menu_bar(self) -> None:
3434
fixed_width_action.setToolTip("Apply default fixed widths")
3535
menubar.addAction(fixed_width_action)
3636

37+
generate_action = QAction("Generate Test Cases", self.main)
38+
generate_action.triggered.connect(self.generate_test_cases_action)
39+
generate_action.setShortcut("")
40+
generate_action.setToolTip("Generate Test Cases")
41+
menubar.addAction(generate_action)
42+
3743

3844
def _create_file_menu(self, menubar: QMenuBar) -> None:
3945
file_menu = menubar.addMenu("File")
@@ -47,7 +53,7 @@ def _create_file_menu(self, menubar: QMenuBar) -> None:
4753

4854
load_action = QAction("Open File", self.main)
4955
load_action.triggered.connect(self.file_ops.open_file)
50-
load_action.setShortcut("Ctrl+O")
56+
load_action.setShortcut("Ctrl+E")
5157
file_menu.addAction(load_action)
5258

5359
file_menu.addSeparator()
@@ -72,11 +78,6 @@ def _create_edit_menu(self, menubar: QMenuBar) -> None:
7278
edit_menu.addAction(self.main.undo_action)
7379
edit_menu.addAction(self.main.redo_action)
7480

75-
edit_menu.addSeparator()
76-
generate_action = QAction("Generate Test Cases", self.main)
77-
generate_action.triggered.connect(self.generate_test_cases_action)
78-
edit_menu.addAction(generate_action)
79-
8081
edit_menu.addSeparator()
8182
find_action = QAction("Find/Replace", self.main)
8283
find_action.setShortcut(QKeySequence.StandardKey.Find)

ui/window.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from PyQt6.QtWidgets import (QMainWindow, QWidget, QTabWidget, QVBoxLayout, QMessageBox, QLabel, QStatusBar, QPushButton, QFrame, QTableView)
22
from PyQt6.QtCore import Qt, QTimer, QModelIndex
3-
from PyQt6.QtGui import QAction, QKeySequence
3+
from PyQt6.QtGui import QAction, QKeySequence, QShortcut
44

55
import re
66
from .menu import MenuBar
@@ -41,10 +41,33 @@ def __init__(self):
4141
self.center_status_label.setObjectName("StatusLabel")
4242
self.center_status_label.hide()
4343
self._setup_find_and_replace()
44+
self.create_shortcuts()
4445

4546
self.setCentralWidget(self.main_tab)
4647
self.show_welcome_screen()
4748

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+
4871
def create_new_tab(self, module_name=None, scenario_path=None, obj_path=None, project_name=None):
4972
self.hide_welcome_screen()
5073

0 commit comments

Comments
 (0)