Skip to content

Commit 1d5a544

Browse files
committed
add quick reference
Signed-off-by: John Thornton <[email protected]>
1 parent c74ae69 commit 1d5a544

File tree

4 files changed

+37
-3
lines changed

4 files changed

+37
-3
lines changed

Diff for: flexgui/src/flexgui

+1-1
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ class flexgui(QMainWindow):
182182

183183
startup.set_screen(self)
184184
startup.find_children(self)
185-
startup.setup_recent_files(self)
185+
startup.setup_menus(self)
186186
startup.get_ini_values(self)
187187
startup.setup_enables(self)
188188
startup.setup_buttons(self)

Diff for: flexgui/src/libflexgui/actions.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,6 @@ def action_about(parent): # actionAbout
504504
dialogs.about_dialog(parent)
505505

506506
def action_quick_reference(parent): # actionQuick_Reference
507-
print(parent.sender().objectName())
507+
dialogs.quick_reference_dialog(parent)
508508

509509

Diff for: flexgui/src/libflexgui/dialogs.py

+31
Original file line numberDiff line numberDiff line change
@@ -213,3 +213,34 @@ def about_dialog(parent):
213213

214214
dialog_box.exec()
215215

216+
def quick_reference_dialog(parent):
217+
dialog_box = QDialog()
218+
dialog_box.setMinimumSize(300, 300)
219+
dialog_box.setWindowTitle('Keyboard Shortcuts')
220+
221+
layout = QVBoxLayout(dialog_box)
222+
223+
titleLabel = QLabel()
224+
titleLabel.setText('FlexGUI')
225+
titleLabel.setAlignment(Qt.AlignmentFlag.AlignCenter)
226+
layout.addWidget(titleLabel)
227+
228+
shortcutsLabel = QLabel()
229+
if len(parent.shortcuts) > 0:
230+
shortcutsLabel.setText(' \n'.join(parent.shortcuts))
231+
else:
232+
shortcutsLabel.setText('No Keyboard Shortcuts Found')
233+
#shortcutsLabel.setAlignment(Qt.AlignmentFlag.AlignCenter)
234+
layout.addWidget(shortcutsLabel)
235+
236+
layout.addStretch()
237+
238+
buttonBox = QDialogButtonBox()
239+
buttonBox.setStandardButtons(QDialogButtonBox.StandardButton.Ok)
240+
buttonBox.setCenterButtons(True)
241+
buttonBox.accepted.connect(dialog_box.close)
242+
layout.addWidget(buttonBox)
243+
244+
dialog_box.exec()
245+
246+

Diff for: flexgui/src/libflexgui/startup.py

+4-1
Original file line numberDiff line numberDiff line change
@@ -818,8 +818,9 @@ def setup_mdi(parent):
818818
parent.mdi_history_lw.addItem(item.strip())
819819
parent.mdi_history_lw.itemSelectionChanged.connect(partial(utilities.add_mdi, parent))
820820

821-
def setup_recent_files(parent):
821+
def setup_menus(parent):
822822
menus = parent.findChildren(QMenu)
823+
parent.shortcuts = []
823824
for menu in menus:
824825
menu_list = menu.actions()
825826
for index, action in enumerate(menu_list):
@@ -837,6 +838,8 @@ def setup_recent_files(parent):
837838
name = os.path.basename(path)
838839
a = parent.menuRecent.addAction(name)
839840
a.triggered.connect(partial(getattr(actions, 'load_file'), parent, path))
841+
if len(action.shortcut().toString()) > 0:
842+
parent.shortcuts.append(f'{action.text()}\t{action.shortcut().toString()}')
840843

841844
def setup_jog(parent):
842845
jog_buttons = {}

0 commit comments

Comments
 (0)