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 "configure.h"
24 #include "rbsettings.h"
25 #include "systeminfo.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
.GenerateOnlyNew
->setChecked(true);
37 ui
.StripExtensions
->setChecked(true);
42 void InstallTalkWindow::browseFolder()
46 if(QFileInfo(ui
.lineTalkFolder
->text()).isDir())
48 startfolder
= ui
.lineTalkFolder
->text();
52 startfolder
= RbSettings::value(RbSettings::Mountpoint
).toString();
54 selected
= QFileDialog::getExistingDirectory(this,
55 tr("Select folder to create talk files"), startfolder
);
56 if(!selected
.isEmpty())
58 ui
.lineTalkFolder
->setText(selected
);
63 void InstallTalkWindow::change()
65 Config
*cw
= new Config(this,4);
67 // make sure the current selected folder doesn't get lost on settings
68 // changes. If the current selection is invalid don't accept it so
69 // it gets reset to the old value after closing the settings dialog.
70 QString folderToTalk
= ui
.lineTalkFolder
->text();
71 if(QFileInfo(folderToTalk
).isDir())
72 RbSettings::setValue(RbSettings::LastTalkedFolder
, folderToTalk
);
73 connect(cw
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
78 void InstallTalkWindow::accept()
80 logger
= new ProgressLoggerGui(this);
82 connect(logger
,SIGNAL(closed()),this,SLOT(close()));
86 QString folderToTalk
= ui
.lineTalkFolder
->text();
88 if(!QFileInfo(folderToTalk
).isDir())
90 logger
->addItem(tr("The Folder to Talk is wrong!"),LOGERROR
);
91 logger
->setFinished();
95 RbSettings::setValue(RbSettings::LastTalkedFolder
, folderToTalk
);
99 talkcreator
->setDir(QDir(folderToTalk
));
100 talkcreator
->setMountPoint(RbSettings::value(RbSettings::Mountpoint
).toString());
102 talkcreator
->setGenerateOnlyNew(ui
.GenerateOnlyNew
->isChecked());
103 talkcreator
->setRecursive(ui
.recursive
->isChecked());
104 talkcreator
->setStripExtensions(ui
.StripExtensions
->isChecked());
105 talkcreator
->setTalkFolders(ui
.talkFolders
->isChecked());
106 talkcreator
->setTalkFiles(ui
.talkFiles
->isChecked());
107 talkcreator
->setIgnoreFiles(ui
.ignoreFiles
->text().split(",",QString::SkipEmptyParts
));
109 connect(talkcreator
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
110 connect(talkcreator
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
111 connect(talkcreator
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
112 connect(logger
,SIGNAL(aborted()),talkcreator
,SLOT(abort()));
114 talkcreator
->createTalkFiles();
118 void InstallTalkWindow::updateSettings(void)
120 QString ttsName
= RbSettings::value(RbSettings::Tts
).toString();
121 TTSBase
* tts
= TTSBase::getTTS(this,ttsName
);
123 ui
.labelTtsProfile
->setText(tr("Selected TTS engine: <b>%1</b>")
124 .arg(TTSBase::getTTSName(ttsName
)));
126 ui
.labelTtsProfile
->setText(tr("Selected TTS engine: <b>%1</b>")
127 .arg("Invalid TTS configuration!"));
129 QString encoder
= SystemInfo::value(SystemInfo::CurEncoder
).toString();
130 EncBase
* enc
= EncBase::getEncoder(this,encoder
);
133 ui
.labelEncProfile
->setText(tr("Selected encoder: <b>%1</b>")
134 .arg(EncBase::getEncoderName(encoder
)));
136 ui
.labelEncProfile
->setText(tr("Selected encoder: <b>%1</b>")
137 .arg("Invalid encoder configuration!"));
140 ui
.labelEncProfile
->setText(tr("Selected encoder: <b>%1</b>")
141 .arg("Invalid encoder configuration!"));
143 ui
.lineTalkFolder
->setText(
144 RbSettings::value(RbSettings::LastTalkedFolder
).toString());
145 emit
settingsUpdated();
149 void InstallTalkWindow::changeEvent(QEvent
*e
)
151 if(e
->type() == QEvent::LanguageChange
) {
152 ui
.retranslateUi(this);
154 QWidget::changeEvent(e
);