提交 543dc0df 编写于 作者: B Benjamin Pasero

settings - prompt for restart for some

上级 846d59aa
......@@ -33,6 +33,7 @@ export interface IWindowsService {
clearRecentPathsList(): TPromise<void>;
getRecentlyOpen(windowId: number): TPromise<{ files: string[]; folders: string[]; }>;
focusWindow(windowId: number): TPromise<void>;
isFocused(windowId: number): TPromise<boolean>;
isMaximized(windowId: number): TPromise<boolean>;
maximizeWindow(windowId: number): TPromise<void>;
unmaximizeWindow(windowId: number): TPromise<void>;
......@@ -83,6 +84,7 @@ export interface IWindowService {
removeFromRecentlyOpen(paths: string[]): TPromise<void>;
getRecentlyOpen(): TPromise<{ files: string[]; folders: string[]; }>;
focusWindow(): TPromise<void>;
isFocused(): TPromise<boolean>;
setDocumentEdited(flag: boolean): TPromise<void>;
isMaximized(): TPromise<boolean>;
maximizeWindow(): TPromise<void>;
......
......@@ -27,6 +27,7 @@ export interface IWindowsChannel extends IChannel {
call(command: 'clearRecentPathsList'): TPromise<void>;
call(command: 'getRecentlyOpen', arg: number): TPromise<{ files: string[]; folders: string[]; }>;
call(command: 'focusWindow', arg: number): TPromise<void>;
call(command: 'isFocused', arg: number): TPromise<boolean>;
call(command: 'isMaximized', arg: number): TPromise<boolean>;
call(command: 'maximizeWindow', arg: number): TPromise<void>;
call(command: 'unmaximizeWindow', arg: number): TPromise<void>;
......@@ -76,6 +77,7 @@ export class WindowsChannel implements IWindowsChannel {
case 'clearRecentPathsList': return this.service.clearRecentPathsList();
case 'getRecentlyOpen': return this.service.getRecentlyOpen(arg);
case 'focusWindow': return this.service.focusWindow(arg);
case 'isFocused': return this.service.isFocused(arg);
case 'isMaximized': return this.service.isMaximized(arg);
case 'maximizeWindow': return this.service.maximizeWindow(arg);
case 'unmaximizeWindow': return this.service.unmaximizeWindow(arg);
......@@ -167,6 +169,10 @@ export class WindowsChannelClient implements IWindowsService {
return this.channel.call('focusWindow', windowId);
}
isFocused(windowId: number): TPromise<boolean> {
return this.channel.call('isFocused', windowId);
}
isMaximized(windowId: number): TPromise<boolean> {
return this.channel.call('isMaximized', windowId);
}
......
......@@ -74,6 +74,10 @@ export class WindowService implements IWindowService {
return this.windowsService.focusWindow(this.windowId);
}
isFocused(): TPromise<boolean> {
return this.windowsService.isFocused(this.windowId);
}
isMaximized(): TPromise<boolean> {
return this.windowsService.isMaximized(this.windowId);
}
......
......@@ -166,6 +166,16 @@ export class WindowsService implements IWindowsService, IDisposable {
return TPromise.as(null);
}
isFocused(windowId: number): TPromise<boolean> {
const vscodeWindow = this.windowsMainService.getWindowById(windowId);
if (vscodeWindow) {
return TPromise.as(vscodeWindow.win.isFocused());
}
return TPromise.as(null);
}
isMaximized(windowId: number): TPromise<boolean> {
const vscodeWindow = this.windowsMainService.getWindowById(windowId);
......
......@@ -82,6 +82,8 @@ import 'vs/workbench/electron-browser/workbench';
import 'vs/workbench/parts/trust/electron-browser/unsupportedWorkspaceSettings.contribution';
import 'vs/workbench/parts/relauncher/electron-browser/relauncher.contribution';
import 'vs/workbench/parts/tasks/electron-browser/task.contribution';
import 'vs/workbench/parts/emmet/browser/emmet.browser.contribution';
......
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
'use strict';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { IWorkbenchContributionsRegistry, IWorkbenchContribution, Extensions as WorkbenchExtensions } from 'vs/workbench/common/contributions';
import { Registry } from 'vs/platform/platform';
import { IMessageService } from 'vs/platform/message/common/message';
import { IPreferencesService } from 'vs/workbench/parts/preferences/common/preferences';
import { IWindowsService, IWindowService } from "vs/platform/windows/common/windows";
import { IConfigurationService } from "vs/platform/configuration/common/configuration";
import { IWindowConfiguration } from "vs/workbench/electron-browser/common";
import { localize } from "vs/nls";
import { IEnvironmentService } from "vs/platform/environment/common/environment";
interface IConfiguration extends IWindowConfiguration {
update: { channel: string; };
telemetry: { enableCrashReporter: boolean };
}
export class SettingsChangeRelauncher implements IWorkbenchContribution {
private toDispose: IDisposable[] = [];
private titleBarStyle: 'native' | 'custom';
private updateChannel: string;
private enableCrashReporter: boolean;
constructor(
@IWindowsService private windowsService: IWindowsService,
@IWindowService private windowService: IWindowService,
@IConfigurationService private configurationService: IConfigurationService,
@IPreferencesService private preferencesService: IPreferencesService,
@IEnvironmentService private envService: IEnvironmentService,
@IMessageService private messageService: IMessageService
) {
this.onConfigurationChange(configurationService.getConfiguration<IConfiguration>(), false);
this.registerListeners();
}
private registerListeners(): void {
this.toDispose.push(this.configurationService.onDidUpdateConfiguration(e => this.onConfigurationChange(e.config, true)));
}
private onConfigurationChange(config: IConfiguration, notify: boolean): void {
let changed = false;
// Titlebar style
if (config.window && config.window.titleBarStyle !== this.titleBarStyle && (config.window.titleBarStyle === 'native' || config.window.titleBarStyle === 'custom')) {
this.titleBarStyle = config.window.titleBarStyle;
changed = true;
}
// Update channel
if (config.update && config.update.channel !== this.updateChannel) {
this.updateChannel = config.update.channel;
changed = true;
}
// Crash reporter
if (config.telemetry && config.telemetry.enableCrashReporter !== this.enableCrashReporter) {
this.enableCrashReporter = config.telemetry.enableCrashReporter;
changed = true;
}
// Notify only when changed and we are the focused window (avoids notification spam across windows)
if (notify && changed) {
this.windowService.isFocused().then(focused => {
if (focused) {
const relaunch = this.messageService.confirm({
type: 'info',
message: localize('relaunchMessage', "A setting has changed that requires a restart to take effect."),
detail: localize('relaunchDetail', "Press the restart button to restart {0} and enable the setting.", this.envService.appNameLong),
primaryButton: localize('restart', "Restart")
});
if (relaunch) {
this.windowsService.relaunch(Object.create(null));
}
}
});
}
}
getId(): string {
return 'workbench.relauncher';
}
public dispose(): void {
this.toDispose = dispose(this.toDispose);
}
}
const workbenchRegistry = <IWorkbenchContributionsRegistry>Registry.as(WorkbenchExtensions.Workbench);
workbenchRegistry.registerWorkbenchContribution(SettingsChangeRelauncher);
......@@ -775,6 +775,10 @@ export class TestWindowService implements IWindowService {
public _serviceBrand: any;
isFocused(): TPromise<boolean> {
return TPromise.as(false);
}
getCurrentWindowId(): number {
return 0;
}
......@@ -886,6 +890,10 @@ export class TestWindowsService implements IWindowsService {
onWindowOpen: Event<number>;
onWindowFocus: Event<number>;
isFocused(windowId: number): TPromise<boolean> {
return TPromise.as(false);
}
openFileFolderPicker(windowId: number, forceNewWindow?: boolean): TPromise<void> {
return TPromise.as(void 0);
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册