Fix file save dialog default path for Linux KDE
This commit is contained in:
12
app/main.ts
12
app/main.ts
@@ -2658,8 +2658,13 @@ ipc.on('show-debug-log', showDebugLogWindow);
|
|||||||
ipc.on(
|
ipc.on(
|
||||||
'show-debug-log-save-dialog',
|
'show-debug-log-save-dialog',
|
||||||
async (_event: Electron.Event, logText: string) => {
|
async (_event: Electron.Event, logText: string) => {
|
||||||
|
// Workaround KDE portal file dialog default path issue
|
||||||
|
const defaultPath = OS.isLinuxUsingKDE()
|
||||||
|
? '~/debuglog.txt'
|
||||||
|
: 'debuglog.txt';
|
||||||
|
|
||||||
const { filePath } = await dialog.showSaveDialog({
|
const { filePath } = await dialog.showSaveDialog({
|
||||||
defaultPath: 'debuglog.txt',
|
defaultPath,
|
||||||
showsTagField: false,
|
showsTagField: false,
|
||||||
});
|
});
|
||||||
if (filePath) {
|
if (filePath) {
|
||||||
@@ -3043,10 +3048,13 @@ ipc.handle('show-save-dialog', async (_event, { defaultPath }) => {
|
|||||||
return { canceled: true };
|
return { canceled: true };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Workaround KDE portal file dialog default path issue
|
||||||
|
const osDefaultPath = OS.isLinuxUsingKDE() ? `~/${defaultPath}` : defaultPath;
|
||||||
|
|
||||||
const { canceled, filePath: selectedFilePath } = await dialog.showSaveDialog(
|
const { canceled, filePath: selectedFilePath } = await dialog.showSaveDialog(
|
||||||
mainWindow,
|
mainWindow,
|
||||||
{
|
{
|
||||||
defaultPath,
|
defaultPath: osDefaultPath,
|
||||||
showsTagField: false,
|
showsTagField: false,
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
@@ -23,9 +23,14 @@ function isWaylandEnabled(): boolean {
|
|||||||
return Boolean(process.env.WAYLAND_DISPLAY);
|
return Boolean(process.env.WAYLAND_DISPLAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function isLinuxUsingKDE(): boolean {
|
||||||
|
return os.platform() === 'linux' && process.env.XDG_CURRENT_DESKTOP === 'KDE';
|
||||||
|
}
|
||||||
|
|
||||||
const OS = {
|
const OS = {
|
||||||
...getOSFunctions(os.release()),
|
...getOSFunctions(os.release()),
|
||||||
getLinuxName,
|
getLinuxName,
|
||||||
|
isLinuxUsingKDE,
|
||||||
isWaylandEnabled,
|
isWaylandEnabled,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user