Skip to content

Commit

Permalink
Edit tab double click
Browse files Browse the repository at this point in the history
  • Loading branch information
emulsion-io committed Oct 25, 2023
1 parent 0d2a3e2 commit 5c6075a
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 15 deletions.
38 changes: 33 additions & 5 deletions assets/js/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -68,4 +96,4 @@ window.app.handleOnglet((event, id) => {

}
})
})
}
8 changes: 0 additions & 8 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down
1 change: 0 additions & 1 deletion preload.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
});

Expand Down

0 comments on commit 5c6075a

Please sign in to comment.