From 9bc63240d4c5b9dc194d8efd83bc26faac63cd06 Mon Sep 17 00:00:00 2001 From: Xiang Chen Date: Sun, 22 Oct 2017 17:08:42 +0200 Subject: [PATCH] Show input dir in out path when file is loaded (#48) --- src/renderer.jsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/src/renderer.jsx b/src/renderer.jsx index 5a2f6acd..7deb9156 100644 --- a/src/renderer.jsx +++ b/src/renderer.jsx @@ -184,7 +184,7 @@ class App extends React.Component { setOutputDir() { dialog.showOpenDialog({ properties: ['openDirectory'] }, (paths) => { - this.setState({ outputDir: (paths && paths.length === 1) ? paths[0] : undefined }); + this.setState({ customOutDir: (paths && paths.length === 1) ? paths[0] : undefined }); }); } @@ -192,6 +192,12 @@ class App extends React.Component { return (this.state.filePath || '').replace(/#/g, '%23'); } + getOutputDir() { + if (this.state.customOutDir) return this.state.customOutDir; + if (this.state.filePath) return path.dirname(this.state.filePath); + return undefined; + } + toggleCaptureFormat() { const isPng = this.state.captureFormat === 'png'; this.setState({ captureFormat: isPng ? 'jpeg' : 'png' }); @@ -257,7 +263,7 @@ class App extends React.Component { } this.setState({ working: true }); - const outputDir = this.state.outputDir; + const outputDir = this.state.customOutDir; const fileFormat = this.state.fileFormat; try { return await ffmpeg.cut( @@ -283,7 +289,7 @@ class App extends React.Component { capture() { const filePath = this.state.filePath; - const outputDir = this.state.outputDir; + const outputDir = this.state.customOutDir; const currentTime = this.state.currentTime; const captureFormat = this.state.captureFormat; if (!filePath) return; @@ -400,10 +406,10 @@ class App extends React.Component {