refs #374 Remove global shortcut and use mousetrap

This commit is contained in:
AkiraFukushima 2018-06-06 20:25:28 +09:00
parent 49cf42d278
commit 8f47d10180
5 changed files with 14 additions and 10 deletions

7
package-lock.json generated
View File

@ -7800,7 +7800,7 @@
},
"onetime": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz",
"resolved": "http://registry.npmjs.org/onetime/-/onetime-1.1.0.tgz",
"integrity": "sha1-ofeDj4MUxRbwXs78vEzP4EtO14k="
},
"pluralize": {
@ -11009,6 +11009,11 @@
"resolved": "https://registry.npmjs.org/moment/-/moment-2.21.0.tgz",
"integrity": "sha512-TCZ36BjURTeFTM/CwRcViQlfkMvL1/vFISuNLO5GkcVm1+QHfbSiNqZuWeMFjj1/3+uAjXswgRk30j1kkLYJBQ=="
},
"mousetrap": {
"version": "1.6.2",
"resolved": "https://registry.npmjs.org/mousetrap/-/mousetrap-1.6.2.tgz",
"integrity": "sha512-jDjhi7wlHwdO6q6DS7YRmSHcuI+RVxadBkLt3KHrhd3C2b+w5pKefg3oj5beTcHZyVFA9Aksf+yEE1y5jxUjVA=="
},
"move-concurrently": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/move-concurrently/-/move-concurrently-1.0.1.tgz",

View File

@ -98,6 +98,7 @@
"is-empty": "^1.2.0",
"mastodon-api": "github:h3poteto/mastodon-api#lib",
"moment": "^2.21.0",
"mousetrap": "^1.6.2",
"nedb": "^1.8.0",
"object-assign-deep": "^0.4.0",
"rc": "^1.2.7",

View File

@ -1,6 +1,6 @@
'use strict'
import { app, ipcMain, BrowserWindow, shell, Menu, globalShortcut } from 'electron'
import { app, ipcMain, BrowserWindow, shell, Menu } from 'electron'
import Datastore from 'nedb'
import empty from 'is-empty'
import log from 'electron-log'
@ -238,10 +238,6 @@ function createWindow () {
mainWindow.on('closed', () => {
mainWindow = null
})
globalShortcut.register('CommandOrControl+T', () => {
mainWindow.webContents.send('CmdOrCtrl+T')
})
})
}

View File

@ -16,6 +16,7 @@ import SideMenu from './TimelineSpace/SideMenu'
import HeaderMenu from './TimelineSpace/HeaderMenu'
import Contents from './TimelineSpace/Contents'
import Modals from './TimelineSpace/Modals'
import Mousetrap from 'mousetrap'
export default {
name: 'timeline-space',
@ -37,6 +38,11 @@ export default {
this.$store.commit('GlobalHeader/updateChanging', false)
})
},
mounted () {
Mousetrap.bind(['command+t', 'ctrl+t'], () => {
this.$store.commit('TimelineSpace/Modals/Jump/changeModal', true)
})
},
beforeDestroy () {
this.$store.dispatch('TimelineSpace/stopUserStreaming')
this.$store.dispatch('TimelineSpace/stopLocalStreaming')

View File

@ -128,14 +128,10 @@ const TimelineSpace = {
ipcRenderer.on('CmdOrCtrl+K', () => {
commit('TimelineSpace/Modals/Jump/changeModal', true, { root: true })
})
ipcRenderer.on('CmdOrCtrl+T', () => {
commit('TimelineSpace/Modals/Jump/changeModal', true, { root: true })
})
},
async removeShortcutEvents () {
ipcRenderer.removeAllListeners('CmdOrCtrl+N')
ipcRenderer.removeAllListeners('CmdOrCtrl+K')
ipcRenderer.removeAllListeners('CmdOrCtrl+T')
return 'removeShortcutEvents'
},
async clearAccount ({ commit }) {