From ef23ce58d1138e78f238ac61f8b552ea182c56f0 Mon Sep 17 00:00:00 2001 From: Anthony Conrad Date: Sun, 23 Aug 2020 21:54:12 -0700 Subject: [PATCH 1/2] Added keyboard support for the menu system --- qt_ui/windows/QLiberationWindow.py | 41 +++++++++++++++++------------- 1 file changed, 23 insertions(+), 18 deletions(-) diff --git a/qt_ui/windows/QLiberationWindow.py b/qt_ui/windows/QLiberationWindow.py index 382b3289..4641be37 100644 --- a/qt_ui/windows/QLiberationWindow.py +++ b/qt_ui/windows/QLiberationWindow.py @@ -69,27 +69,31 @@ class QLiberationWindow(QMainWindow): GameUpdateSignal.get_instance().debriefingReceived.connect(self.onDebriefing) def initActions(self): - self.newGameAction = QAction("New Game", self) + self.newGameAction = QAction("&New Game", self) self.newGameAction.setIcon(QIcon(CONST.ICONS["New"])) self.newGameAction.triggered.connect(self.newGame) + self.newGameAction.setShortcut('CTRL+N') - self.openAction = QAction("Open", self) + self.openAction = QAction("&Open", self) self.openAction.setIcon(QIcon(CONST.ICONS["Open"])) self.openAction.triggered.connect(self.openFile) + self.openAction.setShortcut('CTRL+O') - self.saveGameAction = QAction("Save", self) + self.saveGameAction = QAction("&Save", self) self.saveGameAction.setIcon(QIcon(CONST.ICONS["Save"])) self.saveGameAction.triggered.connect(self.saveGame) + self.saveGameAction.setShortcut('CTRL+S') - self.saveAsAction = QAction("Save As", self) + self.saveAsAction = QAction("Save &As", self) self.saveAsAction.setIcon(QIcon(CONST.ICONS["Save"])) self.saveAsAction.triggered.connect(self.saveGameAs) + self.saveAsAction.setShortcut('CTRL+A') self.showAboutDialogAction = QAction("About DCS Liberation", self) self.showAboutDialogAction.setIcon(QIcon.fromTheme("help-about")) self.showAboutDialogAction.triggered.connect(self.showAboutDialog) - self.showLiberationPrefDialogAction = QAction("Preferences", self) + self.showLiberationPrefDialogAction = QAction("&Preferences", self) self.showLiberationPrefDialogAction.setIcon(QIcon.fromTheme("help-about")) self.showLiberationPrefDialogAction.triggered.connect(self.showLiberationDialog) @@ -102,27 +106,17 @@ class QLiberationWindow(QMainWindow): def initMenuBar(self): self.menu = self.menuBar() - file_menu = self.menu.addMenu("File") + file_menu = self.menu.addMenu("&File") file_menu.addAction(self.newGameAction) file_menu.addAction(self.openAction) + file_menu.addSeparator() file_menu.addAction(self.saveGameAction) file_menu.addAction(self.saveAsAction) file_menu.addSeparator() file_menu.addAction(self.showLiberationPrefDialogAction) file_menu.addSeparator() #file_menu.addAction("Close Current Game", lambda: self.closeGame()) # Not working - file_menu.addAction("Exit" , lambda: self.exit()) - - help_menu = self.menu.addMenu("Help") - help_menu.addAction("Discord Server", lambda: webbrowser.open_new_tab("https://" + "discord.gg" + "/" + "bKrt" + "rkJ")) - help_menu.addAction("Github Repository", lambda: webbrowser.open_new_tab("https://github.com/khopa/dcs_liberation")) - help_menu.addAction("Releases", lambda: webbrowser.open_new_tab("https://github.com/Khopa/dcs_liberation/releases")) - help_menu.addAction("Online Manual", lambda: webbrowser.open_new_tab(URLS["Manual"])) - help_menu.addAction("ED Forum Thread", lambda: webbrowser.open_new_tab(URLS["ForumThread"])) - help_menu.addAction("Report an issue", lambda: webbrowser.open_new_tab(URLS["Issues"])) - - help_menu.addSeparator() - help_menu.addAction(self.showAboutDialogAction) + file_menu.addAction("E&xit" , lambda: self.exit()) displayMenu = self.menu.addMenu("Display") @@ -164,6 +158,17 @@ class QLiberationWindow(QMainWindow): displayMenu.addAction(tg_sam_visibility) displayMenu.addAction(tg_flight_path_visibility) + help_menu = self.menu.addMenu("&Help") + help_menu.addAction("Discord Server", lambda: webbrowser.open_new_tab("https://" + "discord.gg" + "/" + "bKrt" + "rkJ")) + help_menu.addAction("Github Repository", lambda: webbrowser.open_new_tab("https://github.com/khopa/dcs_liberation")) + help_menu.addAction("Releases", lambda: webbrowser.open_new_tab("https://github.com/Khopa/dcs_liberation/releases")) + help_menu.addAction("Online Manual", lambda: webbrowser.open_new_tab(URLS["Manual"])) + help_menu.addAction("ED Forum Thread", lambda: webbrowser.open_new_tab(URLS["ForumThread"])) + help_menu.addAction("Report an issue", lambda: webbrowser.open_new_tab(URLS["Issues"])) + + help_menu.addSeparator() + help_menu.addAction(self.showAboutDialogAction) + def newGame(self): wizard = NewGameWizard(self) wizard.show() From 04c878f57c915dc8baf12144f878188c8472d418 Mon Sep 17 00:00:00 2001 From: Anthony Conrad Date: Sun, 23 Aug 2020 22:25:16 -0700 Subject: [PATCH 2/2] Added keyboard support to the menu system --- .vscode/launch.json | 19 ++++++++++++++++ .vscode/settings.json | 4 ++++ .vscode/tasks.json | 35 ++++++++++++++++++++++++++++++ qt_ui/windows/QLiberationWindow.py | 28 ++++++++++++------------ 4 files changed, 72 insertions(+), 14 deletions(-) create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 .vscode/tasks.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 00000000..646c8768 --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,19 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "Python: Main", + "type": "python", + "request": "launch", + "program": "qt_ui\\main.py", + "console": "integratedTerminal", + "env": { + "PYTHONPATH": ".;./pydcs" + }, + "preLaunchTask": "Prepare Environment" + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 00000000..d8c82a7e --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,4 @@ +{ + "python.pythonPath": "g:\\python\\dcs_liberation\\venv\\Scripts\\python.exe", + "vsintellicode.python.completionsEnabled": true +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 00000000..84bd2413 --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,35 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "label": "Prepare Environment", + "type": "shell", + "isBackground": false, + "problemMatcher": [], + "command": "powershell", + "args": [ + "-Command", + "& {if (-not (Test-Path ${workspaceFolder}\\venv)) { python -m venv ${workspaceFolder}\\venv; . ${workspaceFolder}\\venv\\scripts\\activate.ps1; pip install -r requirements.txt; Copy-Item ${workspaceFolder}\\venv\\Lib\\site-packages\\shiboken2\\shiboken2.abi3.dll ${workspaceFolder}\\venv\\Lib\\site-packages\\PySide2 } }", + ], + "group": "build", + "options": { + "env": { + "PYTHONPATH": ".;./pydcs" + } + }, + "presentation": { + "echo": true, + "reveal": "never", + "focus": false, + "panel": "shared", + "showReuseMessage": true, + "clear": false + }, + "runOptions": { + "runOn": "folderOpen" + } + } + ] +} \ No newline at end of file diff --git a/qt_ui/windows/QLiberationWindow.py b/qt_ui/windows/QLiberationWindow.py index 4641be37..3d19cdf5 100644 --- a/qt_ui/windows/QLiberationWindow.py +++ b/qt_ui/windows/QLiberationWindow.py @@ -89,7 +89,7 @@ class QLiberationWindow(QMainWindow): self.saveAsAction.triggered.connect(self.saveGameAs) self.saveAsAction.setShortcut('CTRL+A') - self.showAboutDialogAction = QAction("About DCS Liberation", self) + self.showAboutDialogAction = QAction("&About DCS Liberation", self) self.showAboutDialogAction.setIcon(QIcon.fromTheme("help-about")) self.showAboutDialogAction.triggered.connect(self.showAboutDialog) @@ -118,35 +118,35 @@ class QLiberationWindow(QMainWindow): #file_menu.addAction("Close Current Game", lambda: self.closeGame()) # Not working file_menu.addAction("E&xit" , lambda: self.exit()) - displayMenu = self.menu.addMenu("Display") + displayMenu = self.menu.addMenu("&Display") - tg_cp_visibility = QAction('Control Point', displayMenu) + tg_cp_visibility = QAction('&Control Point', displayMenu) tg_cp_visibility.setCheckable(True) tg_cp_visibility.setChecked(True) tg_cp_visibility.toggled.connect(lambda: QLiberationMap.set_display_rule("cp", tg_cp_visibility.isChecked())) - tg_go_visibility = QAction('Ground Objects', displayMenu) + tg_go_visibility = QAction('&Ground Objects', displayMenu) tg_go_visibility.setCheckable(True) tg_go_visibility.setChecked(True) tg_go_visibility.toggled.connect(lambda: QLiberationMap.set_display_rule("go", tg_go_visibility.isChecked())) - tg_line_visibility = QAction('Lines', displayMenu) + tg_line_visibility = QAction('&Lines', displayMenu) tg_line_visibility.setCheckable(True) tg_line_visibility.setChecked(True) tg_line_visibility.toggled.connect( lambda: QLiberationMap.set_display_rule("lines", tg_line_visibility.isChecked())) - tg_event_visibility = QAction('Events', displayMenu) + tg_event_visibility = QAction('&Events', displayMenu) tg_event_visibility.setCheckable(True) tg_event_visibility.setChecked(True) tg_event_visibility.toggled.connect(lambda: QLiberationMap.set_display_rule("events", tg_event_visibility.isChecked())) - tg_sam_visibility = QAction('SAM Range', displayMenu) + tg_sam_visibility = QAction('&SAM Range', displayMenu) tg_sam_visibility.setCheckable(True) tg_sam_visibility.setChecked(True) tg_sam_visibility.toggled.connect(lambda: QLiberationMap.set_display_rule("sam", tg_sam_visibility.isChecked())) - tg_flight_path_visibility = QAction('Flight Paths', displayMenu) + tg_flight_path_visibility = QAction('&Flight Paths', displayMenu) tg_flight_path_visibility.setCheckable(True) tg_flight_path_visibility.setChecked(False) tg_flight_path_visibility.toggled.connect(lambda: QLiberationMap.set_display_rule("flight_paths", tg_flight_path_visibility.isChecked())) @@ -159,12 +159,12 @@ class QLiberationWindow(QMainWindow): displayMenu.addAction(tg_flight_path_visibility) help_menu = self.menu.addMenu("&Help") - help_menu.addAction("Discord Server", lambda: webbrowser.open_new_tab("https://" + "discord.gg" + "/" + "bKrt" + "rkJ")) - help_menu.addAction("Github Repository", lambda: webbrowser.open_new_tab("https://github.com/khopa/dcs_liberation")) - help_menu.addAction("Releases", lambda: webbrowser.open_new_tab("https://github.com/Khopa/dcs_liberation/releases")) - help_menu.addAction("Online Manual", lambda: webbrowser.open_new_tab(URLS["Manual"])) - help_menu.addAction("ED Forum Thread", lambda: webbrowser.open_new_tab(URLS["ForumThread"])) - help_menu.addAction("Report an issue", lambda: webbrowser.open_new_tab(URLS["Issues"])) + help_menu.addAction("&Discord Server", lambda: webbrowser.open_new_tab("https://" + "discord.gg" + "/" + "bKrt" + "rkJ")) + help_menu.addAction("&Github Repository", lambda: webbrowser.open_new_tab("https://github.com/khopa/dcs_liberation")) + help_menu.addAction("&Releases", lambda: webbrowser.open_new_tab("https://github.com/Khopa/dcs_liberation/releases")) + help_menu.addAction("&Online Manual", lambda: webbrowser.open_new_tab(URLS["Manual"])) + help_menu.addAction("&ED Forum Thread", lambda: webbrowser.open_new_tab(URLS["ForumThread"])) + help_menu.addAction("Report an &issue", lambda: webbrowser.open_new_tab(URLS["Issues"])) help_menu.addSeparator() help_menu.addAction(self.showAboutDialogAction)