better messageboxes

This commit is contained in:
Eugene Pankov
2019-01-03 17:20:02 +03:00
parent d5b6a686f8
commit 9faa346699
8 changed files with 84 additions and 15 deletions

View File

@@ -5,7 +5,7 @@ import deepEqual = require('deep-equal')
const fontManager = require('font-manager')
import { Component, Inject } from '@angular/core'
import { ConfigService, HostAppService, Platform } from 'terminus-core'
import { ConfigService, HostAppService, Platform, ElectronService } from 'terminus-core'
import { TerminalColorSchemeProvider, ITerminalColorScheme } from '../api'
@Component({
@@ -22,6 +22,7 @@ export class AppearanceSettingsTabComponent {
constructor (
@Inject(TerminalColorSchemeProvider) private colorSchemeProviders: TerminalColorSchemeProvider[],
private hostApp: HostAppService,
private electron: ElectronService,
public config: ConfigService,
) { }
@@ -71,8 +72,16 @@ export class AppearanceSettingsTabComponent {
this.editingColorScheme = null
}
deleteScheme (scheme: ITerminalColorScheme) {
if (confirm(`Delete "${scheme.name}"?`)) {
async deleteScheme (scheme: ITerminalColorScheme) {
if ((await this.electron.showMessageBox(
this.hostApp.getWindow(),
{
type: 'warning',
message: `Delete "${scheme.name}"?`,
buttons: ['Keep', 'Delete'],
defaultId: 1,
}
)).response === 1) {
let schemes = this.config.store.terminal.customColorSchemes
schemes = schemes.filter(x => x !== scheme)
this.config.store.terminal.customColorSchemes = schemes

View File

@@ -48,10 +48,13 @@ export class ShellSettingsTabComponent {
pickWorkingDirectory () {
let shell = this.shells.find(x => x.id === this.config.store.terminal.shell)
console.log(shell)
let paths = this.electron.dialog.showOpenDialog({
defaultPath: shell.fsBase,
properties: ['openDirectory', 'showHiddenFiles'],
})
let paths = this.electron.dialog.showOpenDialog(
this.hostApp.getWindow(),
{
defaultPath: shell.fsBase,
properties: ['openDirectory', 'showHiddenFiles'],
}
)
if (paths) {
this.config.store.terminal.workingDirectory = paths[0]
}

View File

@@ -380,7 +380,15 @@ export class TerminalTabComponent extends BaseTabComponent {
if (children.length === 0) {
return true
}
return confirm(`"${children[0].command}" is still running. Close?`)
return (await this.electron.showMessageBox(
this.hostApp.getWindow(),
{
type: 'warning',
message: `"${children[0].command}" is still running. Close?`,
buttons: ['Cancel', 'Kill'],
defaultId: 1,
}
)).response === 1
}
async saveAsProfile () {