|
|
@@ -1,10 +1,11 @@ |
|
|
|
import { app, BrowserWindow, Menu, ipcMain, } from 'electron' |
|
|
|
import path from 'path' |
|
|
|
import fs from 'fs' |
|
|
|
import * as yargs from 'yargs' |
|
|
|
|
|
|
|
import SPANS from './services/spans.json' |
|
|
|
import SCALE_FACTORS from './services/scaleFactors.json' |
|
|
|
import THEMES from './services/themes.json' |
|
|
|
import COLORS from './services/colors.json' |
|
|
|
import { _ } from './services/messages' |
|
|
|
import getKeyName from './services/getKeyName' |
|
|
|
import getNaturalKeyCount from './services/getNaturalKeyCount' |
|
|
@@ -21,6 +22,9 @@ let config: Config = { |
|
|
|
startKey: 21, |
|
|
|
endKey: 108, |
|
|
|
scaleFactor: 1, |
|
|
|
colorNaturalKey: undefined, |
|
|
|
colorAccidentalKey: undefined, |
|
|
|
colorHighlight: undefined, |
|
|
|
} |
|
|
|
|
|
|
|
const createWindow = () => { |
|
|
@@ -76,6 +80,20 @@ const createWindow = () => { |
|
|
|
}) |
|
|
|
} |
|
|
|
|
|
|
|
const reload = () => { |
|
|
|
app.relaunch({ |
|
|
|
args: process.argv.slice(1).concat([ |
|
|
|
`--startKey=${config.startKey}`, |
|
|
|
`--endKey=${config.endKey}`, |
|
|
|
`--scaleFactor=${config.scaleFactor}`, |
|
|
|
`--colorNaturalKey=${config.colorNaturalKey}`, |
|
|
|
`--colorAccidentalKey=${config.colorAccidentalKey}`, |
|
|
|
`--colorHighlight=${config.colorHighlight}`, |
|
|
|
]) |
|
|
|
}) |
|
|
|
app.exit(0) |
|
|
|
} |
|
|
|
|
|
|
|
app |
|
|
|
.whenReady() |
|
|
|
.then(() => { |
|
|
@@ -124,14 +142,7 @@ app |
|
|
|
click: () => { |
|
|
|
config.startKey = s.startKey |
|
|
|
config.endKey = s.endKey |
|
|
|
app.relaunch({ |
|
|
|
args: process.argv.slice(1).concat([ |
|
|
|
`--startKey=${config.startKey}`, |
|
|
|
`--endKey=${config.endKey}`, |
|
|
|
`--scaleFactor=${config.scaleFactor}`, |
|
|
|
]) |
|
|
|
}) |
|
|
|
app.exit(0) |
|
|
|
reload() |
|
|
|
}, |
|
|
|
})) |
|
|
|
}, |
|
|
@@ -143,18 +154,70 @@ app |
|
|
|
checked: config.scaleFactor === s, |
|
|
|
click: () => { |
|
|
|
config.scaleFactor = s |
|
|
|
|
|
|
|
app.relaunch({ |
|
|
|
args: process.argv.slice(1).concat([ |
|
|
|
`--startKey=${config.startKey}`, |
|
|
|
`--endKey=${config.endKey}`, |
|
|
|
`--scaleFactor=${config.scaleFactor}`, |
|
|
|
]) |
|
|
|
}) |
|
|
|
app.exit(0) |
|
|
|
reload() |
|
|
|
}, |
|
|
|
})), |
|
|
|
}, |
|
|
|
{ |
|
|
|
label: _('THEME'), |
|
|
|
submenu: [ |
|
|
|
{ |
|
|
|
label: _('BASE'), |
|
|
|
submenu: [ |
|
|
|
{ |
|
|
|
label: _('DEFAULT'), |
|
|
|
type: 'radio', |
|
|
|
checked: ( |
|
|
|
typeof config.colorAccidentalKey === 'undefined' |
|
|
|
&& typeof config.colorNaturalKey === 'undefined' |
|
|
|
), |
|
|
|
click: () => { |
|
|
|
config.colorNaturalKey = undefined |
|
|
|
config.colorAccidentalKey = undefined |
|
|
|
reload() |
|
|
|
} |
|
|
|
}, |
|
|
|
...Object.entries(THEMES).map(([key, [colorNaturalKey, colorAccidentalKey]]) => ({ |
|
|
|
label: _(key), |
|
|
|
type: 'radio', |
|
|
|
checked: ( |
|
|
|
config.colorAccidentalKey === colorAccidentalKey |
|
|
|
&& config.colorNaturalKey === colorNaturalKey |
|
|
|
), |
|
|
|
click: () => { |
|
|
|
config.colorNaturalKey = colorNaturalKey |
|
|
|
config.colorAccidentalKey = colorAccidentalKey |
|
|
|
reload() |
|
|
|
} |
|
|
|
})) |
|
|
|
] |
|
|
|
}, |
|
|
|
{ |
|
|
|
label: _('HIGHLIGHT'), |
|
|
|
submenu: [ |
|
|
|
{ |
|
|
|
label: _('NONE'), |
|
|
|
type: 'radio', |
|
|
|
checked: typeof config.colorHighlight === 'undefined', |
|
|
|
click: () => { |
|
|
|
config.colorHighlight = undefined |
|
|
|
reload() |
|
|
|
} |
|
|
|
}, |
|
|
|
...Object.entries(COLORS).map(([key, colorHighlight]) => ({ |
|
|
|
label: _(key), |
|
|
|
sublabel: colorHighlight, |
|
|
|
type: 'radio', |
|
|
|
checked: config.colorHighlight === colorHighlight, |
|
|
|
click: () => { |
|
|
|
config.colorHighlight = colorHighlight |
|
|
|
reload() |
|
|
|
} |
|
|
|
})) |
|
|
|
] |
|
|
|
} |
|
|
|
] |
|
|
|
} |
|
|
|
] |
|
|
|
}, |
|
|
|
...( |
|
|
|