mirror of
https://github.com/zadam/trilium.git
synced 2025-03-01 14:22:32 +01:00
Open new window from taskbar
This commit is contained in:
parent
a18ac7c504
commit
e5213640d7
@ -7,7 +7,7 @@ import log from "./log.js";
|
||||
import sqlInit from "./sql_init.js";
|
||||
import cls from "./cls.js";
|
||||
import keyboardActionsService from "./keyboard_actions.js";
|
||||
import remoteMain from "@electron/remote/main/index.js"
|
||||
import remoteMain from "@electron/remote/main/index.js";
|
||||
import { App, BrowserWindow, WebContents, ipcMain } from 'electron';
|
||||
|
||||
import { fileURLToPath } from "url";
|
||||
@ -46,6 +46,17 @@ ipcMain.on('create-extra-window', (event, arg) => {
|
||||
});
|
||||
|
||||
async function createMainWindow(app: App) {
|
||||
app.setUserTasks([
|
||||
{
|
||||
program: process.execPath,
|
||||
arguments: '--new-window',
|
||||
iconPath: process.execPath,
|
||||
iconIndex: 0,
|
||||
title: 'Open New Window',
|
||||
description: 'Open new window'
|
||||
}
|
||||
]);
|
||||
|
||||
const windowStateKeeper = (await import('electron-window-state')).default; // should not be statically imported
|
||||
|
||||
const mainWindowState = windowStateKeeper({
|
||||
@ -57,7 +68,7 @@ async function createMainWindow(app: App) {
|
||||
const spellcheckEnabled = optionService.getOptionBool('spellCheckEnabled');
|
||||
|
||||
const { BrowserWindow } = (await import('electron')); // should not be statically imported
|
||||
|
||||
|
||||
mainWindow = new BrowserWindow({
|
||||
x: mainWindowState.x,
|
||||
y: mainWindowState.y,
|
||||
@ -82,10 +93,12 @@ async function createMainWindow(app: App) {
|
||||
|
||||
configureWebContents(mainWindow.webContents, spellcheckEnabled);
|
||||
|
||||
app.on('second-instance', () => {
|
||||
// Someone tried to run a second instance, we should focus our window.
|
||||
// see www.ts "requestSingleInstanceLock" for the rest of this logic with explanation
|
||||
if (mainWindow) {
|
||||
app.on('second-instance', (event, commandLine) => {
|
||||
if (commandLine.includes('--new-window')) {
|
||||
createExtraWindow("");
|
||||
} else if (mainWindow) {
|
||||
// Someone tried to run a second instance, we should focus our window.
|
||||
// see www.ts "requestSingleInstanceLock" for the rest of this logic with explanation
|
||||
if (mainWindow.isMinimized()) {
|
||||
mainWindow.restore();
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user