mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-19 18:45:15 +02:00
toggle, blur-dismiss, and titlebar for quick-ask window
This commit is contained in:
parent
d033e1cb48
commit
985299b72d
1 changed files with 14 additions and 2 deletions
|
|
@ -6,6 +6,12 @@ import { getServerPort } from './server';
|
||||||
const SHORTCUT = 'CommandOrControl+Option+S';
|
const SHORTCUT = 'CommandOrControl+Option+S';
|
||||||
let quickAskWindow: BrowserWindow | null = null;
|
let quickAskWindow: BrowserWindow | null = null;
|
||||||
|
|
||||||
|
function hideQuickAsk(): void {
|
||||||
|
if (quickAskWindow && !quickAskWindow.isDestroyed()) {
|
||||||
|
quickAskWindow.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
function createQuickAskWindow(x: number, y: number): BrowserWindow {
|
function createQuickAskWindow(x: number, y: number): BrowserWindow {
|
||||||
if (quickAskWindow && !quickAskWindow.isDestroyed()) {
|
if (quickAskWindow && !quickAskWindow.isDestroyed()) {
|
||||||
quickAskWindow.setPosition(x, y);
|
quickAskWindow.setPosition(x, y);
|
||||||
|
|
@ -19,9 +25,8 @@ function createQuickAskWindow(x: number, y: number): BrowserWindow {
|
||||||
height: 550,
|
height: 550,
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
alwaysOnTop: true,
|
|
||||||
resizable: true,
|
resizable: true,
|
||||||
frame: false,
|
titleBarStyle: 'hiddenInset',
|
||||||
webPreferences: {
|
webPreferences: {
|
||||||
preload: path.join(__dirname, 'preload.js'),
|
preload: path.join(__dirname, 'preload.js'),
|
||||||
contextIsolation: true,
|
contextIsolation: true,
|
||||||
|
|
@ -38,6 +43,8 @@ function createQuickAskWindow(x: number, y: number): BrowserWindow {
|
||||||
quickAskWindow?.show();
|
quickAskWindow?.show();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
quickAskWindow.on('blur', hideQuickAsk);
|
||||||
|
|
||||||
quickAskWindow.on('closed', () => {
|
quickAskWindow.on('closed', () => {
|
||||||
quickAskWindow = null;
|
quickAskWindow = null;
|
||||||
});
|
});
|
||||||
|
|
@ -47,6 +54,11 @@ function createQuickAskWindow(x: number, y: number): BrowserWindow {
|
||||||
|
|
||||||
export function registerQuickAsk(): void {
|
export function registerQuickAsk(): void {
|
||||||
const ok = globalShortcut.register(SHORTCUT, () => {
|
const ok = globalShortcut.register(SHORTCUT, () => {
|
||||||
|
if (quickAskWindow && !quickAskWindow.isDestroyed() && quickAskWindow.isVisible()) {
|
||||||
|
hideQuickAsk();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const text = clipboard.readText().trim();
|
const text = clipboard.readText().trim();
|
||||||
if (!text) return;
|
if (!text) return;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue