This commit is contained in:
Eugene Pankov
2017-04-15 15:35:20 +02:00
parent c19f0b1895
commit 9c12669e8f
9 changed files with 94 additions and 102 deletions

View File

@@ -1,7 +1,7 @@
title-bar(*ngIf='!config.full().appearance.useNativeFrame && config.full().appearance.dock == "off"')
title-bar(*ngIf='!config.store.appearance.useNativeFrame && config.store.appearance.dock == "off"')
.content(
[class.tabs-on-top]='config.full().appearance.tabsOnTop'
[class.tabs-on-top]='config.store.appearance.tabsOnTop'
)
.tab-bar
button.btn.btn-secondary(

View File

@@ -110,7 +110,7 @@ export class AppRootComponent {
// unfocused, invisible
this.electron.app.window.show()
} else {
if (this.config.full().appearance.dock == 'off') {
if (this.config.store.appearance.dock == 'off') {
// not docked, visible
setTimeout(() => {
this.electron.app.window.focus()

View File

@@ -7,42 +7,36 @@ import { ConfigProvider } from '../api/configProvider'
export class ConfigProxy {
constructor (real: any, defaults: any, structure: any) {
for (let key in structure) {
if (!real[key]) {
real[key] = {}
}
let proxy = new ConfigProxy(real[key], defaults[key], structure[key])
Object.defineProperty(
this,
key,
{
enumerable: true,
configurable: false,
get: () => {
return proxy
},
}
)
}
constructor (real: any, defaults: any) {
for (let key in defaults) {
if (structure[key]) {
continue
}
Object.defineProperty(
this,
key,
{
enumerable: true,
configurable: false,
get: () => {
return real[key] || defaults[key]
},
set: (value) => {
real[key] = value
}
if (defaults[key] instanceof Object && Object.keys(defaults[key]).length > 0) {
if (!real[key]) {
real[key] = {}
}
)
let proxy = new ConfigProxy(real[key], defaults[key])
Object.defineProperty(
this,
key,
{
enumerable: true,
configurable: false,
get: () => proxy,
}
)
} else {
Object.defineProperty(
this,
key,
{
enumerable: true,
configurable: false,
get: () => real[key] || defaults[key],
set: (value) => {
real[key] = value
}
}
)
}
}
}
}
@@ -58,7 +52,6 @@ export class ConfigService {
restartRequested: boolean
private _store: any
private path: string
private configStructure: any = require('../defaultConfigStructure.yaml')
private defaultConfigValues: any = require('../defaultConfigValues.yaml')
constructor (
@@ -66,7 +59,6 @@ export class ConfigService {
@Inject(ConfigProvider) configProviders: ConfigProvider[],
) {
this.path = path.join(electron.app.getPath('userData'), 'config.yaml')
this.configStructure = configProviders.map(x => x.configStructure).reduce(configMerge, this.configStructure)
this.defaultConfigValues = configProviders.map(x => x.defaultConfigValues).reduce(configMerge, this.defaultConfigValues)
this.load()
}
@@ -77,7 +69,7 @@ export class ConfigService {
} else {
this._store = {}
}
this.store = new ConfigProxy(this._store, this.defaultConfigValues, this.configStructure)
this.store = new ConfigProxy(this._store, this.defaultConfigValues)
}
save (): void {

View File

@@ -19,14 +19,14 @@ export class DockingService {
dock () {
let display = this.electron.screen.getAllDisplays()
.filter((x) => x.id == this.config.full().appearance.dockScreen)[0]
.filter((x) => x.id == this.config.store.appearance.dockScreen)[0]
if (!display) {
display = this.getCurrentScreen()
}
let dockSide = this.config.full().appearance.dock
let dockSide = this.config.store.appearance.dock
let newBounds: Electron.Rectangle = { x: 0, y: 0, width: 0, height: 0 }
let fill = this.config.full().appearance.dockFill
let fill = this.config.store.appearance.dockFill
if (dockSide == 'off') {
this.hostApp.setAlwaysOnTop(false)

View File

@@ -89,8 +89,8 @@ export class HotkeysService {
getHotkeysConfig () {
let keys = {}
for (let key in this.config.full().hotkeys) {
let value = this.config.full().hotkeys[key]
for (let key in this.config.store.hotkeys) {
let value = this.config.store.hotkeys[key]
if (typeof value == 'string') {
value = [value]
}

View File

@@ -31,7 +31,7 @@ export class ThemesService {
}
applyCurrentTheme (): void {
let theme = this.findTheme(this.config.full().appearance.theme)
let theme = this.findTheme(this.config.store.appearance.theme)
if (!theme) {
theme = this.findTheme('Standard')
}