1/***************************************************************************
2 texttospeechconfigurationdialog.cpp - description
3 -------------------
4 begin : Son Sep 8 2002
5 copyright : (C) 2002 by Gunnar Schmi Dt
6 email : kmouth@schmi-dt.de
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#include "texttospeechconfigurationwidget.h"
19#include <kconfig.h>
20
21#include <QtCore/QTextCodec>
22#include <QtGui/QLayout>
23#include <QtGui/QLabel>
24#include <QtGui/QLineEdit>
25#include <QtGui/QPushButton>
26#include <QtGui/QCheckBox>
27
28#include <kcombobox.h>
29#include <klocale.h>
30#include "speech.h"
31#include <kurlrequester.h>
32
33TextToSpeechConfigurationWidget::TextToSpeechConfigurationWidget (QWidget *parent, const char *name)
34 : QWidget (parent)
35{
36 setObjectName( QLatin1String( name ) );
37 setupUi(this);
38 ttsSystem = new TextToSpeechSystem();
39
40 buildCodecList();
41}
42
43TextToSpeechConfigurationWidget::~TextToSpeechConfigurationWidget() {
44}
45
46void TextToSpeechConfigurationWidget::buildCodecList () {
47 QString local = i18nc("Local characterset", "Local")+QLatin1String( " (" );
48 local += QLatin1String( QTextCodec::codecForLocale()->name() ) + QLatin1Char( ')' );
49 characterCodingBox->addItem (local, Speech::Local);
50 characterCodingBox->addItem (i18nc("Latin1 characterset", "Latin1"), Speech::Latin1);
51 characterCodingBox->addItem (i18n("Unicode"), Speech::Unicode);
52 for (int i = 0; i < ttsSystem->codecList->count(); i++ )
53 characterCodingBox->addItem (QLatin1String( ttsSystem->codecList->at(i)->name() ), Speech::UseCodec + i);
54}
55
56void TextToSpeechConfigurationWidget::cancel() {
57 urlReq->setUrl (ttsSystem->ttsCommand);
58 stdInButton->setChecked (ttsSystem->stdIn);
59 characterCodingBox->setCurrentIndex(ttsSystem->codec);
60 useKttsd->setChecked (ttsSystem->useKttsd);
61}
62
63void TextToSpeechConfigurationWidget::ok() {
64 ttsSystem->ttsCommand = urlReq->url().path();
65 ttsSystem->stdIn = stdInButton->isChecked();
66 ttsSystem->codec = characterCodingBox->currentIndex();
67 ttsSystem->useKttsd = useKttsd->isChecked();
68}
69
70TextToSpeechSystem *TextToSpeechConfigurationWidget::getTTSSystem() const {
71 return ttsSystem;
72}
73
74void TextToSpeechConfigurationWidget::readOptions (KConfig *config, const QString &langGroup) {
75 ttsSystem->readOptions (config, langGroup);
76 urlReq->setUrl (ttsSystem->ttsCommand);
77 stdInButton->setChecked (ttsSystem->stdIn);
78 characterCodingBox->setCurrentIndex(ttsSystem->codec);
79 useKttsd->setChecked (ttsSystem->useKttsd);
80}
81
82void TextToSpeechConfigurationWidget::saveOptions (KConfig *config, const QString &langGroup) {
83 ttsSystem->saveOptions (config, langGroup);
84}
85
86