提交 98d826a2 编写于 作者: I isidor

workbench.tips.enabled

fixes #16595
上级 c0587ff1
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information. * Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/ *--------------------------------------------------------------------------------------------*/
.monaco-workbench .part.editor.empty { .monaco-workbench .part.editor.empty.has-watermark {
background-position-y: calc(50% - 100px); background-position-y: calc(50% - 100px);
} }
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
'use strict'; 'use strict';
import 'vs/css!./watermark'; import 'vs/css!./watermark';
import { $ } from 'vs/base/browser/builder'; import { $, Builder } from 'vs/base/browser/builder';
import { IDisposable, dispose } from 'vs/base/common/lifecycle'; import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { assign } from 'vs/base/common/objects'; import { assign } from 'vs/base/common/objects';
import { isMacintosh } from 'vs/base/common/platform'; import { isMacintosh } from 'vs/base/common/platform';
...@@ -13,9 +13,11 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding'; ...@@ -13,9 +13,11 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import * as nls from 'vs/nls'; import * as nls from 'vs/nls';
import { Registry } from 'vs/platform/platform'; import { Registry } from 'vs/platform/platform';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'vs/platform/configuration/common/configurationRegistry';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace'; import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IWorkbenchContribution, IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions'; import { IWorkbenchContribution, IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle'; import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { GlobalQuickOpenAction } from 'vs/workbench/browser/parts/quickopen/quickopen.contribution'; import { GlobalQuickOpenAction } from 'vs/workbench/browser/parts/quickopen/quickopen.contribution';
import { KeybindingsReferenceAction, OpenRecentAction } from 'vs/workbench/electron-browser/actions'; import { KeybindingsReferenceAction, OpenRecentAction } from 'vs/workbench/electron-browser/actions';
import { ShowRecommendedKeymapExtensionsAction } from 'vs/workbench/parts/extensions/browser/extensionsActions'; import { ShowRecommendedKeymapExtensionsAction } from 'vs/workbench/parts/extensions/browser/extensionsActions';
...@@ -130,17 +132,34 @@ const UNBOUND = nls.localize('watermark.unboundCommand', "unbound"); ...@@ -130,17 +132,34 @@ const UNBOUND = nls.localize('watermark.unboundCommand', "unbound");
export class WatermarkContribution implements IWorkbenchContribution { export class WatermarkContribution implements IWorkbenchContribution {
private toDispose: IDisposable[] = []; private toDispose: IDisposable[] = [];
private watermark: Builder;
private enabled: boolean;
constructor( constructor(
@ILifecycleService lifecycleService: ILifecycleService, @ILifecycleService lifecycleService: ILifecycleService,
@IPartService private partService: IPartService, @IPartService private partService: IPartService,
@IKeybindingService private keybindingService: IKeybindingService, @IKeybindingService private keybindingService: IKeybindingService,
@IWorkspaceContextService private contextService: IWorkspaceContextService, @IWorkspaceContextService private contextService: IWorkspaceContextService,
@ITelemetryService private telemetryService: ITelemetryService @ITelemetryService private telemetryService: ITelemetryService,
@IConfigurationService private configurationService: IConfigurationService
) { ) {
lifecycleService.onShutdown(this.dispose, this); lifecycleService.onShutdown(this.dispose, this);
this.partService.joinCreation().then(() => { this.partService.joinCreation().then(() => {
this.create(); this.enabled = this.configurationService.lookup<boolean>('workbench.tips.enabled').value;
if (this.enabled) {
this.create();
}
});
this.configurationService.onDidUpdateConfiguration(e => {
const enabled = this.configurationService.lookup<boolean>('workbench.tips.enabled').value;
if (enabled !== this.enabled) {
this.enabled = enabled;
if (this.enabled) {
this.create();
} else {
this.destroy();
}
}
}); });
} }
...@@ -150,10 +169,11 @@ export class WatermarkContribution implements IWorkbenchContribution { ...@@ -150,10 +169,11 @@ export class WatermarkContribution implements IWorkbenchContribution {
private create(): void { private create(): void {
const container = this.partService.getContainer(Parts.EDITOR_PART); const container = this.partService.getContainer(Parts.EDITOR_PART);
container.classList.add('has-watermark');
const watermark = $() this.watermark = $()
.div({ 'class': 'watermark' }); .div({ 'class': 'watermark' });
const box = $(watermark) const box = $(this.watermark)
.div({ 'class': 'watermark-box' }); .div({ 'class': 'watermark-box' });
const folder = this.contextService.hasWorkspace(); const folder = this.contextService.hasWorkspace();
const newUser = this.telemetryService.getExperiments().showNewUserWatermark; const newUser = this.telemetryService.getExperiments().showNewUserWatermark;
...@@ -184,12 +204,20 @@ export class WatermarkContribution implements IWorkbenchContribution { ...@@ -184,12 +204,20 @@ export class WatermarkContribution implements IWorkbenchContribution {
container.classList[height <= 478 ? 'add' : 'remove']('max-height-478px'); container.classList[height <= 478 ? 'add' : 'remove']('max-height-478px');
}; };
update(); update();
watermark.build(container.firstElementChild as HTMLElement, 0); this.watermark.build(container.firstElementChild as HTMLElement, 0);
layout(); layout();
this.toDispose.push(this.keybindingService.onDidUpdateKeybindings(update)); this.toDispose.push(this.keybindingService.onDidUpdateKeybindings(update));
this.toDispose.push(this.partService.onEditorLayout(layout)); this.toDispose.push(this.partService.onEditorLayout(layout));
} }
private destroy(): void {
if (this.watermark) {
this.watermark.destroy();
this.partService.getContainer(Parts.EDITOR_PART).classList.remove('has-watermark');
this.dispose();
}
}
public dispose(): void { public dispose(): void {
this.toDispose = dispose(this.toDispose); this.toDispose = dispose(this.toDispose);
} }
...@@ -197,3 +225,17 @@ export class WatermarkContribution implements IWorkbenchContribution { ...@@ -197,3 +225,17 @@ export class WatermarkContribution implements IWorkbenchContribution {
Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench) Registry.as<IWorkbenchContributionsRegistry>(WorkbenchExtensions.Workbench)
.registerWorkbenchContribution(WatermarkContribution); .registerWorkbenchContribution(WatermarkContribution);
Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Configuration)
.registerConfiguration({
'id': 'workbench',
'order': 7,
'title': nls.localize('workbenchConfigurationTitle', "Workbench"),
'properties': {
'workbench.tips.enabled': {
'type': 'boolean',
'default': true,
'description': nls.localize('tips.enabled', "When enabled, will show the watermark tips when no editor is open.")
},
}
});
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册