set default path for open dialog

...to last opened path

fixes #724
see also #1092
pull/1233/head
Mikael Finstad 3 years ago
parent 51e224593a
commit 2364edad7f
No known key found for this signature in database
GPG Key ID: 25AB36E3E81CBC26

@ -2,7 +2,6 @@ const electron = require('electron'); // eslint-disable-line
const i18n = require('i18next');
const { Menu } = electron;
const { dialog } = electron;
const { homepage, getReleaseUrl, licensesPage } = require('./constants');
@ -17,9 +16,7 @@ module.exports = (app, mainWindow, newVersion) => {
label: i18n.t('Open'),
accelerator: 'CmdOrCtrl+O',
async click() {
const { canceled, filePaths } = await dialog.showOpenDialog({ properties: ['openFile', 'multiSelections'] });
if (canceled) return;
mainWindow.webContents.send('openFiles', filePaths);
mainWindow.webContents.send('openFilesDialog');
},
},
{

@ -101,6 +101,7 @@ const leftBarWidth = 240;
const videoStyle = { width: '100%', height: '100%', objectFit: 'contain' };
const bottomMotionStyle = { background: controlsBackground };
let lastOpenedPath;
const App = memo(() => {
// Per project state
@ -2044,6 +2045,8 @@ const App = memo(() => {
console.log('userOpenFiles');
console.log(filePaths.join('\n'));
[lastOpenedPath] = filePaths;
if (filePaths.length > 1) {
if (alwaysConcatMultipleFiles) {
batchLoadPaths(filePaths);
@ -2159,6 +2162,12 @@ const App = memo(() => {
}
}, [fileUri, usingPreviewFile, hasVideo, hasAudio, html5ifyAndLoadWithPreferences, customOutDir, filePath, setWorking]);
const openFilesDialog = useCallback(async () => {
const { canceled, filePaths } = await dialog.showOpenDialog({ properties: ['openFile', 'multiSelections'], defaultPath: lastOpenedPath });
if (canceled) return;
userOpenFiles(filePaths);
}, [userOpenFiles]);
useEffect(() => {
async function exportEdlFile2(e, type) {
if (!checkFileOpened()) return;
@ -2189,6 +2198,7 @@ const App = memo(() => {
const action = {
openFiles: (event, filePaths) => { userOpenFiles(filePaths.map(resolvePathIfNeeded)); },
openFilesDialog,
closeCurrentFile: () => { closeFileWithConfirm(); },
closeBatchFiles: () => { closeBatch(); },
html5ify: userHtml5ifyCurrentFile,
@ -2219,7 +2229,7 @@ const App = memo(() => {
const entries = Object.entries(action);
entries.forEach(([key, value]) => electron.ipcRenderer.on(key, value));
return () => entries.forEach(([key, value]) => electron.ipcRenderer.removeListener(key, value));
}, [apparentCutSegments, askSetStartTimeOffset, checkFileOpened, clearSegments, closeBatch, closeFileWithConfirm, concatCurrentBatch, createFixedDurationSegments, createNumSegments, createRandomSegments, customOutDir, cutSegments, detectBlackScenes, detectedFps, extractAllStreams, fileFormat, filePath, fillSegmentsGaps, getFrameCount, invertAllSegments, loadCutSegments, loadMedia, openSendReportDialogWithState, reorderSegsByStartTime, setWorking, shiftAllSegmentTimes, shuffleSegments, toggleHelp, toggleSettings, tryFixInvalidDuration, userHtml5ifyCurrentFile, userOpenFiles]);
}, [apparentCutSegments, askSetStartTimeOffset, checkFileOpened, clearSegments, closeBatch, closeFileWithConfirm, concatCurrentBatch, createFixedDurationSegments, createNumSegments, createRandomSegments, customOutDir, cutSegments, detectBlackScenes, detectedFps, extractAllStreams, fileFormat, filePath, fillSegmentsGaps, getFrameCount, invertAllSegments, loadCutSegments, loadMedia, openFilesDialog, openSendReportDialogWithState, reorderSegsByStartTime, setWorking, shiftAllSegmentTimes, shuffleSegments, toggleHelp, toggleSettings, tryFixInvalidDuration, userHtml5ifyCurrentFile, userOpenFiles]);
const showAddStreamSourceDialog = useCallback(async () => {
try {

Loading…
Cancel
Save