Merge pull request #102 from parithon/menukbsupport

Add keyboard support to the menu system
This commit is contained in:
C. Perreau 2020-08-24 21:42:27 +02:00 committed by GitHub
commit e4eeef8f99
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 89 additions and 26 deletions

19
.vscode/launch.json vendored Normal file
View File

@ -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"
}
]
}

4
.vscode/settings.json vendored Normal file
View File

@ -0,0 +1,4 @@
{
"python.pythonPath": "g:\\python\\dcs_liberation\\venv\\Scripts\\python.exe",
"vsintellicode.python.completionsEnabled": true
}

35
.vscode/tasks.json vendored Normal file
View File

@ -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"
}
}
]
}

View File

@ -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 = 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,57 +106,47 @@ 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())
file_menu.addAction("E&xit" , 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"]))
displayMenu = self.menu.addMenu("&Display")
help_menu.addSeparator()
help_menu.addAction(self.showAboutDialogAction)
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()))
@ -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()