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"
25 #include "rbsettings.h"
27 InstallTalkWindow::InstallTalkWindow(QWidget
*parent
) : QDialog(parent
)
30 talkcreator
= new TalkFileCreator(this);
32 connect(ui
.buttonBrowse
, SIGNAL(clicked()), this, SLOT(browseFolder()));
33 connect(ui
.change
,SIGNAL(clicked()),this,SLOT(change()));
35 ui
.recursive
->setChecked(true);
36 ui
.OverwriteTalk
->setChecked(true);
37 ui
.StripExtensions
->setChecked(true);
42 void InstallTalkWindow::browseFolder()
44 BrowseDirtree
browser(this);
45 browser
.setFilter(QDir::AllDirs
| QDir::NoDotAndDotDot
| QDir::NoSymLinks
);
47 if(QFileInfo(ui
.lineTalkFolder
->text()).isDir())
49 browser
.setDir(ui
.lineTalkFolder
->text());
53 browser
.setDir("/media"); // FIXME: This looks Linux specific
55 if(browser
.exec() == QDialog::Accepted
)
57 qDebug() << browser
.getSelected();
58 setTalkFolder(browser
.getSelected());
62 void InstallTalkWindow::setTalkFolder(QString folder
)
64 ui
.lineTalkFolder
->setText(folder
);
67 void InstallTalkWindow::change()
69 Config
*cw
= new Config(this,4);
71 connect(cw
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
76 void InstallTalkWindow::accept()
78 logger
= new ProgressLoggerGui(this);
80 connect(logger
,SIGNAL(closed()),this,SLOT(close()));
84 QString folderToTalk
= ui
.lineTalkFolder
->text();
86 if(!QFileInfo(folderToTalk
).isDir())
88 logger
->addItem(tr("The Folder to Talk is wrong!"),LOGERROR
);
89 logger
->setFinished();
93 RbSettings::setValue(RbSettings::LastTalkedFolder
, folderToTalk
);
97 talkcreator
->setDir(QDir(folderToTalk
));
98 talkcreator
->setMountPoint(RbSettings::value(RbSettings::Mountpoint
).toString());
100 talkcreator
->setOverwriteTalk(ui
.OverwriteTalk
->isChecked());
101 talkcreator
->setRecursive(ui
.recursive
->isChecked());
102 talkcreator
->setStripExtensions(ui
.StripExtensions
->isChecked());
103 talkcreator
->setTalkFolders(ui
.talkFolders
->isChecked());
104 talkcreator
->setTalkFiles(ui
.talkFiles
->isChecked());
106 talkcreator
->createTalkFiles(logger
);
110 void InstallTalkWindow::updateSettings(void)
112 QString ttsName
= RbSettings::value(RbSettings::Tts
).toString();
113 TTSBase
* tts
= TTSBase::getTTS(this,ttsName
);
115 ui
.labelTtsProfile
->setText(tr("Selected TTS engine: <b>%1</b>")
116 .arg(TTSBase::getTTSName(ttsName
)));
118 ui
.labelTtsProfile
->setText(tr("Selected TTS engine: <b>%1</b>")
119 .arg("Invalid TTS configuration!"));
121 QString encoder
= RbSettings::value(RbSettings::CurEncoder
).toString();
122 EncBase
* enc
= EncBase::getEncoder(this,encoder
);
125 ui
.labelEncProfile
->setText(tr("Selected encoder: <b>%1</b>")
126 .arg(EncBase::getEncoderName(encoder
)));
128 ui
.labelEncProfile
->setText(tr("Selected encoder: <b>%1</b>")
129 .arg("Invalid encoder configuration!"));
132 ui
.labelEncProfile
->setText(tr("Selected encoder: <b>%1</b>")
133 .arg("Invalid encoder configuration!"));
135 setTalkFolder(RbSettings::value(RbSettings::LastTalkedFolder
).toString());
136 emit
settingsUpdated();