+31
-1
@@ -66,6 +66,7 @@ let templates;
|
|||||||
let capture;
|
let capture;
|
||||||
let textIntel;
|
let textIntel;
|
||||||
let mainWindow;
|
let mainWindow;
|
||||||
|
let lastZoomShortcut = null;
|
||||||
|
|
||||||
function reindex(guideId) {
|
function reindex(guideId) {
|
||||||
try {
|
try {
|
||||||
@@ -88,6 +89,16 @@ function applyTheme() {
|
|||||||
nativeTheme.themeSource = settings.get('appearance') || 'system';
|
nativeTheme.themeSource = settings.get('appearance') || 'system';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function dispatchZoomShortcut(kind) {
|
||||||
|
if (!kind) return;
|
||||||
|
const now = Date.now();
|
||||||
|
if (lastZoomShortcut && lastZoomShortcut.kind === kind && (now - lastZoomShortcut.at) < 50) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
lastZoomShortcut = { kind, at: now };
|
||||||
|
sendToRenderer('editor:zoom-shortcut', kind);
|
||||||
|
}
|
||||||
|
|
||||||
function createWindow() {
|
function createWindow() {
|
||||||
mainWindow = new BrowserWindow({
|
mainWindow = new BrowserWindow({
|
||||||
width: 1280,
|
width: 1280,
|
||||||
@@ -118,7 +129,7 @@ function createWindow() {
|
|||||||
const kind = zoomShortcutFromInputEvent(input);
|
const kind = zoomShortcutFromInputEvent(input);
|
||||||
if (!kind) return;
|
if (!kind) return;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
sendToRenderer('editor:zoom-shortcut', kind);
|
dispatchZoomShortcut(kind);
|
||||||
});
|
});
|
||||||
mainWindow.loadFile(path.join(__dirname, 'renderer', 'index.html'));
|
mainWindow.loadFile(path.join(__dirname, 'renderer', 'index.html'));
|
||||||
mainWindow.once('ready-to-show', () => {
|
mainWindow.once('ready-to-show', () => {
|
||||||
@@ -397,6 +408,25 @@ function createWindow() {
|
|||||||
|
|
||||||
function registerHotkeys() {
|
function registerHotkeys() {
|
||||||
globalShortcut.unregisterAll();
|
globalShortcut.unregisterAll();
|
||||||
|
const zoomBindings = [
|
||||||
|
['CommandOrControl+=', 'in'],
|
||||||
|
['CommandOrControl+Shift+=', 'in'],
|
||||||
|
['CommandOrControl+Add', 'in'],
|
||||||
|
['CommandOrControl+-', 'out'],
|
||||||
|
['CommandOrControl+Minus', 'out'],
|
||||||
|
['CommandOrControl+Subtract', 'out'],
|
||||||
|
['CommandOrControl+0', 'fit'],
|
||||||
|
];
|
||||||
|
for (const [accel, kind] of zoomBindings) {
|
||||||
|
try {
|
||||||
|
if (globalShortcut.register(accel, () => dispatchZoomShortcut(kind))) {
|
||||||
|
// Keep registering the other spellings so keyboards with different
|
||||||
|
// plus/minus translations still land on the same action.
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
// Invalid accelerators must not break startup.
|
||||||
|
}
|
||||||
|
}
|
||||||
const accel = settings.get('capture.hotkeyCapture');
|
const accel = settings.get('capture.hotkeyCapture');
|
||||||
const pauseAccel = settings.get('capture.hotkeyPauseResume');
|
const pauseAccel = settings.get('capture.hotkeyPauseResume');
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user