Submit FS#9746 by Boris Gjenero. Set PP502x IDE pins low for iPod Video when IDE...
[kugel-rb.git] / rbutil / rbutilqt / installtalkwindow.cpp
blob405b3b05e07d68cf477ad8633b693e15535999ab
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
9 * Copyright (C) 2007 by Dominik Riebeling
10 * $Id$
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"
26 #include "systeminfo.h"
28 InstallTalkWindow::InstallTalkWindow(QWidget *parent) : QDialog(parent)
30 ui.setupUi(this);
31 talkcreator = new TalkFileCreator(this);
33 connect(ui.buttonBrowse, SIGNAL(clicked()), this, SLOT(browseFolder()));
34 connect(ui.change,SIGNAL(clicked()),this,SLOT(change()));
36 ui.recursive->setChecked(true);
37 ui.GenerateOnlyNew->setChecked(true);
38 ui.StripExtensions->setChecked(true);
40 updateSettings();
43 void InstallTalkWindow::browseFolder()
45 QString selected;
46 QString startfolder;
47 if(QFileInfo(ui.lineTalkFolder->text()).isDir())
49 startfolder = ui.lineTalkFolder->text();
51 else
53 startfolder = RbSettings::value(RbSettings::Mountpoint).toString();
55 selected = QFileDialog::getExistingDirectory(this,
56 tr("Select folder to create talk files"), startfolder);
57 if(!selected.isEmpty())
59 ui.lineTalkFolder->setText(selected);
64 void InstallTalkWindow::change()
66 Config *cw = new Config(this,4);
68 // make sure the current selected folder doesn't get lost on settings
69 // changes. If the current selection is invalid don't accept it so
70 // it gets reset to the old value after closing the settings dialog.
71 QString folderToTalk = ui.lineTalkFolder->text();
72 if(QFileInfo(folderToTalk).isDir())
73 RbSettings::setValue(RbSettings::LastTalkedFolder, folderToTalk);
74 connect(cw, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
76 cw->show();
79 void InstallTalkWindow::accept()
81 logger = new ProgressLoggerGui(this);
83 connect(logger,SIGNAL(closed()),this,SLOT(close()));
84 logger->show();
87 QString folderToTalk = ui.lineTalkFolder->text();
89 if(!QFileInfo(folderToTalk).isDir())
91 logger->addItem(tr("The Folder to Talk is wrong!"),LOGERROR);
92 logger->setFinished();
93 return;
96 RbSettings::setValue(RbSettings::LastTalkedFolder, folderToTalk);
98 RbSettings::sync();
100 talkcreator->setDir(QDir(folderToTalk));
101 talkcreator->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
103 talkcreator->setGenerateOnlyNew(ui.GenerateOnlyNew->isChecked());
104 talkcreator->setRecursive(ui.recursive->isChecked());
105 talkcreator->setStripExtensions(ui.StripExtensions->isChecked());
106 talkcreator->setTalkFolders(ui.talkFolders->isChecked());
107 talkcreator->setTalkFiles(ui.talkFiles->isChecked());
108 talkcreator->setIgnoreFiles(ui.ignoreFiles->text().split(",",QString::SkipEmptyParts));
110 connect(talkcreator, SIGNAL(done(bool)), logger, SLOT(setFinished()));
111 connect(talkcreator, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
112 connect(talkcreator, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
113 connect(logger,SIGNAL(aborted()),talkcreator,SLOT(abort()));
115 talkcreator->createTalkFiles();
119 void InstallTalkWindow::updateSettings(void)
121 QString ttsName = RbSettings::value(RbSettings::Tts).toString();
122 TTSBase* tts = TTSBase::getTTS(this,ttsName);
123 if(tts->configOk())
124 ui.labelTtsProfile->setText(tr("Selected TTS engine: <b>%1</b>")
125 .arg(TTSBase::getTTSName(ttsName)));
126 else
127 ui.labelTtsProfile->setText(tr("Selected TTS engine: <b>%1</b>")
128 .arg("Invalid TTS configuration!"));
130 QString encoder = SystemInfo::value(SystemInfo::CurEncoder).toString();
131 EncBase* enc = EncBase::getEncoder(this,encoder);
132 if(enc != NULL) {
133 if(enc->configOk())
134 ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>")
135 .arg(EncBase::getEncoderName(encoder)));
136 else
137 ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>")
138 .arg("Invalid encoder configuration!"));
140 else
141 ui.labelEncProfile->setText(tr("Selected encoder: <b>%1</b>")
142 .arg("Invalid encoder configuration!"));
144 ui.lineTalkFolder->setText(
145 RbSettings::value(RbSettings::LastTalkedFolder).toString());
146 emit settingsUpdated();