1
0
mirror of https://github.com/mifi/lossless-cut.git synced 2024-11-22 02:12:30 +01:00

Show input dir in out path when file is loaded (#48)

This commit is contained in:
Xiang Chen 2017-10-22 17:08:42 +02:00 committed by Mikael Finstad
parent 815fbc082a
commit 9bc63240d4

View File

@ -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 {
<div className="right-menu">
<button
title={`Custom output dir (cancel to restore default). Current: ${this.state.outputDir || 'Not set (use input dir)'}`}
title={`Custom output dir (cancel to restore default). Current: ${this.getOutputDir() || 'Not set (use input dir)'}`}
onClick={withBlur(() => this.setOutputDir())}
>
{this.state.outputDir ? `...${this.state.outputDir.substr(-10)}` : 'OUT PATH'}
{this.getOutputDir() ? `...${this.getOutputDir().substr(-10)}` : 'OUT PATH'}
</button>
<button title="Format">
{this.state.fileFormat || 'FMT'}