# Path: dobby/config.py
# def is_option_list(value, *args):
# def initConfig(path='config.ini'):


from ..ui.config_ui import Ui_ConfigDialog
from PySide.QtCore import *
from PySide.QtGui import *
from dobby.config import validator
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Dobby.  If not, see <http://www.gnu.org/licenses/>.


class ConfigForm(QDialog, Ui_ConfigDialog):
    def __init__(self, config, parent=None):
        super(ConfigForm, self).__init__(parent)
        self.setModal(True)
        self.setupUi(self)
        self.config = config
        self.load()

    def load(self):
        # General
        self.qleGeneralWelcomeMessage.setText(self.config['General']['welcome_message'])
        self.qleGeneralByeMessage.setText(self.config['General']['bye_message'])
        self.qleGeneralFailedMessage.setText(self.config['General']['failed_message'])
        self.qleGeneralConfirmationMessage.setText(self.config['General']['confirmation_message'])
        self.qsbGeneralRecognitionTimeout.setValue(self.config['General']['recognition_timeout'])
        
        # Speakers
        speakers = ['speechdispatcher']
        self.qcbSpeaker.setCurrentIndex(speakers.index(self.config['Speaker']['speaker']))
        self.qleSpeakerSpeechDispatcherEngine.setText(self.config['Speaker']['SpeechDispatcher']['engine'])
        self.qleSpeakerSpeechDispatcherVoice.setText(self.config['Speaker']['SpeechDispatcher']['voice'])
        self.qleSpeakerSpeechDispatcherLanguage.setText(self.config['Speaker']['SpeechDispatcher']['language'])
        self.qsbSpeakerSpeechDispatcherVolume.setValue(self.config['Speaker']['SpeechDispatcher']['volume'])

# Path: dobby/config.py
# def is_option_list(value, *args):
# def initConfig(path='config.ini'):


# Path: dobby/qt/dialogs/configure.py
from ..ui.config_ui import Ui_ConfigDialog
from PySide.QtCore import *
from PySide.QtGui import *
from dobby.config import validator

# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Dobby.  If not, see <http://www.gnu.org/licenses/>.


class ConfigForm(QDialog, Ui_ConfigDialog):
    def __init__(self, config, parent=None):
        super(ConfigForm, self).__init__(parent)
        self.setModal(True)
        self.setupUi(self)
        self.config = config
        self.load()

    def load(self):
        # General
        self.qleGeneralWelcomeMessage.setText(self.config['General']['welcome_message'])
        self.qleGeneralByeMessage.setText(self.config['General']['bye_message'])
        self.qleGeneralFailedMessage.setText(self.config['General']['failed_message'])
        self.qleGeneralConfirmationMessage.setText(self.config['General']['confirmation_message'])
        self.qsbGeneralRecognitionTimeout.setValue(self.config['General']['recognition_timeout'])
        
        # Speakers
        speakers = ['speechdispatcher']
        self.qcbSpeaker.setCurrentIndex(speakers.index(self.config['Speaker']['speaker']))
        self.qleSpeakerSpeechDispatcherEngine.setText(self.config['Speaker']['SpeechDispatcher']['engine'])
        self.qleSpeakerSpeechDispatcherVoice.setText(self.config['Speaker']['SpeechDispatcher']['voice'])
        self.qleSpeakerSpeechDispatcherLanguage.setText(self.config['Speaker']['SpeechDispatcher']['language'])
        self.qsbSpeakerSpeechDispatcherVolume.setValue(self.config['Speaker']['SpeechDispatcher']['volume'])

        self.qsbSpeakerSpeechDispatcherRate.setValue(self.config['Speaker']['SpeechDispatcher']['rate'])