提交 0c8a0750 编写于 作者: B Benjamin Pasero

touchbar - allow to disable/enable without restart

上级 5d8c2877
...@@ -23,7 +23,6 @@ import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/ ...@@ -23,7 +23,6 @@ import { IWorkbenchEnvironmentService } from 'vs/workbench/services/environment/
interface IConfiguration extends IWindowsConfiguration { interface IConfiguration extends IWindowsConfiguration {
update: { mode: string; }; update: { mode: string; };
telemetry: { enableCrashReporter: boolean }; telemetry: { enableCrashReporter: boolean };
keyboard: { touchbar: { enabled: boolean } };
workbench: { list: { horizontalScrolling: boolean }, useExperimentalGridLayout: boolean }; workbench: { list: { horizontalScrolling: boolean }, useExperimentalGridLayout: boolean };
debug: { console: { wordWrap: boolean } }; debug: { console: { wordWrap: boolean } };
} }
...@@ -36,7 +35,6 @@ export class SettingsChangeRelauncher extends Disposable implements IWorkbenchCo ...@@ -36,7 +35,6 @@ export class SettingsChangeRelauncher extends Disposable implements IWorkbenchCo
private clickThroughInactive: boolean; private clickThroughInactive: boolean;
private updateMode: string; private updateMode: string;
private enableCrashReporter: boolean; private enableCrashReporter: boolean;
private touchbarEnabled: boolean;
private treeHorizontalScrolling: boolean; private treeHorizontalScrolling: boolean;
private useGridLayout: boolean; private useGridLayout: boolean;
private debugConsoleWordWrap: boolean; private debugConsoleWordWrap: boolean;
...@@ -112,12 +110,6 @@ export class SettingsChangeRelauncher extends Disposable implements IWorkbenchCo ...@@ -112,12 +110,6 @@ export class SettingsChangeRelauncher extends Disposable implements IWorkbenchCo
this.enableCrashReporter = config.telemetry.enableCrashReporter; this.enableCrashReporter = config.telemetry.enableCrashReporter;
changed = true; changed = true;
} }
// macOS: Touchbar config
if (isMacintosh && config.keyboard && config.keyboard.touchbar && typeof config.keyboard.touchbar.enabled === 'boolean' && config.keyboard.touchbar.enabled !== this.touchbarEnabled) {
this.touchbarEnabled = config.keyboard.touchbar.enabled;
changed = true;
}
} }
// Notify only when changed and we are the focused window (avoids notification spam across windows) // Notify only when changed and we are the focused window (avoids notification spam across windows)
......
...@@ -213,7 +213,7 @@ export class ElectronWindow extends Disposable { ...@@ -213,7 +213,7 @@ export class ElectronWindow extends Disposable {
this._register(this.configurationService.onDidChangeConfiguration(e => { this._register(this.configurationService.onDidChangeConfiguration(e => {
if (e.affectsConfiguration('window.zoomLevel')) { if (e.affectsConfiguration('window.zoomLevel')) {
this.updateWindowZoomLevel(); this.updateWindowZoomLevel();
} else if (e.affectsConfiguration('keyboard.touchbar.ignored')) { } else if (e.affectsConfiguration('keyboard.touchbar.enabled') || e.affectsConfiguration('keyboard.touchbar.ignored')) {
this.updateTouchbarMenu(); this.updateTouchbarMenu();
} }
})); }));
...@@ -342,11 +342,8 @@ export class ElectronWindow extends Disposable { ...@@ -342,11 +342,8 @@ export class ElectronWindow extends Disposable {
} }
private updateTouchbarMenu(): void { private updateTouchbarMenu(): void {
if ( if (!isMacintosh) {
!isMacintosh || // macOS only return; // macOS only
!this.configurationService.getValue<boolean>('keyboard.touchbar.enabled') // disabled via setting
) {
return;
} }
// Dispose old // Dispose old
...@@ -368,36 +365,40 @@ export class ElectronWindow extends Disposable { ...@@ -368,36 +365,40 @@ export class ElectronWindow extends Disposable {
const actions: Array<MenuItemAction | Separator> = []; const actions: Array<MenuItemAction | Separator> = [];
const disabled = this.configurationService.getValue<boolean>('keyboard.touchbar.enabled') === false;
const ignoredItems = this.configurationService.getValue<string[]>('keyboard.touchbar.ignored') || [];
// Fill actions into groups respecting order // Fill actions into groups respecting order
this.touchBarDisposables.add(createAndFillInActionBarActions(this.touchBarMenu, undefined, actions)); this.touchBarDisposables.add(createAndFillInActionBarActions(this.touchBarMenu, undefined, actions));
// Convert into command action multi array // Convert into command action multi array
const items: ICommandAction[][] = []; const items: ICommandAction[][] = [];
let group: ICommandAction[] = []; let group: ICommandAction[] = [];
const ignoredItems = this.configurationService.getValue<string[]>('keyboard.touchbar.ignored') || []; if (!disabled) {
for (const action of actions) { for (const action of actions) {
// Command
if (action instanceof MenuItemAction) {
if (ignoredItems.indexOf(action.item.id) >= 0) {
continue; // ignored
}
// Command group.push(action.item);
if (action instanceof MenuItemAction) {
if (ignoredItems.indexOf(action.item.id) >= 0) {
continue; // ignored
} }
group.push(action.item); // Separator
} else if (action instanceof Separator) {
if (group.length) {
items.push(group);
}
// Separator group = [];
else if (action instanceof Separator) {
if (group.length) {
items.push(group);
} }
group = [];
} }
}
if (group.length) { if (group.length) {
items.push(group); items.push(group);
}
} }
// Only update if the actions have changed // Only update if the actions have changed
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册