Finishing touches on putting History off QML.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
parent
448d94fee3
commit
b91dbfb311
7 changed files with 12 additions and 119 deletions
|
@ -58,7 +58,6 @@ export class BaseEventEmitter {
|
|||
for(const type of eventType.split(" "))
|
||||
this.on(type, eventListener)
|
||||
else {
|
||||
console.log("Listening to", eventType)
|
||||
if(!this.constructor.emits.includes(eventType)) {
|
||||
const className = this.constructor.name
|
||||
const eventTypes = this.constructor.emits.join(", ")
|
||||
|
|
|
@ -29,6 +29,12 @@ class ClearedEvent extends BaseEvent {
|
|||
}
|
||||
}
|
||||
|
||||
class LoadedEvent extends BaseEvent {
|
||||
constructor() {
|
||||
super("loaded")
|
||||
}
|
||||
}
|
||||
|
||||
class AddedEvent extends BaseEvent {
|
||||
constructor(action) {
|
||||
super("added")
|
||||
|
@ -51,7 +57,7 @@ class RedoneEvent extends BaseEvent {
|
|||
}
|
||||
|
||||
class HistoryAPI extends Module {
|
||||
static emits = ["cleared", "added", "undone", "redone"]
|
||||
static emits = ["cleared", "loaded", "added", "undone", "redone"]
|
||||
|
||||
#helper
|
||||
|
||||
|
@ -154,7 +160,7 @@ class HistoryAPI extends Module {
|
|||
this.redoStack.push(
|
||||
new Actions[name](...args)
|
||||
)
|
||||
this.emit(new UpdatedEvent())
|
||||
this.emit(new LoadedEvent())
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -59,7 +59,6 @@ class IOAPI extends Module {
|
|||
})
|
||||
|
||||
// Settings.on("changed", this.__emitModified.bind(this))
|
||||
console.log("Init IO", this)
|
||||
History.on("added undone redone", this.__emitModified.bind(this))
|
||||
}
|
||||
|
||||
|
@ -125,6 +124,7 @@ class IOAPI extends Module {
|
|||
}
|
||||
Helper.write(filename, JSON.stringify(settings))
|
||||
this.#alert.show(qsTranslate("io", "Saved plot to '%1'.").arg(filename.split("/").pop()))
|
||||
this.#saved = true
|
||||
this.emit(new SavedEvent())
|
||||
}
|
||||
|
||||
|
@ -203,6 +203,7 @@ class IOAPI extends Module {
|
|||
}
|
||||
Canvas.redraw()
|
||||
this.#alert.show(qsTranslate("io", "Loaded file '%1'.").arg(basename))
|
||||
this.#saved = true
|
||||
this.emit(new LoadedEvent())
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue