mirror of
https://github.com/qvacua/vimr.git
synced 2024-11-23 19:21:53 +03:00
GH-326, GH-460 Persist last window action pref
This commit is contained in:
parent
884296145b
commit
6e9f33ea77
@ -40,6 +40,10 @@ class GeneralPref: PrefPane, UiComponent, NSTextFieldDelegate {
|
||||
|
||||
self.openWhenLaunchingCheckbox.boolState = state.openNewMainWindowOnLaunch
|
||||
self.openOnReactivationCheckbox.boolState = state.openNewMainWindowOnReactivation
|
||||
|
||||
self.lastWindowAction = state.afterLastWindowAction
|
||||
self.afterLastWindowPopup.selectItem(at: indexToAfterLastWindowAction.index(of: state.afterLastWindowAction) ?? 0)
|
||||
|
||||
self.ignorePatterns = state.openQuickly.ignorePatterns
|
||||
self.ignoreField.stringValue = FileItemIgnorePattern.toString(state.openQuickly.ignorePatterns)
|
||||
|
||||
@ -54,7 +58,12 @@ class GeneralPref: PrefPane, UiComponent, NSTextFieldDelegate {
|
||||
self.openOnReactivationCheckbox.boolState = state.openNewMainWindowOnReactivation
|
||||
}
|
||||
|
||||
|
||||
if self.lastWindowAction != state.afterLastWindowAction {
|
||||
self.afterLastWindowPopup.selectItem(
|
||||
at: indexToAfterLastWindowAction.index(of: state.afterLastWindowAction) ?? 0
|
||||
)
|
||||
}
|
||||
self.lastWindowAction = state.afterLastWindowAction
|
||||
})
|
||||
.disposed(by: self.disposeBag)
|
||||
}
|
||||
@ -62,6 +71,8 @@ class GeneralPref: PrefPane, UiComponent, NSTextFieldDelegate {
|
||||
fileprivate let emit: (Action) -> Void
|
||||
fileprivate let disposeBag = DisposeBag()
|
||||
|
||||
fileprivate var lastWindowAction = AppState.AfterLastWindowAction.doNothing
|
||||
|
||||
fileprivate let openWhenLaunchingCheckbox = NSButton(forAutoLayout: ())
|
||||
fileprivate let openOnReactivationCheckbox = NSButton(forAutoLayout: ())
|
||||
|
||||
@ -228,7 +239,6 @@ extension GeneralPref {
|
||||
}
|
||||
|
||||
func openUntitledWindowOnReactivationAction(_ sender: NSButton) {
|
||||
NSLog("\(self.openOnReactivationCheckbox.boolState)")
|
||||
self.emit(.setOpenOnReactivation(self.openOnReactivationCheckbox.boolState))
|
||||
}
|
||||
|
||||
@ -239,7 +249,8 @@ extension GeneralPref {
|
||||
return
|
||||
}
|
||||
|
||||
self.emit(.setAfterLastWindowAction(indexToAfterLastWindowAction[index]))
|
||||
self.lastWindowAction = indexToAfterLastWindowAction[index]
|
||||
self.emit(.setAfterLastWindowAction(self.lastWindowAction))
|
||||
}
|
||||
|
||||
fileprivate func ignorePatternsAction() {
|
||||
|
@ -16,6 +16,7 @@ class Keys {
|
||||
|
||||
static let openNewOnLaunch = "open-new-window-when-launching"
|
||||
static let openNewOnReactivation = "open-new-window-on-reactivation"
|
||||
static let afterLastWindowAction = "after-last-window-action"
|
||||
static let useSnapshotUpdateChannel = "use-snapshot-update-channel"
|
||||
|
||||
class OpenQuickly {
|
||||
|
@ -8,11 +8,11 @@ import RxSwift
|
||||
|
||||
struct AppState: SerializableState {
|
||||
|
||||
enum AfterLastWindowAction {
|
||||
enum AfterLastWindowAction: String {
|
||||
|
||||
case doNothing
|
||||
case hide
|
||||
case quit
|
||||
case doNothing = "do-nothing"
|
||||
case hide = "hide"
|
||||
case quit = "quit"
|
||||
}
|
||||
|
||||
static let `default` = AppState()
|
||||
@ -47,6 +47,11 @@ struct AppState: SerializableState {
|
||||
|
||||
self.openNewMainWindowOnLaunch = openOnLaunch
|
||||
self.openNewMainWindowOnReactivation = openOnReactivation
|
||||
|
||||
let lastWindowActionString = PrefUtils.string(from: dict, for: Keys.afterLastWindowAction)
|
||||
?? AfterLastWindowAction.doNothing.rawValue
|
||||
self.afterLastWindowAction = AfterLastWindowAction(rawValue: lastWindowActionString) ?? .doNothing
|
||||
|
||||
self.useSnapshotUpdate = useSnapshot
|
||||
|
||||
let openQuicklyDict = dict[Keys.OpenQuickly.key] as? [String: Any] ?? [:]
|
||||
@ -60,6 +65,7 @@ struct AppState: SerializableState {
|
||||
return [
|
||||
Keys.openNewOnLaunch: self.openNewMainWindowOnLaunch,
|
||||
Keys.openNewOnReactivation: self.openNewMainWindowOnReactivation,
|
||||
Keys.afterLastWindowAction: self.afterLastWindowAction.rawValue,
|
||||
Keys.useSnapshotUpdateChannel: self.useSnapshotUpdate,
|
||||
|
||||
Keys.OpenQuickly.key: self.openQuickly.dict(),
|
||||
|
Loading…
Reference in New Issue
Block a user