2007-08-05 16:17:35 +00:00
|
|
|
/***************************************************************************
|
|
|
|
* __________ __ ___.
|
|
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
|
|
* \/ \/ \/ \/ \/
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 by Dominik Riebeling
|
|
|
|
*
|
|
|
|
* All files in this archive are subject to the GNU General Public License.
|
|
|
|
* See the file COPYING in the source tree root for full license agreement.
|
|
|
|
*
|
|
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
|
|
* KIND, either express or implied.
|
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
2013-01-27 11:01:56 +00:00
|
|
|
#include <QMessageBox>
|
2007-08-05 16:17:35 +00:00
|
|
|
#include "installtalkwindow.h"
|
|
|
|
#include "ui_installtalkfrm.h"
|
|
|
|
|
2007-12-14 19:49:11 +00:00
|
|
|
#include "configure.h"
|
2009-05-09 16:59:14 +00:00
|
|
|
#include "rbsettings.h"
|
2010-01-24 21:12:11 +00:00
|
|
|
#include "systeminfo.h"
|
2013-11-03 10:08:18 +00:00
|
|
|
#include "Logger.h"
|
2007-08-07 17:49:35 +00:00
|
|
|
|
2007-08-05 16:17:35 +00:00
|
|
|
InstallTalkWindow::InstallTalkWindow(QWidget *parent) : QDialog(parent)
|
|
|
|
{
|
|
|
|
ui.setupUi(this);
|
|
|
|
talkcreator = new TalkFileCreator(this);
|
2007-09-15 22:57:07 +00:00
|
|
|
|
2007-12-14 19:49:11 +00:00
|
|
|
connect(ui.change,SIGNAL(clicked()),this,SLOT(change()));
|
2007-08-28 23:10:42 +00:00
|
|
|
|
2007-08-05 16:17:35 +00:00
|
|
|
ui.recursive->setChecked(true);
|
2009-10-13 20:51:20 +00:00
|
|
|
ui.GenerateOnlyNew->setChecked(true);
|
2007-08-05 16:17:35 +00:00
|
|
|
ui.StripExtensions->setChecked(true);
|
2012-01-06 19:19:32 +00:00
|
|
|
|
2012-06-13 21:04:27 +00:00
|
|
|
fsm = new QFileSystemModel(this);
|
|
|
|
QString mp = RbSettings::value(RbSettings::Mountpoint).toString();
|
|
|
|
fsm->setRootPath(mp);
|
|
|
|
ui.treeView->setModel(fsm);
|
|
|
|
ui.treeView->setSelectionMode(QAbstractItemView::ExtendedSelection);
|
|
|
|
ui.treeView->setRootIndex(fsm->index(mp));
|
|
|
|
fsm->setFilter(QDir::AllDirs | QDir::NoDotAndDotDot);
|
|
|
|
for(int i = 1; i < fsm->columnCount(); i++)
|
|
|
|
ui.treeView->setColumnHidden(i, true);
|
|
|
|
ui.treeView->setHeaderHidden(true);
|
2007-08-05 16:17:35 +00:00
|
|
|
|
2012-06-13 21:04:27 +00:00
|
|
|
updateSettings();
|
2007-08-05 16:17:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2012-06-14 20:36:54 +00:00
|
|
|
void InstallTalkWindow::saveSettings(void)
|
2007-12-14 19:49:11 +00:00
|
|
|
{
|
2012-06-14 20:51:32 +00:00
|
|
|
QString mp = RbSettings::value(RbSettings::Mountpoint).toString();
|
2012-06-13 21:04:27 +00:00
|
|
|
QModelIndexList si = ui.treeView->selectionModel()->selectedIndexes();
|
|
|
|
QStringList foldersToTalk;
|
|
|
|
for(int i = 0; i < si.size(); i++) {
|
|
|
|
if(si.at(i).column() == 0) {
|
2012-06-14 20:51:32 +00:00
|
|
|
QString current = fsm->filePath(si.at(i));
|
|
|
|
foldersToTalk.append(current.remove(QRegExp("^" + mp)));
|
2012-06-13 21:04:27 +00:00
|
|
|
}
|
|
|
|
}
|
2012-06-14 20:36:54 +00:00
|
|
|
RbSettings::setValue(RbSettings::TalkFolders, foldersToTalk);
|
|
|
|
|
|
|
|
RbSettings::setValue(RbSettings::TalkSkipExisting, ui.GenerateOnlyNew->isChecked());
|
|
|
|
RbSettings::setValue(RbSettings::TalkRecursive, ui.recursive->isChecked());
|
|
|
|
RbSettings::setValue(RbSettings::TalkStripExtensions, ui.StripExtensions->isChecked());
|
|
|
|
RbSettings::setValue(RbSettings::TalkProcessFolders, ui.talkFolders->isChecked());
|
|
|
|
RbSettings::setValue(RbSettings::TalkProcessFiles, ui.talkFiles->isChecked());
|
|
|
|
RbSettings::setValue(RbSettings::TalkIgnoreWildcards, ui.ignoreFiles->text());
|
|
|
|
RbSettings::setValue(RbSettings::TalkIgnoreFiles, ui.ignoreEnabled->isChecked());
|
|
|
|
|
|
|
|
RbSettings::sync();
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void InstallTalkWindow::change()
|
|
|
|
{
|
|
|
|
Config *cw = new Config(this, 4);
|
|
|
|
|
|
|
|
// make sure the current selected folder doesn't get lost on settings
|
|
|
|
// changes.
|
2008-03-14 18:27:39 +00:00
|
|
|
connect(cw, SIGNAL(settingsUpdated()), this, SLOT(updateSettings()));
|
2012-01-06 19:19:32 +00:00
|
|
|
|
2008-04-06 19:50:38 +00:00
|
|
|
cw->show();
|
2007-12-14 19:49:11 +00:00
|
|
|
}
|
2007-08-05 16:17:35 +00:00
|
|
|
|
|
|
|
void InstallTalkWindow::accept()
|
|
|
|
{
|
2012-10-06 09:30:26 +00:00
|
|
|
saveSettings();
|
|
|
|
QStringList foldersToTalk
|
|
|
|
= RbSettings::value(RbSettings::TalkFolders).toStringList();
|
|
|
|
if(foldersToTalk.size() == 0) {
|
|
|
|
QMessageBox::information(this, tr("Empty selection"),
|
|
|
|
tr("No files or folders selected. Please select files or "
|
|
|
|
"folders first."));
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2007-08-05 16:17:35 +00:00
|
|
|
logger = new ProgressLoggerGui(this);
|
2012-01-06 19:19:32 +00:00
|
|
|
|
2007-08-29 21:46:12 +00:00
|
|
|
connect(logger,SIGNAL(closed()),this,SLOT(close()));
|
2008-04-06 19:50:38 +00:00
|
|
|
logger->show();
|
2007-08-28 23:10:42 +00:00
|
|
|
|
2009-05-09 16:59:14 +00:00
|
|
|
talkcreator->setMountPoint(RbSettings::value(RbSettings::Mountpoint).toString());
|
2012-01-06 19:19:32 +00:00
|
|
|
|
2009-10-13 20:51:20 +00:00
|
|
|
talkcreator->setGenerateOnlyNew(ui.GenerateOnlyNew->isChecked());
|
2007-08-05 16:17:35 +00:00
|
|
|
talkcreator->setRecursive(ui.recursive->isChecked());
|
|
|
|
talkcreator->setStripExtensions(ui.StripExtensions->isChecked());
|
2007-10-12 15:52:04 +00:00
|
|
|
talkcreator->setTalkFolders(ui.talkFolders->isChecked());
|
|
|
|
talkcreator->setTalkFiles(ui.talkFiles->isChecked());
|
2009-08-23 18:57:50 +00:00
|
|
|
talkcreator->setIgnoreFiles(ui.ignoreFiles->text().split(",",QString::SkipEmptyParts));
|
2012-01-06 19:19:32 +00:00
|
|
|
|
2009-06-26 20:40:51 +00:00
|
|
|
connect(talkcreator, SIGNAL(done(bool)), logger, SLOT(setFinished()));
|
|
|
|
connect(talkcreator, SIGNAL(logItem(QString, int)), logger, SLOT(addItem(QString, int)));
|
|
|
|
connect(talkcreator, SIGNAL(logProgress(int, int)), logger, SLOT(setProgress(int, int)));
|
|
|
|
connect(logger,SIGNAL(aborted()),talkcreator,SLOT(abort()));
|
2012-01-06 19:19:32 +00:00
|
|
|
|
2012-06-13 21:04:27 +00:00
|
|
|
for(int i = 0; i < foldersToTalk.size(); i++) {
|
2013-11-03 10:08:18 +00:00
|
|
|
LOG_INFO() << "creating talk files for folder"
|
|
|
|
<< foldersToTalk.at(i);
|
2012-09-05 18:17:26 +00:00
|
|
|
talkcreator->setDir(foldersToTalk.at(i));
|
2012-06-13 21:04:27 +00:00
|
|
|
talkcreator->createTalkFiles();
|
|
|
|
}
|
2007-08-05 16:17:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2008-03-14 18:27:39 +00:00
|
|
|
void InstallTalkWindow::updateSettings(void)
|
2008-03-01 13:42:14 +00:00
|
|
|
{
|
2012-06-14 20:51:32 +00:00
|
|
|
QString mp = RbSettings::value(RbSettings::Mountpoint).toString();
|
2009-05-09 16:59:14 +00:00
|
|
|
QString ttsName = RbSettings::value(RbSettings::Tts).toString();
|
2009-04-29 21:27:01 +00:00
|
|
|
TTSBase* tts = TTSBase::getTTS(this,ttsName);
|
2012-10-06 10:42:20 +00:00
|
|
|
if(!tts)
|
|
|
|
{
|
|
|
|
QMessageBox::critical(this, tr("TTS error"),
|
|
|
|
tr("The selected TTS failed to initialize. You can't use this TTS."));
|
|
|
|
return;
|
|
|
|
}
|
2007-12-15 13:13:57 +00:00
|
|
|
if(tts->configOk())
|
2012-09-02 18:15:31 +00:00
|
|
|
ui.labelTtsProfile->setText(QString("<b>%1</b>")
|
2008-07-05 22:14:15 +00:00
|
|
|
.arg(TTSBase::getTTSName(ttsName)));
|
2007-12-15 13:13:57 +00:00
|
|
|
else
|
2012-09-02 18:15:31 +00:00
|
|
|
ui.labelTtsProfile->setText(QString("<b>%1</b>")
|
2008-07-05 22:14:15 +00:00
|
|
|
.arg("Invalid TTS configuration!"));
|
2012-01-06 19:19:32 +00:00
|
|
|
|
2012-06-14 20:36:54 +00:00
|
|
|
QStringList folders = RbSettings::value(RbSettings::TalkFolders).toStringList();
|
2012-06-13 21:04:27 +00:00
|
|
|
for(int i = 0; i < folders.size(); ++i) {
|
2012-06-14 20:51:32 +00:00
|
|
|
QModelIndex mi = fsm->index(mp + folders.at(i));
|
2012-06-13 21:04:27 +00:00
|
|
|
ui.treeView->selectionModel()->select(mi, QItemSelectionModel::Select);
|
|
|
|
// make sure all parent items are expanded.
|
|
|
|
while((mi = mi.parent()) != QModelIndex()) {
|
|
|
|
ui.treeView->setExpanded(mi, true);
|
|
|
|
}
|
|
|
|
}
|
2012-06-14 20:36:54 +00:00
|
|
|
ui.GenerateOnlyNew->setChecked(
|
|
|
|
RbSettings::value(RbSettings::TalkSkipExisting).toBool());
|
|
|
|
ui.recursive->setChecked(
|
|
|
|
RbSettings::value(RbSettings::TalkRecursive).toBool());
|
|
|
|
ui.StripExtensions->setChecked(
|
|
|
|
RbSettings::value(RbSettings::TalkStripExtensions).toBool());
|
|
|
|
ui.talkFolders->setChecked(
|
|
|
|
RbSettings::value(RbSettings::TalkProcessFolders).toBool());
|
|
|
|
ui.talkFiles->setChecked(
|
|
|
|
RbSettings::value(RbSettings::TalkProcessFiles).toBool());
|
|
|
|
ui.ignoreFiles->setText(
|
|
|
|
RbSettings::value(RbSettings::TalkIgnoreWildcards).toString());
|
|
|
|
ui.ignoreEnabled->setChecked(
|
|
|
|
RbSettings::value(RbSettings::TalkIgnoreFiles).toBool());
|
2012-06-13 21:04:27 +00:00
|
|
|
|
2008-03-14 18:27:39 +00:00
|
|
|
emit settingsUpdated();
|
2007-08-05 16:17:35 +00:00
|
|
|
}
|
2008-01-19 18:33:33 +00:00
|
|
|
|
2011-10-02 14:30:05 +00:00
|
|
|
|
|
|
|
void InstallTalkWindow::changeEvent(QEvent *e)
|
|
|
|
{
|
|
|
|
if(e->type() == QEvent::LanguageChange) {
|
|
|
|
ui.retranslateUi(this);
|
2011-10-04 18:30:27 +00:00
|
|
|
updateSettings();
|
2011-10-02 14:30:05 +00:00
|
|
|
} else {
|
|
|
|
QWidget::changeEvent(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|