@@ -9,9 +9,9 @@ import { localize } from 'vs/nls';
9
9
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility' ;
10
10
import { Action2 } from 'vs/platform/actions/common/actions' ;
11
11
import { AudioCue , IAudioCueService } from 'vs/platform/audioCues/browser/audioCueService' ;
12
+ import { IConfigurationService } from 'vs/platform/configuration/common/configuration' ;
12
13
import { ServicesAccessor } from 'vs/platform/instantiation/common/instantiation' ;
13
14
import { IQuickInputService , IQuickPickItem } from 'vs/platform/quickinput/common/quickInput' ;
14
- import { IPreferencesService } from 'vs/workbench/services/preferences/common/preferences' ;
15
15
16
16
export class ShowAudioCueHelp extends Action2 {
17
17
static readonly ID = 'audioCues.help' ;
@@ -29,36 +29,45 @@ export class ShowAudioCueHelp extends Action2 {
29
29
30
30
override async run ( accessor : ServicesAccessor ) : Promise < void > {
31
31
const audioCueService = accessor . get ( IAudioCueService ) ;
32
- const quickPickService = accessor . get ( IQuickInputService ) ;
33
- const preferencesService = accessor . get ( IPreferencesService ) ;
32
+ const quickInputService = accessor . get ( IQuickInputService ) ;
33
+ const configurationService = accessor . get ( IConfigurationService ) ;
34
34
const accessibilityService = accessor . get ( IAccessibilityService ) ;
35
-
35
+ const userGestureCues = [ AudioCue . save , AudioCue . format ] ;
36
36
const items : ( IQuickPickItem & { audioCue : AudioCue } ) [ ] = AudioCue . allAudioCues . map ( ( cue , idx ) => ( {
37
- label : accessibilityService . isScreenReaderOptimized ( ) ?
38
- `${ cue . name } ${ audioCueService . isCueEnabled ( cue ) ? '' : ' (' + localize ( 'disabled' , "Disabled" ) + ')' } `
39
- : `${ audioCueService . isCueEnabled ( cue ) ? '$(check)' : ' ' } ${ cue . name } ` ,
37
+ label : userGestureCues . includes ( cue ) ? `${ cue . name } (${ configurationService . getValue ( cue . settingsKey ) } )` : cue . name ,
40
38
audioCue : cue ,
41
- buttons : [ {
39
+ buttons : userGestureCues . includes ( cue ) ? [ {
42
40
iconClass : ThemeIcon . asClassName ( Codicon . settingsGear ) ,
43
41
tooltip : localize ( 'audioCues.help.settings' , 'Enable/Disable Audio Cue' ) ,
44
- } ] ,
42
+ alwaysVisible : true
43
+ } ] : [ ]
45
44
} ) ) ;
46
-
47
- const quickPick = quickPickService . pick < IQuickPickItem & { audioCue : AudioCue } > (
48
- items ,
49
- {
50
- activeItem : items [ 0 ] ,
51
- onDidFocus : ( item ) => {
52
- audioCueService . playSound ( item . audioCue . sound . getSound ( true ) , true ) ;
53
- } ,
54
- onDidTriggerItemButton : ( context ) => {
55
- preferencesService . openSettings ( { query : context . item . audioCue . settingsKey } ) ;
56
- } ,
57
- placeHolder : localize ( 'audioCues.help.placeholder' , 'Select an audio cue to play' ) ,
45
+ const qp = quickInputService . createQuickPick < IQuickPickItem & { audioCue : AudioCue } > ( ) ;
46
+ qp . items = items ;
47
+ qp . selectedItems = items . filter ( i => audioCueService . isCueEnabled ( i . audioCue ) ) ;
48
+ qp . onDidAccept ( ( ) => {
49
+ const enabledCues = qp . selectedItems . map ( i => i . audioCue ) ;
50
+ const disabledCues = AudioCue . allAudioCues . filter ( cue => ! enabledCues . includes ( cue ) ) ;
51
+ for ( const cue of enabledCues ) {
52
+ if ( ! userGestureCues . includes ( cue ) ) {
53
+ configurationService . updateValue ( cue . settingsKey , accessibilityService . isScreenReaderOptimized ( ) ? 'auto' : 'on' ) ;
54
+ }
58
55
}
59
- ) ;
60
-
61
- await quickPick ;
56
+ for ( const cue of disabledCues ) {
57
+ if ( userGestureCues . includes ( cue ) ) {
58
+ configurationService . updateValue ( cue . settingsKey , 'never' ) ;
59
+ } else {
60
+ configurationService . updateValue ( cue . settingsKey , 'off' ) ;
61
+ }
62
+ }
63
+ qp . hide ( ) ;
64
+ } ) ;
65
+ qp . onDidChangeActive ( ( ) => {
66
+ audioCueService . playSound ( qp . activeItems [ 0 ] . audioCue . sound . getSound ( true ) , true ) ;
67
+ } ) ;
68
+ qp . placeholder = localize ( 'audioCues.help.placeholder' , 'Select an audio cue to play and configure' ) ;
69
+ qp . canSelectMany = true ;
70
+ await qp . show ( ) ;
62
71
}
63
72
}
64
73
@@ -78,32 +87,40 @@ export class ShowAccessibilityAlertHelp extends Action2 {
78
87
79
88
override async run ( accessor : ServicesAccessor ) : Promise < void > {
80
89
const audioCueService = accessor . get ( IAudioCueService ) ;
81
- const quickPickService = accessor . get ( IQuickInputService ) ;
82
- const preferencesService = accessor . get ( IPreferencesService ) ;
83
- const accessibilityService = accessor . get ( IAccessibilityService ) ;
84
-
85
- const items : ( IQuickPickItem & { audioCue : AudioCue } ) [ ] = AudioCue . allAudioCues . filter ( c => ! ! c . alertMessage ) . map ( ( cue , idx ) => ( {
86
- label : accessibilityService . isScreenReaderOptimized ( ) ?
87
- `${ cue . name } ${ audioCueService . isAlertEnabled ( cue ) ? '' : ' (' + localize ( 'disabled' , "Disabled" ) + ')' } `
88
- : `${ audioCueService . isAlertEnabled ( cue ) ? '$(check)' : ' ' } ${ cue . name } ` ,
90
+ const quickInputService = accessor . get ( IQuickInputService ) ;
91
+ const configurationService = accessor . get ( IConfigurationService ) ;
92
+ const userGestureAlerts = [ AudioCue . save , AudioCue . format ] ;
93
+ const items : ( IQuickPickItem & { audioCue : AudioCue } ) [ ] = AudioCue . allAudioCues . filter ( c => c . alertSettingsKey ) . map ( ( cue , idx ) => ( {
94
+ label : userGestureAlerts . includes ( cue ) && cue . alertSettingsKey ? `${ cue . name } (${ configurationService . getValue ( cue . alertSettingsKey ) } )` : cue . name ,
89
95
audioCue : cue ,
90
- buttons : [ {
96
+ buttons : userGestureAlerts . includes ( cue ) ? [ {
91
97
iconClass : ThemeIcon . asClassName ( Codicon . settingsGear ) ,
92
- tooltip : localize ( 'alerts.help.settings' , 'Enable/Disable Audio Cue' ) ,
93
- } ] ,
98
+ tooltip : localize ( 'alert.help.settings' , 'Enable/Disable Alert' ) ,
99
+ alwaysVisible : true
100
+ } ] : [ ]
94
101
} ) ) ;
95
-
96
- const quickPick = quickPickService . pick < IQuickPickItem & { audioCue : AudioCue } > (
97
- items ,
98
- {
99
- activeItem : items [ 0 ] ,
100
- onDidTriggerItemButton : ( context ) => {
101
- preferencesService . openSettings ( { query : context . item . audioCue . alertSettingsKey } ) ;
102
- } ,
103
- placeHolder : localize ( 'alerts.help.placeholder' , 'Inspect and configure the status of an alert' ) ,
102
+ const qp = quickInputService . createQuickPick < IQuickPickItem & { audioCue : AudioCue } > ( ) ;
103
+ qp . items = items ;
104
+ qp . selectedItems = items . filter ( i => audioCueService . isAlertEnabled ( i . audioCue ) ) ;
105
+ qp . onDidAccept ( ( ) => {
106
+ const enabledAlerts = qp . selectedItems . map ( i => i . audioCue ) ;
107
+ const disabledAlerts = AudioCue . allAudioCues . filter ( cue => ! enabledAlerts . includes ( cue ) ) ;
108
+ for ( const cue of enabledAlerts ) {
109
+ if ( ! userGestureAlerts . includes ( cue ) ) {
110
+ configurationService . updateValue ( cue . alertSettingsKey ! , true ) ;
111
+ }
104
112
}
105
- ) ;
106
-
107
- await quickPick ;
113
+ for ( const cue of disabledAlerts ) {
114
+ if ( userGestureAlerts . includes ( cue ) ) {
115
+ configurationService . updateValue ( cue . alertSettingsKey ! , 'never' ) ;
116
+ } else {
117
+ configurationService . updateValue ( cue . alertSettingsKey ! , false ) ;
118
+ }
119
+ }
120
+ qp . hide ( ) ;
121
+ } ) ;
122
+ qp . placeholder = localize ( 'alert.help.placeholder' , 'Select an alert to configure' ) ;
123
+ qp . canSelectMany = true ;
124
+ await qp . show ( ) ;
108
125
}
109
126
}
0 commit comments