mirror of
https://github.com/wavetermdev/waveterm.git
synced 2024-12-21 16:38:23 +01:00
Simple Quicklook (#998)
This adds some ability to use quicklook from the directory view with the spacebar on mac.
This commit is contained in:
parent
9dd4188810
commit
c43fd787a0
@ -787,6 +787,17 @@ if (unamePlatform !== "darwin") {
|
||||
});
|
||||
}
|
||||
|
||||
electron.ipcMain.on("quicklook", (event, filePath: string) => {
|
||||
if (unamePlatform == "darwin") {
|
||||
child_process.execFile("/usr/bin/qlmanage", ["-p", filePath], (error, stdout, stderr) => {
|
||||
if (error) {
|
||||
console.error(`Error opening Quick Look: ${error}`);
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
async function createNewWaveWindow(): Promise<void> {
|
||||
const clientData = await services.ClientService.GetClientData();
|
||||
const fullConfig = await services.FileService.GetFullConfig();
|
||||
|
@ -38,6 +38,7 @@ contextBridge.exposeInMainWorld("api", {
|
||||
registerGlobalWebviewKeys: (keys) => ipcRenderer.send("register-global-webview-keys", keys),
|
||||
onControlShiftStateUpdate: (callback) =>
|
||||
ipcRenderer.on("control-shift-state-update", (_event, state) => callback(state)),
|
||||
onQuicklook: (filePath: string) => ipcRenderer.send("quicklook", filePath),
|
||||
});
|
||||
|
||||
// Custom event for "new-window"
|
||||
|
@ -2,7 +2,7 @@
|
||||
// SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
import { ContextMenuModel } from "@/app/store/contextmenu";
|
||||
import { atoms, createBlock, getApi } from "@/app/store/global";
|
||||
import { PLATFORM, atoms, createBlock, getApi } from "@/app/store/global";
|
||||
import { FileService } from "@/app/store/services";
|
||||
import type { PreviewModel } from "@/app/view/preview/preview";
|
||||
import { checkKeyPressed, isCharacterKeyEvent } from "@/util/keyutil";
|
||||
@ -594,6 +594,11 @@ function DirectoryPreview({ model }: DirectoryPreviewProps) {
|
||||
setSearchText((current) => current.slice(0, -1));
|
||||
return true;
|
||||
}
|
||||
if (checkKeyPressed(waveEvent, "Space") && searchText == "" && PLATFORM == "darwin") {
|
||||
getApi().onQuicklook(selectedPath);
|
||||
console.log(selectedPath);
|
||||
return true;
|
||||
}
|
||||
if (isCharacterKeyEvent(waveEvent)) {
|
||||
setSearchText((current) => current + waveEvent.key);
|
||||
return true;
|
||||
@ -603,7 +608,7 @@ function DirectoryPreview({ model }: DirectoryPreviewProps) {
|
||||
return () => {
|
||||
model.directoryKeyDownHandler = null;
|
||||
};
|
||||
}, [filteredData, selectedPath]);
|
||||
}, [filteredData, selectedPath, searchText]);
|
||||
|
||||
useEffect(() => {
|
||||
if (filteredData.length != 0 && focusIndex > filteredData.length - 1) {
|
||||
|
1
frontend/types/custom.d.ts
vendored
1
frontend/types/custom.d.ts
vendored
@ -77,6 +77,7 @@ declare global {
|
||||
setWebviewFocus: (focusedId: number) => void; // focusedId si the getWebContentsId of the webview
|
||||
registerGlobalWebviewKeys: (keys: string[]) => void;
|
||||
onControlShiftStateUpdate: (callback: (state: boolean) => void) => void;
|
||||
onQuicklook: (filePath: string) => void;
|
||||
};
|
||||
|
||||
type ElectronContextMenuItem = {
|
||||
|
Loading…
Reference in New Issue
Block a user