Allow configuration of default Settings

This commit is contained in:
Jonas Herzig 2018-10-08 19:38:29 +02:00
parent ad3669d8bc
commit 4482129330
2 changed files with 21 additions and 10 deletions

View file

@ -11,6 +11,17 @@ window.mumbleWebConfig = {
'username': true, 'username': true,
'password': true 'password': true
}, },
// Default values for user settings
// You can see your current value by typing `localStorage.getItem('mumble.$setting')` in the web console.
'settings': {
'voiceMode': 'vad', // one of 'cont' (Continuous), 'ptt' (Push-to-Talk), 'vad' (Voice Activity Detection)
'pttKey': 'ctrl + shift',
'vadLevel': 0.3,
'toolbarVertical': false,
'showAvatars': 'always', // one of 'always', 'own_channel', 'linked_channel', 'minimal_only', 'never'
'audioBitrate': 40000, // bits per second
'samplesPerPacket': 960
},
// Default values (can be changed by passing a query parameter of the same name) // Default values (can be changed by passing a query parameter of the same name)
'defaults': { 'defaults': {
// Connect Dialog // Connect Dialog

View file

@ -167,7 +167,7 @@ class SettingsDialog {
if (this._testVad) { if (this._testVad) {
this._testVad.end() this._testVad.end()
} }
let dummySettings = new Settings() let dummySettings = new Settings({})
this.applyTo(dummySettings) this.applyTo(dummySettings)
this._testVad = new VADVoiceHandler(null, dummySettings) this._testVad = new VADVoiceHandler(null, dummySettings)
this._testVad.on('started_talking', () => this.testVadActive(true)) this._testVad.on('started_talking', () => this.testVadActive(true))
@ -236,15 +236,15 @@ class SettingsDialog {
} }
class Settings { class Settings {
constructor () { constructor (defaults) {
const load = key => window.localStorage.getItem('mumble.' + key) const load = key => window.localStorage.getItem('mumble.' + key)
this.voiceMode = load('voiceMode') || 'vad' this.voiceMode = load('voiceMode') || defaults.voiceMode
this.pttKey = load('pttKey') || 'ctrl + shift' this.pttKey = load('pttKey') || defaults.pttKey
this.vadLevel = load('vadLevel') || 0.3 this.vadLevel = load('vadLevel') || defaults.vadLevel
this.toolbarVertical = load('toolbarVertical') || false this.toolbarVertical = load('toolbarVertical') || defaults.toolbarVertical
this.showAvatars = ko.observable(load('showAvatars') || 'always') this.showAvatars = ko.observable(load('showAvatars') || defaults.showAvatars)
this.audioBitrate = Number(load('audioBitrate')) || 40000 this.audioBitrate = Number(load('audioBitrate')) || defaults.audioBitrate
this.samplesPerPacket = Number(load('samplesPerPacket')) || 960 this.samplesPerPacket = Number(load('samplesPerPacket')) || defaults.samplesPerPacket
} }
save () { save () {
@ -262,7 +262,7 @@ class Settings {
class GlobalBindings { class GlobalBindings {
constructor (config) { constructor (config) {
this.config = config this.config = config
this.settings = new Settings() this.settings = new Settings(config.settings)
this.connector = new WorkerBasedMumbleConnector() this.connector = new WorkerBasedMumbleConnector()
this.client = null this.client = null
this.userContextMenu = new ContextMenu() this.userContextMenu = new ContextMenu()