1
0

Add context menu for files in tree view

This commit is contained in:
2025-05-26 20:20:34 +02:00
parent 5e318a1c51
commit 42595ad74b

28
main.js
View File

@@ -1392,4 +1392,32 @@ ipcMain.on('show-folder-context-menu', (event, folderPath) => {
menu.popup({ window: win });
});
ipcMain.on('show-tree-context-menu', (event, { absPath, relPath, root, type }) => {
const win = BrowserWindow.fromWebContents(event.sender);
const template = [
{
label: 'Open File',
click: () => shell.openPath(absPath),
visible: type === 'file' // Nur für Dateien anzeigen
},
{
label: 'Copy File Path',
click: () => clipboard.writeText(absPath)
},
{
label: 'Add to .gitignore',
click: () => {
const gitignore = path.join(root, '.gitignore');
fs.appendFile(gitignore, `\n${relPath}\n`, (err) => {
if (err) {
dialog.showErrorBox('Error', 'Konnte nicht zu .gitignore hinzufügen:\n' + err.message);
}
});
}
}
];
const menu = Menu.buildFromTemplate(template);
menu.popup({ window: win });
});