Skip to content

Commit

Permalink
Added open folder link to file menu
Browse files Browse the repository at this point in the history
  • Loading branch information
Mattk70 committed Mar 8, 2024
1 parent 97e9684 commit 2a1bab6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
6 changes: 5 additions & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -549,10 +549,14 @@ <h5>Saved Records</h5>
File
</a>
<ul class="dropdown-menu">
<li><a id="open" class="dropdown-item" href="#">
<li><a id="open-file" class="dropdown-item" href="#">
<span class="material-symbols-outlined">file_open</span> Open Audio
File(s) <span class="shortcut float-end">Ctrl+O</span></a>
</li>
<li><a id="open-folder" class="dropdown-item" href="#">
<span class="material-symbols-outlined">folder_open</span> Open
Folder(s)</a>
</li>
<div class="dropdown-divider"></div>
<li><a class="dropdown-item disabled" id="saveCSV" href="#">
<span class="material-symbols-outlined">ios_share</span> Export Results
Expand Down
17 changes: 12 additions & 5 deletions js/ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -453,9 +453,15 @@ function zoomSpec(direction) {
}
}

async function showOpenDialog() {
const files = await window.electron.openDialog('showOpenDialog', {type: 'audio'});
if (!files.canceled) await onOpenFiles({ filePaths: files.filePaths });
async function showOpenDialog(fileOrFolder) {
const files = await window.electron.openDialog('showOpenDialog', {type: 'audio', fileOrFolder: fileOrFolder});
if (!files.canceled) {
if (fileOrFolder === 'openFiles'){
await onOpenFiles({ filePaths: files.filePaths });
} else {
filterValidFiles({ filePaths: files.filePaths })
}
}
}

// function powerSave(on) {
Expand Down Expand Up @@ -2427,7 +2433,7 @@ function onChartData(args) {
if ( e.ctrlKey || e.metaKey) showGoToPosition();
},
KeyO: async function (e) {
if ( e.ctrlKey || e.metaKey) await showOpenDialog();
if ( e.ctrlKey || e.metaKey) await showOpenDialog('openFile');
},
KeyP: function () {
(typeof region !== 'undefined') ? region.play() : console.log('Region undefined')
Expand Down Expand Up @@ -4057,7 +4063,8 @@ DOM.gain.addEventListener('input', () => {
const target = e.target.closest('[id]')?.id;
switch (target)
{
case 'open': { showOpenDialog(); break }
case 'open-file': { showOpenDialog('openFile'); break }
case 'open-folder': { showOpenDialog('openDirectory'); break }
case 'saveLabels': { showSaveDialog(); break }
case 'saveCSV': { export2CSV(); break }
case 'export-audio': { exportAudio(); break }
Expand Down
4 changes: 2 additions & 2 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -379,14 +379,14 @@ app.whenReady().then(async () => {
});

ipcMain.handle('openFiles', async (_event, _method, config) => {
const {type} = config;
const {type, fileOrFolder} = config;
let options;
if (type === 'audio') {
options = {
filters: [
{ name: 'Audio Files', extensions: ['mp3', 'wav', 'ogg', 'aac', 'flac', 'm4a', 'mpga', 'mpeg', 'mp4', 'opus'] }
],
properties: ['openFile', 'multiSelections']
properties: [fileOrFolder, 'multiSelections']
}
} else {
options = {
Expand Down

0 comments on commit 2a1bab6

Please sign in to comment.