1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
9 * Copyright (C) 2007 by Dominik Riebeling
12 * All files in this archive are subject to the GNU General Public License.
13 * See the file COPYING in the source tree root for full license agreement.
15 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
16 * KIND, either express or implied.
18 ****************************************************************************/
20 #include "installtalkwindow.h"
21 #include "ui_installtalkfrm.h"
23 #include "browsedirtree.h"
24 #include "configure.h"
26 InstallTalkWindow::InstallTalkWindow(QWidget
*parent
) : QDialog(parent
)
29 talkcreator
= new TalkFileCreator(this);
31 connect(ui
.buttonBrowse
, SIGNAL(clicked()), this, SLOT(browseFolder()));
32 connect(ui
.change
,SIGNAL(clicked()),this,SLOT(change()));
34 ui
.OverwriteWav
->setChecked(true);
35 ui
.RemoveWav
->setChecked(true);
36 ui
.recursive
->setChecked(true);
37 ui
.OverwriteTalk
->setChecked(true);
38 ui
.StripExtensions
->setChecked(true);
41 void InstallTalkWindow::browseFolder()
43 BrowseDirtree
browser(this);
44 browser
.setFilter(QDir::AllDirs
| QDir::NoDotAndDotDot
| QDir::NoSymLinks
);
46 if(QFileInfo(ui
.lineTalkFolder
->text()).isDir())
48 browser
.setDir(ui
.lineTalkFolder
->text());
52 browser
.setDir("/media"); // FIXME: This looks Linux specific
54 if(browser
.exec() == QDialog::Accepted
)
56 qDebug() << browser
.getSelected();
57 setTalkFolder(browser
.getSelected());
61 void InstallTalkWindow::setTalkFolder(QString folder
)
63 ui
.lineTalkFolder
->setText(folder
);
66 void InstallTalkWindow::change()
68 Config
*cw
= new Config(this,4);
69 cw
->setSettings(settings
);
71 connect(cw
, SIGNAL(settingsUpdated()), this, SIGNAL(settingsUpdated()));
74 void InstallTalkWindow::accept()
76 logger
= new ProgressLoggerGui(this);
78 connect(logger
,SIGNAL(closed()),this,SLOT(close()));
80 QString folderToTalk
= ui
.lineTalkFolder
->text();
82 if(!QFileInfo(folderToTalk
).isDir())
84 logger
->addItem(tr("The Folder to Talk is wrong!"),LOGERROR
);
89 settings
->setLastTalkedDir(folderToTalk
);
93 talkcreator
->setSettings(settings
);
94 talkcreator
->setDir(QDir(folderToTalk
));
95 talkcreator
->setMountPoint(settings
->mountpoint());
97 talkcreator
->setOverwriteTalk(ui
.OverwriteTalk
->isChecked());
98 talkcreator
->setOverwriteWav(ui
.OverwriteWav
->isChecked());
99 talkcreator
->setRemoveWav(ui
.RemoveWav
->isChecked());
100 talkcreator
->setRecursive(ui
.recursive
->isChecked());
101 talkcreator
->setStripExtensions(ui
.StripExtensions
->isChecked());
102 talkcreator
->setTalkFolders(ui
.talkFolders
->isChecked());
103 talkcreator
->setTalkFiles(ui
.talkFiles
->isChecked());
105 talkcreator
->createTalkFiles(logger
);
109 void InstallTalkWindow::setSettings(RbSettings
* sett
)
113 QString ttsName
= settings
->curTTS();
114 TTSBase
* tts
= getTTS(ttsName
);
115 tts
->setCfg(settings
);
117 ui
.labelTtsProfile
->setText(tr("Selected TTS engine : <b>%1</b>").arg(ttsName
));
119 ui
.labelTtsProfile
->setText(tr("Selected TTS Engine: <b>%1</b>").arg("Invalid TTS configuration!"));
121 QString encoder
= settings
->curEncoder();
122 // only proceed if encoder setting is set
123 if(!encoder
.isEmpty()) {
124 // FIXME: getEncoder CAN return a NULL pointer. Additional error
125 // checking is required or getEncoder should use the default engine
126 EncBase
* enc
= getEncoder(encoder
);
127 enc
->setCfg(settings
);
129 ui
.labelEncProfile
->setText(tr("Selected Encoder: <b>%1</b>").arg(encoder
));
131 ui
.labelEncProfile
->setText(tr("Selected Encoder: <b>%1</b>").arg("Invalid encoder configuration!"));
134 ui
.labelEncProfile
->setText(tr("Selected Encoder: <b>%1</b>").arg("Invalid encoder configuration!"));
136 setTalkFolder(settings
->lastTalkedFolder());