mirror of
https://github.com/Microsoft/vscode
synced 2024-09-13 13:46:13 +00:00
'about' global command
This commit is contained in:
parent
58674aeefd
commit
9408e89870
|
@ -9,8 +9,8 @@ import * as nls from 'vs/nls';
|
|||
import { isMacintosh, isLinux, isWindows, language } from 'vs/base/common/platform';
|
||||
import * as arrays from 'vs/base/common/arrays';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { ipcMain as ipc, app, shell, Menu, MenuItem, BrowserWindow, clipboard } from 'electron';
|
||||
import { OpenContext, IRunActionInWindowRequest } from 'vs/platform/windows/common/windows';
|
||||
import { ipcMain as ipc, app, shell, Menu, MenuItem, BrowserWindow } from 'electron';
|
||||
import { OpenContext, IRunActionInWindowRequest, IWindowsService } from 'vs/platform/windows/common/windows';
|
||||
import { IConfigurationService, IConfigurationChangeEvent } from 'vs/platform/configuration/common/configuration';
|
||||
import { AutoSaveConfiguration } from 'vs/platform/files/common/files';
|
||||
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
|
||||
|
@ -18,7 +18,7 @@ import { IUpdateService, StateType } from 'vs/platform/update/common/update';
|
|||
import product from 'vs/platform/node/product';
|
||||
import { RunOnceScheduler } from 'vs/base/common/async';
|
||||
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { mnemonicMenuLabel as baseMnemonicLabel, unmnemonicLabel, getPathLabel, mnemonicButtonLabel } from 'vs/base/common/labels';
|
||||
import { mnemonicMenuLabel as baseMnemonicLabel, unmnemonicLabel, getPathLabel } from 'vs/base/common/labels';
|
||||
import { KeybindingsResolver } from 'vs/code/electron-main/keyboard';
|
||||
import { IWindowsMainService, IWindowsCountChangedEvent } from 'vs/platform/windows/electron-main/windows';
|
||||
import { IHistoryMainService } from 'vs/platform/history/common/history';
|
||||
|
@ -69,6 +69,7 @@ export class CodeMenu {
|
|||
@IInstantiationService instantiationService: IInstantiationService,
|
||||
@IConfigurationService private configurationService: IConfigurationService,
|
||||
@IWindowsMainService private windowsMainService: IWindowsMainService,
|
||||
@IWindowsService private windowsService: IWindowsService,
|
||||
@IEnvironmentService private environmentService: IEnvironmentService,
|
||||
@ITelemetryService private telemetryService: ITelemetryService,
|
||||
@IHistoryMainService private historyMainService: IHistoryMainService
|
||||
|
@ -998,7 +999,7 @@ export class CodeMenu {
|
|||
}
|
||||
|
||||
helpMenu.append(__separator__());
|
||||
helpMenu.append(new MenuItem({ label: this.mnemonicLabel(nls.localize({ key: 'miAbout', comment: ['&& denotes a mnemonic'] }, "&&About")), click: () => this.openAboutDialog() }));
|
||||
helpMenu.append(new MenuItem({ label: this.mnemonicLabel(nls.localize({ key: 'miAbout', comment: ['&& denotes a mnemonic'] }, "&&About")), click: () => this.windowsService.openAboutDialog() }));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1206,39 +1207,6 @@ export class CodeMenu {
|
|||
return options;
|
||||
}
|
||||
|
||||
private openAboutDialog(): void {
|
||||
const lastActiveWindow = this.windowsMainService.getFocusedWindow() || this.windowsMainService.getLastActiveWindow();
|
||||
|
||||
const detail = nls.localize('aboutDetail',
|
||||
"Version {0}\nCommit {1}\nDate {2}\nShell {3}\nRenderer {4}\nNode {5}\nArchitecture {6}",
|
||||
app.getVersion(),
|
||||
product.commit || 'Unknown',
|
||||
product.date || 'Unknown',
|
||||
process.versions['electron'],
|
||||
process.versions['chrome'],
|
||||
process.versions['node'],
|
||||
process.arch
|
||||
);
|
||||
|
||||
const buttons = [nls.localize('okButton', "OK")];
|
||||
if (isWindows) {
|
||||
buttons.push(mnemonicButtonLabel(nls.localize({ key: 'copy', comment: ['&& denotes a mnemonic'] }, "&&Copy"))); // https://github.com/Microsoft/vscode/issues/37608
|
||||
}
|
||||
|
||||
this.windowsMainService.showMessageBox({
|
||||
title: product.nameLong,
|
||||
type: 'info',
|
||||
message: product.nameLong,
|
||||
detail: `\n${detail}`,
|
||||
buttons,
|
||||
noLink: true
|
||||
}, lastActiveWindow).then(result => {
|
||||
if (isWindows && result.button === 1) {
|
||||
clipboard.writeText(detail);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private openUrl(url: string, id: string): void {
|
||||
shell.openExternal(url);
|
||||
this.reportMenuActionTelemetry(id);
|
||||
|
|
|
@ -160,6 +160,8 @@ export interface IWindowsService {
|
|||
|
||||
// TODO: this is a bit backwards
|
||||
startCrashReporter(config: CrashReporterStartOptions): TPromise<void>;
|
||||
|
||||
openAboutDialog(): TPromise<void>;
|
||||
}
|
||||
|
||||
export const IWindowService = createDecorator<IWindowService>('windowService');
|
||||
|
|
|
@ -63,6 +63,7 @@ export interface IWindowsChannel extends IChannel {
|
|||
call(command: 'showItemInFolder', arg: string): TPromise<void>;
|
||||
call(command: 'openExternal', arg: string): TPromise<boolean>;
|
||||
call(command: 'startCrashReporter', arg: CrashReporterStartOptions): TPromise<void>;
|
||||
call(command: 'openAboutDialog'): TPromise<void>;
|
||||
call(command: string, arg?: any): TPromise<any>;
|
||||
}
|
||||
|
||||
|
@ -142,6 +143,7 @@ export class WindowsChannel implements IWindowsChannel {
|
|||
case 'showItemInFolder': return this.service.showItemInFolder(arg);
|
||||
case 'openExternal': return this.service.openExternal(arg);
|
||||
case 'startCrashReporter': return this.service.startCrashReporter(arg);
|
||||
case 'openAboutDialog': return this.service.openAboutDialog();
|
||||
}
|
||||
return undefined;
|
||||
}
|
||||
|
@ -345,4 +347,8 @@ export class WindowsChannelClient implements IWindowsService {
|
|||
updateTouchBar(windowId: number, items: ICommandAction[][]): TPromise<void> {
|
||||
return this.channel.call('updateTouchBar', [windowId, items]);
|
||||
}
|
||||
|
||||
openAboutDialog(): TPromise<void> {
|
||||
return this.channel.call('openAboutDialog');
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,13 +5,15 @@
|
|||
|
||||
'use strict';
|
||||
|
||||
import * as nls from 'vs/nls';
|
||||
import { TPromise } from 'vs/base/common/winjs.base';
|
||||
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
|
||||
import { assign } from 'vs/base/common/objects';
|
||||
import URI from 'vs/base/common/uri';
|
||||
import product from 'vs/platform/node/product';
|
||||
import { IWindowsService, OpenContext, INativeOpenDialogOptions, IEnterWorkspaceResult, IMessageBoxResult } from 'vs/platform/windows/common/windows';
|
||||
import { IEnvironmentService } from 'vs/platform/environment/common/environment';
|
||||
import { shell, crashReporter, app, Menu } from 'electron';
|
||||
import { shell, crashReporter, app, Menu, clipboard } from 'electron';
|
||||
import Event, { chain, fromNodeEventEmitter } from 'vs/base/common/event';
|
||||
import { IURLService } from 'vs/platform/url/common/url';
|
||||
import { ILifecycleService } from 'vs/platform/lifecycle/electron-main/lifecycleMain';
|
||||
|
@ -20,6 +22,8 @@ import { IHistoryMainService, IRecentlyOpened } from 'vs/platform/history/common
|
|||
import { IWorkspaceIdentifier, IWorkspaceFolderCreationData } from 'vs/platform/workspaces/common/workspaces';
|
||||
import { ICommandAction } from 'vs/platform/actions/common/actions';
|
||||
import { Schemas } from 'vs/base/common/network';
|
||||
import { mnemonicButtonLabel } from 'vs/base/common/labels';
|
||||
import { isWindows } from 'vs/base/common/platform';
|
||||
|
||||
export class WindowsService implements IWindowsService, IDisposable {
|
||||
|
||||
|
@ -409,6 +413,41 @@ export class WindowsService implements IWindowsService, IDisposable {
|
|||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
openAboutDialog(): TPromise<void> {
|
||||
const lastActiveWindow = this.windowsMainService.getFocusedWindow() || this.windowsMainService.getLastActiveWindow();
|
||||
|
||||
const detail = nls.localize('aboutDetail',
|
||||
"Version {0}\nCommit {1}\nDate {2}\nShell {3}\nRenderer {4}\nNode {5}\nArchitecture {6}",
|
||||
app.getVersion(),
|
||||
product.commit || 'Unknown',
|
||||
product.date || 'Unknown',
|
||||
process.versions['electron'],
|
||||
process.versions['chrome'],
|
||||
process.versions['node'],
|
||||
process.arch
|
||||
);
|
||||
|
||||
const buttons = [nls.localize('okButton', "OK")];
|
||||
if (isWindows) {
|
||||
buttons.push(mnemonicButtonLabel(nls.localize({ key: 'copy', comment: ['&& denotes a mnemonic'] }, "&&Copy"))); // https://github.com/Microsoft/vscode/issues/37608
|
||||
}
|
||||
|
||||
this.windowsMainService.showMessageBox({
|
||||
title: product.nameLong,
|
||||
type: 'info',
|
||||
message: product.nameLong,
|
||||
detail: `\n${detail}`,
|
||||
buttons,
|
||||
noLink: true
|
||||
}, lastActiveWindow).then(result => {
|
||||
if (isWindows && result.button === 1) {
|
||||
clipboard.writeText(detail);
|
||||
}
|
||||
});
|
||||
|
||||
return TPromise.as(null);
|
||||
}
|
||||
|
||||
private openFileForURI(uri: URI): TPromise<void> {
|
||||
const cli = assign(Object.create(null), this.environmentService.args, { goto: true });
|
||||
const pathsToOpen = [uri.fsPath];
|
||||
|
|
|
@ -1607,4 +1607,22 @@ export class ToggleWindowTabsBar extends Action {
|
|||
public run(): TPromise<boolean> {
|
||||
return this.windowsService.toggleWindowTabsBar().then(() => true);
|
||||
}
|
||||
}
|
||||
|
||||
export class ShowAboutDialogAction extends Action {
|
||||
|
||||
public static readonly ID = 'workbench.action.showAboutDialog';
|
||||
public static LABEL = nls.localize('about', "About {0}", product.applicationName);
|
||||
|
||||
constructor(
|
||||
id: string,
|
||||
label: string,
|
||||
@IWindowsService private windowsService: IWindowsService
|
||||
) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
run(): TPromise<void> {
|
||||
return this.windowsService.openAboutDialog();
|
||||
}
|
||||
}
|
|
@ -14,7 +14,7 @@ import { IConfigurationRegistry, Extensions as ConfigurationExtensions } from 'v
|
|||
import { IWorkbenchActionRegistry, Extensions } from 'vs/workbench/common/actions';
|
||||
import { KeyMod, KeyChord, KeyCode } from 'vs/base/common/keyCodes';
|
||||
import { isWindows, isLinux, isMacintosh } from 'vs/base/common/platform';
|
||||
import { KeybindingsReferenceAction, OpenDocumentationUrlAction, OpenIntroductoryVideosUrlAction, OpenTipsAndTricksUrlAction, OpenIssueReporterAction, ReportPerformanceIssueUsingReporterAction, ZoomResetAction, ZoomOutAction, ZoomInAction, ToggleFullScreenAction, ToggleMenuBarAction, CloseWorkspaceAction, CloseCurrentWindowAction, SwitchWindow, NewWindowAction, CloseMessagesAction, NavigateUpAction, NavigateDownAction, NavigateLeftAction, NavigateRightAction, IncreaseViewSizeAction, DecreaseViewSizeAction, ShowStartupPerformance, ToggleSharedProcessAction, QuickSwitchWindow, QuickOpenRecentAction, inRecentFilesPickerContextKey } from 'vs/workbench/electron-browser/actions';
|
||||
import { KeybindingsReferenceAction, OpenDocumentationUrlAction, OpenIntroductoryVideosUrlAction, OpenTipsAndTricksUrlAction, OpenIssueReporterAction, ReportPerformanceIssueUsingReporterAction, ZoomResetAction, ZoomOutAction, ZoomInAction, ToggleFullScreenAction, ToggleMenuBarAction, CloseWorkspaceAction, CloseCurrentWindowAction, SwitchWindow, NewWindowAction, CloseMessagesAction, NavigateUpAction, NavigateDownAction, NavigateLeftAction, NavigateRightAction, IncreaseViewSizeAction, DecreaseViewSizeAction, ShowStartupPerformance, ToggleSharedProcessAction, QuickSwitchWindow, QuickOpenRecentAction, inRecentFilesPickerContextKey, ShowAboutDialogAction } from 'vs/workbench/electron-browser/actions';
|
||||
import { MessagesVisibleContext } from 'vs/workbench/electron-browser/workbench';
|
||||
import { registerCommands } from 'vs/workbench/electron-browser/commands';
|
||||
import { AddRootFolderAction, GlobalRemoveRootFolderAction, OpenWorkspaceAction, SaveWorkspaceAsAction, OpenWorkspaceConfigFileAction, OpenFolderAsWorkspaceInNewWindowAction, OpenFileFolderAction, OpenFileAction, OpenFolderAction } from 'vs/workbench/browser/actions/workspaceActions';
|
||||
|
@ -65,6 +65,8 @@ if (OpenTipsAndTricksUrlAction.AVAILABLE) {
|
|||
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(OpenTipsAndTricksUrlAction, OpenTipsAndTricksUrlAction.ID, OpenTipsAndTricksUrlAction.LABEL), 'Help: Tips and Tricks', helpCategory);
|
||||
}
|
||||
|
||||
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ShowAboutDialogAction, ShowAboutDialogAction.ID, ShowAboutDialogAction.LABEL), 'Help: About', helpCategory);
|
||||
|
||||
workbenchActionsRegistry.registerWorkbenchAction(
|
||||
new SyncActionDescriptor(ZoomInAction, ZoomInAction.ID, ZoomInAction.LABEL, {
|
||||
primary: KeyMod.CtrlCmd | KeyCode.US_EQUAL,
|
||||
|
|
|
@ -16,7 +16,6 @@ import { Registry } from 'vs/platform/registry/common/platform';
|
|||
import { SyncActionDescriptor } from 'vs/platform/actions/common/actions';
|
||||
import { IMessageService, Severity } from 'vs/platform/message/common/message';
|
||||
import product from 'vs/platform/node/product';
|
||||
import IPackageConfiguration from 'vs/platform/node/package';
|
||||
|
||||
function ignore<T>(code: string, value: T = null): (err: any) => TPromise<T> {
|
||||
return err => err.code === code ? TPromise.as<T>(value) : TPromise.wrapError<T>(err);
|
||||
|
@ -144,30 +143,10 @@ class UninstallAction extends Action {
|
|||
}
|
||||
}
|
||||
|
||||
class ShowCodeVersion extends Action {
|
||||
public static readonly ID = 'workbench.action.showCodeVersion';
|
||||
public static LABEL = nls.localize('version', "Show version of '{0}' installed", product.applicationName);
|
||||
|
||||
constructor(
|
||||
id: string,
|
||||
label: string,
|
||||
@IMessageService private messageService: IMessageService
|
||||
) {
|
||||
super(id, label);
|
||||
}
|
||||
|
||||
|
||||
run(): TPromise<void> {
|
||||
this.messageService.show(Severity.Info, nls.localize('successFromVersion', "'{0}' version - {1}", product.applicationName, IPackageConfiguration.version));
|
||||
return TPromise.as(null);
|
||||
}
|
||||
}
|
||||
|
||||
if (process.platform === 'darwin') {
|
||||
const category = nls.localize('shellCommand', "Shell Command");
|
||||
|
||||
const workbenchActionsRegistry = Registry.as<IWorkbenchActionRegistry>(ActionExtensions.WorkbenchActions);
|
||||
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(InstallAction, InstallAction.ID, InstallAction.LABEL), 'Shell Command: Install \'code\' command in PATH', category);
|
||||
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(UninstallAction, UninstallAction.ID, UninstallAction.LABEL), 'Shell Command: Uninstall \'code\' command from PATH', category);
|
||||
workbenchActionsRegistry.registerWorkbenchAction(new SyncActionDescriptor(ShowCodeVersion, ShowCodeVersion.ID, ShowCodeVersion.LABEL), 'Shell Command: Show \'code\' version', category);
|
||||
}
|
||||
|
|
|
@ -1220,6 +1220,10 @@ export class TestWindowsService implements IWindowsService {
|
|||
showOpenDialog(windowId: number, options: Electron.OpenDialogOptions): TPromise<string[]> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
|
||||
openAboutDialog(): TPromise<void> {
|
||||
return TPromise.as(void 0);
|
||||
}
|
||||
}
|
||||
|
||||
export class TestTextResourceConfigurationService implements ITextResourceConfigurationService {
|
||||
|
|
Loading…
Reference in a new issue