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
.GenerateOnlyNew
->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 // make sure the current selected folder doesn't get lost on settings
72 // changes. If the current selection is invalid don't accept it so
73 // it gets reset to the old value after closing the settings dialog.
74 QString folderToTalk
= ui
.lineTalkFolder
->text();
75 if(QFileInfo(folderToTalk
).isDir())
76 RbSettings::setValue(RbSettings::LastTalkedFolder
, folderToTalk
);
77 connect(cw
, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
82 void InstallTalkWindow::accept()
84 logger
= new ProgressLoggerGui(this);
86 connect(logger
,SIGNAL(closed()),this,SLOT(close()));
90 QString folderToTalk
= ui
.lineTalkFolder
->text();
92 if(!QFileInfo(folderToTalk
).isDir())
94 logger
->addItem(tr("The Folder to Talk is wrong!"),LOGERROR
);
95 logger
->setFinished();
99 RbSettings::setValue(RbSettings::LastTalkedFolder
, folderToTalk
);
103 talkcreator
->setDir(QDir(folderToTalk
));
104 talkcreator
->setMountPoint(RbSettings::value(RbSettings::Mountpoint
).toString());
106 talkcreator
->setGenerateOnlyNew(ui
.GenerateOnlyNew
->isChecked());
107 talkcreator
->setRecursive(ui
.recursive
->isChecked());
108 talkcreator
->setStripExtensions(ui
.StripExtensions
->isChecked());
109 talkcreator
->setTalkFolders(ui
.talkFolders
->isChecked());
110 talkcreator
->setTalkFiles(ui
.talkFiles
->isChecked());
111 talkcreator
->setIgnoreFiles(ui
.ignoreFiles
->text().split(",",QString::SkipEmptyParts
));
113 connect(talkcreator
, SIGNAL(done(bool)), logger
, SLOT(setFinished()));
114 connect(talkcreator
, SIGNAL(logItem(QString
, int)), logger
, SLOT(addItem(QString
, int)));
115 connect(talkcreator
, SIGNAL(logProgress(int, int)), logger
, SLOT(setProgress(int, int)));
116 connect(logger
,SIGNAL(aborted()),talkcreator
,SLOT(abort()));
118 talkcreator
->createTalkFiles();
122 void InstallTalkWindow::updateSettings(void)
124 QString ttsName
= RbSettings::value(RbSettings::Tts
).toString();
125 TTSBase
* tts
= TTSBase::getTTS(this,ttsName
);
127 ui
.labelTtsProfile
->setText(tr("Selected TTS engine: <b>%1</b>")
128 .arg(TTSBase::getTTSName(ttsName
)));
130 ui
.labelTtsProfile
->setText(tr("Selected TTS engine: <b>%1</b>")
131 .arg("Invalid TTS configuration!"));
133 QString encoder
= RbSettings::value(RbSettings::CurEncoder
).toString();
134 EncBase
* enc
= EncBase::getEncoder(this,encoder
);
137 ui
.labelEncProfile
->setText(tr("Selected encoder: <b>%1</b>")
138 .arg(EncBase::getEncoderName(encoder
)));
140 ui
.labelEncProfile
->setText(tr("Selected encoder: <b>%1</b>")
141 .arg("Invalid encoder configuration!"));
144 ui
.labelEncProfile
->setText(tr("Selected encoder: <b>%1</b>")
145 .arg("Invalid encoder configuration!"));
147 setTalkFolder(RbSettings::value(RbSettings::LastTalkedFolder
).toString());
148 emit
settingsUpdated();