mirror of
https://github.com/hyperspacedev/hyperspace
synced 2025-02-04 03:08:10 +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
|
# Electron app files
|
||||||
desktop/*.plist
|
desktop/*.plist
|
||||||
desktop/*.provisionprofile
|
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
|
* Create the menu bar and attach it to a window
|
||||||
*/
|
*/
|
||||||
@ -198,7 +211,22 @@ function createMenubar() {
|
|||||||
createWindow();
|
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',
|
label: 'View',
|
||||||
submenu: [
|
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: 'reload' },
|
||||||
{ role: 'forcereload' },
|
{ role: 'forcereload' },
|
||||||
|
{ type: 'separator' },
|
||||||
{
|
{
|
||||||
label: 'Open Dev Tools',
|
label: 'Open Dev Tools',
|
||||||
click () {
|
click () {
|
||||||
@ -236,19 +283,77 @@ function createMenubar() {
|
|||||||
{ role: 'togglefullscreen' }
|
{ 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',
|
role: 'window',
|
||||||
submenu: [
|
submenu: [
|
||||||
{ role: 'minimize' },
|
{ role: 'minimize' },
|
||||||
{ role: 'close' }
|
{ role: 'close' },
|
||||||
|
{ type: 'separator' },
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
role: 'help',
|
role: 'help',
|
||||||
submenu: [
|
submenu: [
|
||||||
|
{
|
||||||
|
label: 'Hyperspace Docs',
|
||||||
|
click () { require('electron').shell.openExternal('https://hyperspace.marquiskurt.net/docs/') }
|
||||||
|
},
|
||||||
{
|
{
|
||||||
label: 'Report a Bug',
|
label: 'Report a Bug',
|
||||||
click () { require('electron').shell.openExternal('https://github.com/hyperspacedev/hyperspace/issues') }
|
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({
|
menuBar.unshift({
|
||||||
label: app.getName(),
|
label: app.getName(),
|
||||||
submenu: [
|
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' },
|
{ type: 'separator' },
|
||||||
{ role: 'services' },
|
{ role: 'services' },
|
||||||
{ type: 'separator' },
|
{ type: 'separator' },
|
||||||
@ -283,7 +401,7 @@ function createMenubar() {
|
|||||||
)
|
)
|
||||||
|
|
||||||
// Window menu
|
// Window menu
|
||||||
menuBar[4].submenu = [
|
menuBar[5].submenu = [
|
||||||
{ role: 'close' },
|
{ role: 'close' },
|
||||||
{ role: 'minimize' },
|
{ role: 'minimize' },
|
||||||
{ role: 'zoom' },
|
{ role: 'zoom' },
|
||||||
|
@ -53,6 +53,7 @@ class App extends Component<any, any> {
|
|||||||
this.removeBodyBackground();
|
this.removeBodyBackground();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
removeBodyBackground() {
|
removeBodyBackground() {
|
||||||
if (isDarwinApp()) {
|
if (isDarwinApp()) {
|
||||||
document.body.style.backgroundColor = "transparent";
|
document.body.style.backgroundColor = "transparent";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user