diff --git a/assets/js/app.js b/assets/js/app.js index 8be3c01..29c5bef 100644 --- a/assets/js/app.js +++ b/assets/js/app.js @@ -44,12 +44,40 @@ const tab = tabGroup.addTab({ active: true }); -tabGroup.on("tab-active", (tab, tabGroup) => { - var idTab = tabGroup.getActiveTab().id; - window.app.getOnglet(idTab); +window.app.handleOnglet((event, id) => { + editOnglet() +}) + +tabGroup.on("tab-active", (tab, tabGroup) => { + ongletClick(tab); }); -window.app.handleOnglet((event, id) => { +let lastClickedTab = null; +let clickCount = 0; +let clickTimeout; +const doubleClickDelay = 300; + +function ongletClick(tab) { + clickCount++; + + if (clickCount === 1) { + clickTimeout = setTimeout(() => { + console.log('Clic simple sur l\'onglet'); + clickCount = 0; + }, doubleClickDelay); + } else if (clickCount === 2) { + if (tab === lastClickedTab) { + editOnglet(); + clickCount = 0; + } else { + clickCount = 1; + } + } + + lastClickedTab = tab; +} + +function editOnglet() { Swal.fire({ title: 'Change tab name', input: 'text', @@ -68,4 +96,4 @@ window.app.handleOnglet((event, id) => { } }) -}) \ No newline at end of file +} \ No newline at end of file diff --git a/main.js b/main.js index 9d5afdd..f6c74b8 100644 --- a/main.js +++ b/main.js @@ -205,14 +205,6 @@ ipcMain.on('on-top', () => { onTop(); }); -ipcMain.on('get-onglet', (event, tabID) => { - getOnglet(tabID); -}); - -function getOnglet(tabID) { - //tabID -} - function setOnglet() { mainWindow.webContents.send('update-onglet', 0) } diff --git a/package.json b/package.json index 9c8e1f9..ed1972e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "chatgpt-quake-mode", - "version": "1.4.0", + "version": "1.4.1", "description": "Open chatGPT in Quake mode", "main": "main.js", "scripts": { diff --git a/preload.js b/preload.js index ee6c2ce..18dc1a6 100644 --- a/preload.js +++ b/preload.js @@ -7,7 +7,6 @@ contextBridge.exposeInMainWorld('app', { reloadApp: () => ipcRenderer.send('reload-app'), hideApp: () => ipcRenderer.send('hide-app'), onTop: () => ipcRenderer.send('on-top'), - getOnglet: (tabID) => ipcRenderer.send('get-onglet', tabID), handleOnglet: (callback) => ipcRenderer.on('update-onglet', callback) });