Added an edge-case helper for choosing files/directories in linux. This finishes the requirement for issue #50 on linux, but will test changes on macOS before marking the issue resolved.

This commit is contained in:
Matt McWilliams 2021-02-24 10:05:45 -05:00
parent 5061a511ab
commit fb7b1e2fb6
9 changed files with 61 additions and 14 deletions

View File

@ -2497,6 +2497,7 @@ const filmout = require('./lib/ui/filmout.js');
const mse = require('./lib/ui/mscript.js');
const Mscript = require('./lib/mscript');
const { delay } = require('./lib/delay');
let log;
/******

View File

@ -27,6 +27,7 @@ class FilmOut {
this.id = 'filmout';
this.videoExtensions = ['.mpg', '.mpeg', '.mov', '.mkv', '.avi', '.mp4'];
this.stillExtensions = ['.tif', '.tiff', '.png', '.jpg', '.jpeg', '.bmp'];
this.sequenceExtensions = ['.png', '.jpg', '.jpeg'];
this.gifExtension = '.gif';
this.state = {
frame: 0,
@ -346,7 +347,7 @@ class FilmOut {
}
frameList = frameList.filter((fileName) => {
let ext = path_1.extname(fileName);
if (this.stillExtensions.indexOf(ext) !== -1) {
if (this.sequenceExtensions.indexOf(ext) !== -1) {
return true;
}
return false;

File diff suppressed because one or more lines are too long

View File

@ -49,6 +49,7 @@ class FilmOut {
this.videoExtensions = ['.mpg', '.mpeg', '.mov', '.mkv', '.avi', '.mp4',
'.gif'];
this.stillExtensions = ['.tif', '.tiff', '.png', '.jpg', '.jpeg', '.bmp'];
this.sequenceExtensions = ['.png', '.jpg', '.jpeg'];
this.displays = [];
this.state = {
frame: 0,
@ -127,9 +128,10 @@ class FilmOut {
selectFile() {
return __awaiter(this, void 0, void 0, function* () {
const elem = $('#digital');
const properties = [`openFile`, `openDirectory`];
const options = {
title: `Select video or image sequence`,
properties: [`openFile`, `openDirectory`],
properties,
defaultPath: 'c:/',
filters: [
{
@ -143,6 +145,22 @@ class FilmOut {
let pathStr;
let displayName;
let ext;
const linuxMessage = `Do you want to use a single file (video or still image) or a folder containing an image sequence?`;
const linuxChoices = ['File', 'Folder', 'Cancel'];
let linuxChoice = 0;
if (process.platform === 'linux') {
linuxChoice = yield gui.choice(linuxMessage, linuxChoices);
console.log(linuxChoice);
if (linuxChoice === 0) {
options.properties = ['openFile'];
}
else if (linuxChoice === 1) {
options.properties = ['openDirectory'];
}
else {
return false;
}
}
try {
files = yield dialog.showOpenDialog(options);
}
@ -190,7 +208,7 @@ class FilmOut {
fileList = fs.readdirSync(pathStr);
fileList = fileList.filter((file) => {
let ext = path.extname(file).toLowerCase();
if (this.stillExtensions.indexOf(ext)) {
if (this.sequenceExtensions.indexOf(ext)) {
return true;
}
return false;
@ -221,7 +239,7 @@ class FilmOut {
fileName
};
if (filePath && filePath !== '') {
proceed = yield gui.confirm(`Are you sure you want to use ${fileName}?`);
proceed = yield gui.confirm(`Are you sure you want to use ${fileName}?`, 'No');
}
else {
this.selectFile();
@ -296,7 +314,7 @@ class FilmOut {
return __awaiter(this, void 0, void 0, function* () {
let proceed = false;
if (this.state.path && this.state.path !== '') {
proceed = yield gui.confirm(`Export all frames of ${this.state.name}? This may take a while, but will allow filmout sequences to run faster.`);
proceed = yield gui.confirm(`Export all frames of ${this.state.name}? This may take a while, but will allow filmout sequences to run faster.`, 'No');
}
if (proceed) {
gui.overlay(true);

File diff suppressed because one or more lines are too long

View File

@ -227,14 +227,23 @@ gui.info = async function (title, message) {
};
return dialog.showMessageBox(config);
};
gui.confirm = async function (message) {
gui.confirm = async function (message, cancel = 'Cancel') {
const config = {
buttons : ['Yes', 'Cancel'],
buttons : ['Yes', cancel],
message
}
const res = await dialog.showMessageBox(config);
return res.response === 0;
};
gui.choice = async function (message, choices) {
const config = {
buttons : choices,
defaultId : 0,
message
}
const res = await dialog.showMessageBox(config);
return res.response;
};
gui.warn = async function (title, message) {
'use strict';
const config = {

View File

@ -23,6 +23,7 @@ const filmout = require('./lib/ui/filmout.js');
const mse = require('./lib/ui/mscript.js');
const Mscript = require('./lib/mscript');
const { delay } = require('./lib/delay');
let log;
/******

View File

@ -47,6 +47,7 @@ class FilmOut {
private videoExtensions : string[] = ['.mpg', '.mpeg', '.mov', '.mkv', '.avi', '.mp4',
'.gif'];
private stillExtensions : string[] = ['.tif', '.tiff', '.png', '.jpg', '.jpeg', '.bmp'];
private sequenceExtensions : string[] = ['.png', '.jpg', '.jpeg'];
private displays : any[] = [];
private state : any = {
frame : 0,
@ -131,9 +132,10 @@ class FilmOut {
**/
async selectFile () {
const elem : any = $('#digital');
const properties : string[] = [`openFile`, `openDirectory`];
const options : any = {
title : `Select video or image sequence`,
properties : [`openFile`, `openDirectory`], // openDirectory, multiSelection, openFile
properties, // openDirectory, multiSelection, openFile
defaultPath: 'c:/',
filters : [
{
@ -147,6 +149,20 @@ class FilmOut {
let pathStr : string;
let displayName : string;
let ext : string;
const linuxMessage : string = `Do you want to use a single file (video or still image) or a folder containing an image sequence?`;
const linuxChoices : string[] = ['File', 'Folder', 'Cancel'];
let linuxChoice : number = 0;
if (process.platform === 'linux') {
linuxChoice = await gui.choice(linuxMessage, linuxChoices);
if (linuxChoice === 0) {
options.properties = ['openFile'];
} else if (linuxChoice === 1) {
options.properties = ['openDirectory'];
} else {
return false;
}
}
try {
files = await dialog.showOpenDialog(options);
@ -195,7 +211,7 @@ class FilmOut {
fileList = fs.readdirSync(pathStr);
fileList = fileList.filter((file : string) => {
let ext : string = path.extname(file).toLowerCase();
if (this.stillExtensions.indexOf(ext)) {
if (this.sequenceExtensions.indexOf(ext)) {
return true;
}
return false;
@ -227,7 +243,7 @@ class FilmOut {
};
if (filePath && filePath !== '') {
proceed = await gui.confirm(`Are you sure you want to use ${fileName}?`);
proceed = await gui.confirm(`Are you sure you want to use ${fileName}?`, 'No');
} else {
this.selectFile();
}
@ -306,7 +322,7 @@ class FilmOut {
let proceed = false;
if (this.state.path && this.state.path !== '') {
proceed = await gui.confirm(`Export all frames of ${this.state.name}? This may take a while, but will allow filmout sequences to run faster.`);
proceed = await gui.confirm(`Export all frames of ${this.state.name}? This may take a while, but will allow filmout sequences to run faster.`, 'No');
}
if (proceed) {

View File

@ -16,6 +16,7 @@ class FilmOut {
private id : string = 'filmout';
private videoExtensions : string[] = ['.mpg', '.mpeg', '.mov', '.mkv', '.avi', '.mp4'];
private stillExtensions : string[] = ['.tif', '.tiff', '.png', '.jpg', '.jpeg', '.bmp'];
private sequenceExtensions : string[] = ['.png', '.jpg', '.jpeg'];
private gifExtension : string = '.gif';
public state : any = {
frame : 0,
@ -356,7 +357,7 @@ class FilmOut {
frameList = frameList.filter((fileName : string) => {
let ext : string = extname(fileName);
if (this.stillExtensions.indexOf(ext) !== -1) {
if (this.sequenceExtensions.indexOf(ext) !== -1) {
return true;
}
return false;