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

touchbar - allow to disable/enable without restart

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