backend for EQ preset sharing(#289)

* added import/export to menu

* fix error

* oops

* added author to eq preset for later use

* Added error checking to EQ import

* made eq backend pass JSON objects instead of strings
This commit is contained in:
Swiftzerr 2022-01-31 22:39:04 -05:00 committed by GitHub
parent 3924c2fb87
commit 184eb55455
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -274,14 +274,14 @@
"icon": "./assets/feather/share.svg", "icon": "./assets/feather/share.svg",
"name": app.getLz('action.import'), "name": app.getLz('action.import'),
"action": function () { "action": function () {
notyf.error("Not implemented yet") this.importPreset()
} }
}, },
"export": { "export": {
"icon": "./assets/feather/share.svg", "icon": "./assets/feather/share.svg",
"name": app.getLz('action.export'), "name": app.getLz('action.export'),
"action": function () { "action": function () {
notyf.error("Not implemented yet") this.exportPreset()
} }
}, },
} }
@ -398,6 +398,29 @@
preset.vibrantBass = app.cfg.audio.equalizer.vibrantBass preset.vibrantBass = app.cfg.audio.equalizer.vibrantBass
notyf.success("Saved Preset") notyf.success("Saved Preset")
}, },
exportPreset() {
const preset = app.cfg.audio.equalizer.presets.find(p => p.preset == app.cfg.audio.equalizer.preset)
const jsonObj = {"name": preset.name, "author": app.chrome.userinfo.attributes.name, "frequency": preset.frequencies, "gain": preset.gain, "q": preset.Q, "preamp": preset.preamp, "mix": preset.mix, "vibrantBass": preset.vibrantBass};
ipcRenderer.send("export-eq", jsonObj)
},
importPreset() {
ipcRenderer.sendSync("import-eq").then((result) => {
let newPreset = new self.eqPreset()
newPreset.name = result.name
newPreset.author = result.author
newPreset.frequencies = result.frequency
newPreset.gain = result.gain
newPreset.Q = result.q
newPreset.preamp = result.preamp
newPreset.mix = result.mix
newPreset.vibrantBass = result.vibrantBass
app.cfg.audio.equalizer.presets.push(newPreset)
notyf.success("Imported preset " + result.name)
}).catch(err => {
console.error("[EQ Import] " + err)
notyf.error("Could not import preset")
})
},
applyPreset(preset) { applyPreset(preset) {
Object.assign(this.$root.cfg.audio.equalizer, preset) Object.assign(this.$root.cfg.audio.equalizer, preset)
this.changePreamp() this.changePreamp()