From 7252fd2017e4cafe9fe8a4b7bf90c45578923267 Mon Sep 17 00:00:00 2001 From: isidor Date: Wed, 11 Sep 2019 12:43:01 +0200 Subject: [PATCH] dialogService: allow checkboxes for show --- src/vs/platform/dialogs/browser/dialogService.ts | 7 +++++-- src/vs/platform/dialogs/common/dialogs.ts | 4 ++++ .../services/dialogs/electron-browser/dialogService.ts | 6 ++++-- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/src/vs/platform/dialogs/browser/dialogService.ts b/src/vs/platform/dialogs/browser/dialogService.ts index 517651193d1..5ddc105e993 100644 --- a/src/vs/platform/dialogs/browser/dialogService.ts +++ b/src/vs/platform/dialogs/browser/dialogService.ts @@ -97,7 +97,9 @@ export class DialogService implements IDialogService { EventHelper.stop(event, true); } } - } + }, + checkboxLabel: options && options.checkbox ? options.checkbox.label : undefined, + checkboxChecked: options && options.checkbox ? options.checkbox.checked : undefined }); dialogDisposables.add(dialog); @@ -107,7 +109,8 @@ export class DialogService implements IDialogService { dialogDisposables.dispose(); return { - choice: result.button + choice: result.button, + checkboxChecked: result.checkboxChecked }; } } diff --git a/src/vs/platform/dialogs/common/dialogs.ts b/src/vs/platform/dialogs/common/dialogs.ts index 2081f736eb4..e4d26726470 100644 --- a/src/vs/platform/dialogs/common/dialogs.ts +++ b/src/vs/platform/dialogs/common/dialogs.ts @@ -143,6 +143,10 @@ export const IDialogService = createDecorator('dialogService'); export interface IDialogOptions { cancelId?: number; detail?: string; + checkbox?: { + label: string; + checked?: boolean; + }; } /** diff --git a/src/vs/workbench/services/dialogs/electron-browser/dialogService.ts b/src/vs/workbench/services/dialogs/electron-browser/dialogService.ts index 7e3f18bd489..49c83de1fc2 100644 --- a/src/vs/workbench/services/dialogs/electron-browser/dialogService.ts +++ b/src/vs/workbench/services/dialogs/electron-browser/dialogService.ts @@ -137,11 +137,13 @@ class NativeDialogService implements IDialogService { buttons, type: (severity === Severity.Info) ? 'question' : (severity === Severity.Error) ? 'error' : (severity === Severity.Warning) ? 'warning' : 'none', cancelId: dialogOptions ? dialogOptions.cancelId : undefined, - detail: dialogOptions ? dialogOptions.detail : undefined + detail: dialogOptions ? dialogOptions.detail : undefined, + checkboxLabel: dialogOptions && dialogOptions.checkbox ? dialogOptions.checkbox.label : undefined, + checkboxChecked: dialogOptions && dialogOptions.checkbox ? dialogOptions.checkbox.checked : undefined }); const result = await this.windowService.showMessageBox(options); - return { choice: buttonIndexMap[result.button] }; + return { choice: buttonIndexMap[result.button], checkboxChecked: result.checkboxChecked }; } private massageMessageBoxOptions(options: Electron.MessageBoxOptions): IMassagedMessageBoxOptions { -- GitLab