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(
|
||||
'show-debug-log-save-dialog',
|
||||
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({
|
||||
defaultPath: 'debuglog.txt',
|
||||
defaultPath,
|
||||
showsTagField: false,
|
||||
});
|
||||
if (filePath) {
|
||||
@@ -3043,10 +3048,13 @@ ipc.handle('show-save-dialog', async (_event, { defaultPath }) => {
|
||||
return { canceled: true };
|
||||
}
|
||||
|
||||
// Workaround KDE portal file dialog default path issue
|
||||
const osDefaultPath = OS.isLinuxUsingKDE() ? `~/${defaultPath}` : defaultPath;
|
||||
|
||||
const { canceled, filePath: selectedFilePath } = await dialog.showSaveDialog(
|
||||
mainWindow,
|
||||
{
|
||||
defaultPath,
|
||||
defaultPath: osDefaultPath,
|
||||
showsTagField: false,
|
||||
}
|
||||
);
|
||||
|
@@ -23,9 +23,14 @@ function isWaylandEnabled(): boolean {
|
||||
return Boolean(process.env.WAYLAND_DISPLAY);
|
||||
}
|
||||
|
||||
function isLinuxUsingKDE(): boolean {
|
||||
return os.platform() === 'linux' && process.env.XDG_CURRENT_DESKTOP === 'KDE';
|
||||
}
|
||||
|
||||
const OS = {
|
||||
...getOSFunctions(os.release()),
|
||||
getLinuxName,
|
||||
isLinuxUsingKDE,
|
||||
isWaylandEnabled,
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user