Added sound settings tab in the preferences dialog. Only available options there are input and output device

This commit is contained in:
2019-03-28 08:57:48 -06:00
parent 8f631cfe4b
commit 0b2c3fa96e
4 changed files with 76 additions and 7 deletions

View File

@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
import sound_lib.input, sound_lib.output
import config
from mysc import restart
from . import base
@@ -9,6 +10,8 @@ class configurationPresenter(base.basePresenter):
def __init__(self, session, view, interactor):
self.session = session
super(configurationPresenter, self).__init__(view=view, interactor=interactor, modulename="configuration")
# Control requirement for a restart of the application.
self.needs_restart = False
self.create_config()
self.run()
@@ -57,6 +60,11 @@ class configurationPresenter(base.basePresenter):
self.send_message("set", tab="startup", setting="audio_albums", value=self.session.settings["load_at_startup"]["audio_albums"])
self.send_message("set", tab="startup", setting="video_albums", value=self.session.settings["load_at_startup"]["video_albums"])
self.send_message("set", tab="startup", setting="communities", value=self.session.settings["load_at_startup"]["communities"])
self.input_devices = sound_lib.input.Input.get_device_names()
self.output_devices = sound_lib.output.Output.get_device_names()
self.send_message("create_tab", tab="sound", arglist=dict(input_devices=self.input_devices, output_devices=self.output_devices, soundpacks=[]))
self.send_message("set", tab="sound", setting="input", value=config.app["sound"]["input_device"])
self.send_message("set", tab="sound", setting="output", value=config.app["sound"]["output_device"])
def update_setting(self, section, setting, value):
if section not in self.session.settings:
@@ -68,10 +76,21 @@ class configurationPresenter(base.basePresenter):
def save_settings_file(self):
self.session.settings.write()
def update_proxy(self, proxy_value):
if proxy_value != config.app["app-settings"]["use_proxy"]:
config.app["app-settings"]["use_proxy"] = proxy_value
config.app.write()
def update_app_setting(self, section, setting, value):
if section not in config.app:
raise AttributeError("The configuration section is not present in the spec file.")
if setting not in config.app[section]:
raise AttributeError("The setting you specified is not present in the config file.")
# check if certain settings have been changed so we'd restart the client.
# List of app settings that require a restart after being changed.
settings_needing_restart = ["use_proxy", "input_device", "output_device"]
if value != config.app[section][setting] and setting in settings_needing_restart:
self.needs_restart = True
config.app[section][setting] = value
def save_app_settings_file(self):
config.app.write()
if self.needs_restart:
self.send_message("restart_program")
def restart_application(self):