Fix file save dialog default path for Linux KDE

This commit is contained in:
ayumi-signal
2025-03-12 09:11:33 -07:00
committed by GitHub
parent f4be6f6932
commit 1be2c07d7b
2 changed files with 15 additions and 2 deletions

View File

@@ -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,
}
);

View File

@@ -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,
};