Use cwd as default dialog path
This commit is contained in:
+6
-5
@@ -372,16 +372,17 @@
|
||||
<script>
|
||||
|
||||
let workPath = document.getElementById("workPath");
|
||||
let webOrApp = amIWeb();
|
||||
// If empty or undefined use local folder as default
|
||||
if (workPath.value == '' || workPath.value == undefined ) {
|
||||
// workPath.value = process.cwd();
|
||||
workPath.value = '/tmp';
|
||||
//app.setPath('temp',process.cwd());
|
||||
if (webOrApp) {
|
||||
workPath.value = '/tmp';
|
||||
} else {
|
||||
workPath.value = process.cwd();
|
||||
}
|
||||
}
|
||||
// Open the default Layers tab
|
||||
document.getElementById("btnLayers").click();
|
||||
|
||||
let webOrApp = amIWeb();
|
||||
|
||||
if (webOrApp) {
|
||||
console.log('this script is not running in Node.js');
|
||||
|
||||
@@ -4,6 +4,10 @@ const { app, BrowserWindow, Menu, dialog, ipcMain, fs } = require('electron');
|
||||
// Fall back to software rendering instead of crashing on startup.
|
||||
app.disableHardwareAcceleration();
|
||||
|
||||
function getDefaultDialogPath() {
|
||||
return process.cwd();
|
||||
}
|
||||
|
||||
function createWindow () {
|
||||
const win = new BrowserWindow({
|
||||
width: 950,
|
||||
@@ -29,7 +33,7 @@ function createWindow () {
|
||||
click () {
|
||||
dialog.showOpenDialog(win,
|
||||
{ title : "Load configuration file",
|
||||
defaultPath : app.getPath('temp'),
|
||||
defaultPath : getDefaultDialogPath(),
|
||||
//buttonLabel : "Custom button",
|
||||
filters :[
|
||||
{name: 'Config file type', extensions: ['cfg']},
|
||||
@@ -55,7 +59,7 @@ function createWindow () {
|
||||
click () {
|
||||
dialog.showOpenDialog(win,
|
||||
{ title: "Select folder",
|
||||
defaultPath : app.getPath('temp'),
|
||||
defaultPath : getDefaultDialogPath(),
|
||||
properties:["openDirectory"]}
|
||||
).then(result => {
|
||||
setImmediate(function() {
|
||||
@@ -84,7 +88,7 @@ function createWindow () {
|
||||
click () {
|
||||
dialog.showSaveDialog(win,
|
||||
{ title : "Save configuration file",
|
||||
defaultPath : app.getPath('temp'),
|
||||
defaultPath : getDefaultDialogPath(),
|
||||
filters :[
|
||||
{name: 'Config file type', extensions: ['cfg']},
|
||||
{name: 'All Files', extensions: ['*']}
|
||||
@@ -249,7 +253,7 @@ ipcMain.on('browseFolder', (event, args) => {
|
||||
console.log('received a message: '+args);
|
||||
const senderWindow = BrowserWindow.fromWebContents(event.sender);
|
||||
dialog.showOpenDialog(senderWindow, { title: "Select folder",
|
||||
defaultPath : app.getPath('temp'),
|
||||
defaultPath : getDefaultDialogPath(),
|
||||
properties:["openDirectory"]}
|
||||
).then(result => {
|
||||
console.log(result)
|
||||
|
||||
Reference in New Issue
Block a user