mirror of
https://github.com/hyperspacedev/hyperspace
synced 2025-02-03 18:57:38 +01:00
Merge pull request #84 from hyperspacedev/keyboard-shorcuts-73
Add keyboard shortcuts to desktop apps
This commit is contained in:
commit
f4703e4a55
3
.gitignore
vendored
3
.gitignore
vendored
@ -70,3 +70,6 @@ dist/
|
||||
# Electron app files
|
||||
desktop/*.plist
|
||||
desktop/*.provisionprofile
|
||||
|
||||
# JetBrains IDEA directory
|
||||
.idea/
|
@ -176,6 +176,19 @@ function createWindow() {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Go to a URL in the main window. If it doesn't exist,
|
||||
* create the window and then navigate to it.
|
||||
* @param url The URL to visit in the main window
|
||||
*/
|
||||
function safelyGoTo(url) {
|
||||
if (mainWindow == null) {
|
||||
registerProtocol();
|
||||
createWindow();
|
||||
}
|
||||
mainWindow.loadURL(url);
|
||||
}
|
||||
|
||||
/**
|
||||
* Create the menu bar and attach it to a window
|
||||
*/
|
||||
@ -198,7 +211,22 @@ function createMenubar() {
|
||||
createWindow();
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'New Post',
|
||||
accelerator: 'Shift+CmdOrCtrl+N',
|
||||
click() {
|
||||
safelyGoTo("hyperspace://hyperspace/app/#compose")
|
||||
}
|
||||
},
|
||||
{ type: 'separator' },
|
||||
{
|
||||
label: 'Edit Profile',
|
||||
accelerator: "Shift+CmdOrCtrl+P",
|
||||
click() {
|
||||
safelyGoTo("hyperspace://hyperspace/app/#/you")
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
@ -218,8 +246,27 @@ function createMenubar() {
|
||||
{
|
||||
label: 'View',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Back',
|
||||
accelerator: 'CmdOrCtrl+[',
|
||||
click() {
|
||||
if (mainWindow != null && mainWindow.webContents.canGoBack()) {
|
||||
mainWindow.webContents.goBack()
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Forward',
|
||||
accelerator: 'CmdOrCtrl+]',
|
||||
click() {
|
||||
if (mainWindow != null && mainWindow.webContents.canGoForward()) {
|
||||
mainWindow.webContents.goForward()
|
||||
}
|
||||
}
|
||||
},
|
||||
{ role: 'reload' },
|
||||
{ role: 'forcereload' },
|
||||
{ type: 'separator' },
|
||||
{
|
||||
label: 'Open Dev Tools',
|
||||
click () {
|
||||
@ -236,19 +283,77 @@ function createMenubar() {
|
||||
{ role: 'togglefullscreen' }
|
||||
]
|
||||
},
|
||||
{
|
||||
label: "Places",
|
||||
submenu: [
|
||||
{
|
||||
label: 'Home',
|
||||
accelerator: "CmdOrCtrl+0",
|
||||
click() {
|
||||
safelyGoTo("hyperspace://hyperspace/app/#/home")
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Local',
|
||||
accelerator: "CmdOrCtrl+1",
|
||||
click() {
|
||||
safelyGoTo("hyperspace://hyperspace/app/#/local")
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Public',
|
||||
accelerator: "CmdOrCtrl+2",
|
||||
click() {
|
||||
safelyGoTo("hyperspace://hyperspace/app/#/public")
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Recommendations',
|
||||
accelerator: "CmdOrCtrl+3",
|
||||
click() {
|
||||
safelyGoTo("hyperspace://hyperspace/app/#/recommended")
|
||||
}
|
||||
},
|
||||
{ type: 'separator' },
|
||||
{
|
||||
label: 'Notifications',
|
||||
accelerator: "CmdOrCtrl+4",
|
||||
click() {
|
||||
safelyGoTo("hyperspace://hyperspace/app/#/notifications")
|
||||
}
|
||||
},
|
||||
{
|
||||
label: 'Messages',
|
||||
accelerator: "CmdOrCtrl+5",
|
||||
click() {
|
||||
safelyGoTo("hyperspace://hyperspace/app/#/messages")
|
||||
}
|
||||
},
|
||||
]
|
||||
},
|
||||
{
|
||||
role: 'window',
|
||||
submenu: [
|
||||
{ role: 'minimize' },
|
||||
{ role: 'close' }
|
||||
{ role: 'close' },
|
||||
{ type: 'separator' },
|
||||
]
|
||||
},
|
||||
{
|
||||
role: 'help',
|
||||
submenu: [
|
||||
{
|
||||
label: 'Hyperspace Docs',
|
||||
click () { require('electron').shell.openExternal('https://hyperspace.marquiskurt.net/docs/') }
|
||||
},
|
||||
{
|
||||
label: 'Report a Bug',
|
||||
click () { require('electron').shell.openExternal('https://github.com/hyperspacedev/hyperspace/issues') }
|
||||
},
|
||||
{ type: 'separator' },
|
||||
{
|
||||
label: 'Acknowledgements',
|
||||
click () { require('electron').shell.openExternal('https://github.com/hyperspacedev/hyperspace/blob/master/patreon.md') }
|
||||
}
|
||||
]
|
||||
}
|
||||
@ -258,7 +363,20 @@ function createMenubar() {
|
||||
menuBar.unshift({
|
||||
label: app.getName(),
|
||||
submenu: [
|
||||
{ role: 'about' },
|
||||
{
|
||||
label: 'About Hyperspace',
|
||||
click() {
|
||||
safelyGoTo("hyperspace://hyperspace/app/#/about")
|
||||
}
|
||||
},
|
||||
{ type: 'separator' },
|
||||
{
|
||||
label: "Preferences...",
|
||||
accelerator: 'Cmd+,',
|
||||
click() {
|
||||
safelyGoTo("hyperspace://hyperspace/app/#/settings");
|
||||
}
|
||||
},
|
||||
{ type: 'separator' },
|
||||
{ role: 'services' },
|
||||
{ type: 'separator' },
|
||||
@ -283,7 +401,7 @@ function createMenubar() {
|
||||
)
|
||||
|
||||
// Window menu
|
||||
menuBar[4].submenu = [
|
||||
menuBar[5].submenu = [
|
||||
{ role: 'close' },
|
||||
{ role: 'minimize' },
|
||||
{ role: 'zoom' },
|
||||
|
@ -53,6 +53,7 @@ class App extends Component<any, any> {
|
||||
this.removeBodyBackground();
|
||||
}
|
||||
|
||||
|
||||
removeBodyBackground() {
|
||||
if (isDarwinApp()) {
|
||||
document.body.style.backgroundColor = "transparent";
|
||||
|
Loading…
x
Reference in New Issue
Block a user