提交 2a4cd323 编写于 作者: C Christof Marti

First session watermark (#15547)

上级 c6566148
......@@ -38,7 +38,7 @@ if (!!product.reportIssueUrl) {
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ReportIssueAction, ReportIssueAction.ID, ReportIssueAction.LABEL), 'Help: Report Issues', helpCategory);
}
if (KeybindingsReferenceAction.AVAILABLE) {
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(KeybindingsReferenceAction, KeybindingsReferenceAction.ID, KeybindingsReferenceAction.LABEL), 'Help: Keyboard Shortcuts Reference', helpCategory);
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(KeybindingsReferenceAction, KeybindingsReferenceAction.ID, KeybindingsReferenceAction.LABEL, { primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_R) }), 'Help: Keyboard Shortcuts Reference', helpCategory);
}
workbenchActionsRegistry.registerWorkbenchAction(
new SyncActionDescriptor(ZoomInAction, ZoomInAction.ID, ZoomInAction.LABEL, {
......
......@@ -5,7 +5,7 @@
import 'vs/css!./media/extensions';
import { localize } from 'vs/nls';
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes';
import { Registry } from 'vs/platform/platform';
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
......@@ -106,7 +106,7 @@ actionRegistry.registerWorkbenchAction(listOutdatedActionDescriptor, 'Extensions
const recommendationsActionDescriptor = new SyncActionDescriptor(ShowRecommendedExtensionsAction, ShowRecommendedExtensionsAction.ID, ShowRecommendedExtensionsAction.LABEL);
actionRegistry.registerWorkbenchAction(recommendationsActionDescriptor, 'Extensions: Show Recommended Extensions', ExtensionsLabel);
const keymapRecommendationsActionDescriptor = new SyncActionDescriptor(ShowRecommendedKeymapExtensionsAction, ShowRecommendedKeymapExtensionsAction.ID, ShowRecommendedKeymapExtensionsAction.SHORT_LABEL);
const keymapRecommendationsActionDescriptor = new SyncActionDescriptor(ShowRecommendedKeymapExtensionsAction, ShowRecommendedKeymapExtensionsAction.ID, ShowRecommendedKeymapExtensionsAction.SHORT_LABEL, { primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_M) });
actionRegistry.registerWorkbenchAction(keymapRecommendationsActionDescriptor, 'Preferences: Keymaps', PreferencesLabel);
const workspaceRecommendationsActionDescriptor = new SyncActionDescriptor(ShowWorkspaceRecommendedExtensionsAction, ShowWorkspaceRecommendedExtensionsAction.ID, ShowWorkspaceRecommendedExtensionsAction.LABEL);
......
......@@ -11,7 +11,7 @@ import { IEditorRegistry, Extensions as EditorExtensions } from 'vs/workbench/co
import { EditorDescriptor } from 'vs/workbench/browser/parts/editor/baseEditor';
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { KeyMod, KeyCode } from 'vs/base/common/keyCodes';
import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes';
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors';
import { DefaultSettingsEditor, DefaultSettingsInput, DefaultKeybindingsInput } from 'vs/workbench/parts/settings/browser/defaultSettingsEditors';
import { OpenGlobalSettingsAction, OpenGlobalKeybindingsAction, OpenWorkspaceSettingsAction } from 'vs/workbench/parts/settings/browser/openSettingsActions';
......@@ -40,5 +40,5 @@ registry.registerWorkbenchAction(new SyncActionDescriptor(OpenGlobalSettingsActi
primary: null,
mac: { primary: KeyMod.CtrlCmd | KeyCode.US_COMMA }
}), 'Preferences: Open User Settings', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenGlobalKeybindingsAction, OpenGlobalKeybindingsAction.ID, OpenGlobalKeybindingsAction.LABEL), 'Preferences: Open Keyboard Shortcuts', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenGlobalKeybindingsAction, OpenGlobalKeybindingsAction.ID, OpenGlobalKeybindingsAction.LABEL, { primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_S) }), 'Preferences: Open Keyboard Shortcuts', category);
registry.registerWorkbenchAction(new SyncActionDescriptor(OpenWorkspaceSettingsAction, OpenWorkspaceSettingsAction.ID, OpenWorkspaceSettingsAction.LABEL), 'Preferences: Open Workspace Settings', category);
\ No newline at end of file
......@@ -9,6 +9,7 @@ import { localize } from 'vs/nls';
import { TPromise } from 'vs/base/common/winjs.base';
import { Action } from 'vs/base/common/actions';
import { firstIndex } from 'vs/base/common/arrays';
import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes';
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
import { IMessageService, Severity } from 'vs/platform/message/common/message';
import { Registry } from 'vs/platform/platform';
......@@ -20,7 +21,7 @@ import { IExtensionGalleryService } from 'vs/platform/extensionManagement/common
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { Delayer } from 'vs/base/common/async';
class SelectColorThemeAction extends Action {
export class SelectColorThemeAction extends Action {
static ID = 'workbench.action.selectTheme';
static LABEL = localize('selectTheme.label', "Color Theme");
......@@ -146,7 +147,7 @@ function findInMarketplacePick(viewletService: IViewletService, query: string) {
const category = localize('preferences', "Preferences");
const colorThemeDescriptor = new SyncActionDescriptor(SelectColorThemeAction, SelectColorThemeAction.ID, SelectColorThemeAction.LABEL);
const colorThemeDescriptor = new SyncActionDescriptor(SelectColorThemeAction, SelectColorThemeAction.ID, SelectColorThemeAction.LABEL, { primary: KeyChord(KeyMod.CtrlCmd | KeyCode.KEY_K, KeyMod.CtrlCmd | KeyCode.KEY_T) });
Registry.as<IWorkbenchActionRegistry>(Extensions.WorkbenchActions).registerWorkbenchAction(colorThemeDescriptor, 'Preferences: Color Theme', category);
const iconThemeDescriptor = new SyncActionDescriptor(SelectIconThemeAction, SelectIconThemeAction.ID, SelectIconThemeAction.LABEL);
......
......@@ -11,13 +11,24 @@ import { assign } from 'vs/base/common/objects';
import { isMacintosh } from 'vs/base/common/platform';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import * as nls from 'vs/nls';
import { KeybindingsReferenceAction } from 'vs/workbench/electron-browser/actions';
import { Parts, IPartService } from 'vs/workbench/services/part/common/partService';
import { Registry } from 'vs/platform/platform';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
import { IWorkbenchContribution, IWorkbenchContributionsRegistry, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
import { ILifecycleService } from 'vs/platform/lifecycle/common/lifecycle';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { GlobalQuickOpenAction } from 'vs/workbench/browser/parts/quickopen/quickopen.contribution';
import { KeybindingsReferenceAction, OpenRecentAction } from 'vs/workbench/electron-browser/actions';
import { ShowRecommendedKeymapExtensionsAction } from 'vs/workbench/parts/extensions/browser/extensionsActions';
import { GlobalNewUntitledFileAction } from 'vs/workbench/parts/files/browser/fileActions';
import { OpenFolderAction, OpenFileAction, OpenFileFolderAction } from 'vs/workbench/parts/files/electron-browser/electronFileActions';
import { ShowAllCommandsAction } from 'vs/workbench/parts/quickopen/browser/commandsHandler';
import { Parts, IPartService } from 'vs/workbench/services/part/common/partService';
import { StartAction } from 'vs/workbench/parts/debug/browser/debugActions';
import { FindInFilesActionId } from 'vs/workbench/parts/search/common/constants';
import { OpenGlobalKeybindingsAction } from 'vs/workbench/parts/settings/browser/openSettingsActions';
import { ToggleTerminalAction } from 'vs/workbench/parts/terminal/electron-browser/terminalActions';
import { SelectColorThemeAction } from 'vs/workbench/parts/themes/electron-browser/themes.contribution';
interface WatermarkEntry {
text: string;
......@@ -27,69 +38,65 @@ interface WatermarkEntry {
const showCommands: WatermarkEntry = {
text: nls.localize('watermark.showCommands', "Show All Commands"),
ids: ['workbench.action.showCommands']
ids: [ShowAllCommandsAction.ID]
};
const quickOpen: WatermarkEntry = {
text: nls.localize('watermark.quickOpen', "Go to File"),
ids: ['workbench.action.quickOpen']
ids: [GlobalQuickOpenAction.ID]
};
const openFileNonMacOnly: WatermarkEntry = {
text: nls.localize('watermark.openFile', "Open File"),
ids: ['workbench.action.files.openFile'],
ids: [OpenFileAction.ID],
mac: false
};
const openFolderNonMacOnly: WatermarkEntry = {
text: nls.localize('watermark.openFolder', "Open Folder"),
ids: ['workbench.action.files.openFolder'],
ids: [OpenFolderAction.ID],
mac: false
};
const openFileOrFolderMacOnly: WatermarkEntry = {
text: nls.localize('watermark.openFileFolder', "Open File or Folder"),
ids: ['workbench.action.files.openFileFolder'],
ids: [OpenFileFolderAction.ID],
mac: true
};
const openRecent: WatermarkEntry = {
text: nls.localize('watermark.openRecent', "Open Recent"),
ids: ['workbench.action.openRecent']
ids: [OpenRecentAction.ID]
};
const newUntitledFile: WatermarkEntry = {
text: nls.localize('watermark.newUntitledFile', "New Untitled File"),
ids: ['workbench.action.files.newUntitledFile']
ids: [GlobalNewUntitledFileAction.ID]
};
const newUntitledFileMacOnly: WatermarkEntry = assign({ mac: true }, newUntitledFile);
const toggleTerminal: WatermarkEntry = {
text: nls.localize({ key: 'watermark.toggleTerminal', comment: ['toggle is a verb here'] }, "Toggle Terminal"),
ids: ['workbench.action.terminal.toggleTerminal']
ids: [ToggleTerminalAction.ID]
};
const findInFiles: WatermarkEntry = {
text: nls.localize('watermark.findInFiles', "Find in Files"),
ids: ['workbench.action.findInFiles']
ids: [FindInFilesActionId]
};
const startDebugging: WatermarkEntry = {
text: nls.localize('watermark.startDebugging', "Start Debugging"),
ids: ['workbench.action.debug.start']
ids: [StartAction.ID]
};
// TODO: default keybinding
const selectTheme: WatermarkEntry = {
text: nls.localize('watermark.selectTheme', "Change Color Theme"),
ids: ['workbench.action.selectTheme']
text: nls.localize('watermark.selectTheme', "Change Theme"),
ids: [SelectColorThemeAction.ID]
};
// TODO: requires #15159
const selectKeymap: WatermarkEntry = {
text: nls.localize('watermark.selectKeymap', "Change Keymap"),
ids: ['workbench.action.openGlobalKeybindings']
ids: [ShowRecommendedKeymapExtensionsAction.ID]
};
// TODO: default keybinding
const keybindingsReference: WatermarkEntry = {
text: nls.localize('watermark.keybindingsReference', "Keyboard Reference"),
ids: ['workbench.action.keybindingsReference']
ids: [KeybindingsReferenceAction.ID]
};
// TODO: default keybinding
const openGlobalKeybindings: WatermarkEntry = {
text: nls.localize('watermark.openGlobalKeybindings', "Keyboard Shortcuts"),
ids: ['workbench.action.openGlobalKeybindings']
ids: [OpenGlobalKeybindingsAction.ID]
};
const firstSessionEntries = [
......@@ -119,8 +126,6 @@ const folderEntries = [
toggleTerminal
];
const firstSession = false; // TODO: fix above TODOs first
const UNBOUND = nls.localize('watermark.unboundCommand', "unbound");
export class WatermarkContribution implements IWorkbenchContribution {
......@@ -132,6 +137,7 @@ export class WatermarkContribution implements IWorkbenchContribution {
@IPartService private partService: IPartService,
@IKeybindingService private keybindingService: IKeybindingService,
@IWorkspaceContextService private contextService: IWorkspaceContextService,
@IStorageService private storageService: IStorageService,
@ITelemetryService telemetryService: ITelemetryService
) {
if (telemetryService.getExperiments().showCommandsWatermark) {
......@@ -154,6 +160,7 @@ export class WatermarkContribution implements IWorkbenchContribution {
const box = $(watermark)
.div({ 'class': 'watermark-box' });
const folder = !!this.contextService.getWorkspace();
const firstSession = !this.storageService.get('telemetry.lastSessionDate');
const selected = (folder ? folderEntries : firstSession ? firstSessionEntries : noFolderEntries)
.filter(entry => !('mac' in entry) || entry.mac === isMacintosh);
const update = () => {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册