Update to autoset and use Rhubarb Path Preference setting
This commit is contained in:
parent
693f4f8ba9
commit
2d8998c1e6
4 changed files with 62 additions and 38 deletions
|
@ -1044,6 +1044,18 @@ bool TSystem::showDocument(const TFilePath &path) {
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString TSystem::findFileLocation(QStringList folderList, QString fileName) {
|
||||||
|
if (folderList.isEmpty()) return "";
|
||||||
|
|
||||||
|
QStringList::iterator it;
|
||||||
|
for (it = folderList.begin(); it != folderList.end(); it++) {
|
||||||
|
QString path = *it + "/" + fileName;
|
||||||
|
if (TSystem::doesExistFileOrLevel(TFilePath(path))) return *it;
|
||||||
|
}
|
||||||
|
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
|
|
|
@ -263,6 +263,8 @@ DVAPI TFilePath toLocalPath(const TFilePath &fp);
|
||||||
|
|
||||||
DVAPI bool showDocument(const TFilePath &fp);
|
DVAPI bool showDocument(const TFilePath &fp);
|
||||||
|
|
||||||
|
DVAPI QString findFileLocation(QStringList folderList, QString fileName);
|
||||||
|
|
||||||
#ifndef TNZCORE_LIGHT
|
#ifndef TNZCORE_LIGHT
|
||||||
DVAPI QDateTime getFileTime(const TFilePath &path);
|
DVAPI QDateTime getFileTime(const TFilePath &path);
|
||||||
DVAPI QString getHostName();
|
DVAPI QString getHostName();
|
||||||
|
|
|
@ -477,6 +477,8 @@ LipSyncPopup::LipSyncPopup()
|
||||||
SLOT(setPage(int)));
|
SLOT(setPage(int)));
|
||||||
|
|
||||||
assert(ret);
|
assert(ret);
|
||||||
|
|
||||||
|
m_rhubarbPath = "";
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -515,6 +517,9 @@ void LipSyncPopup::showEvent(QShowEvent *) {
|
||||||
m_isEditingLevel = app->getCurrentFrame()->isEditingLevel();
|
m_isEditingLevel = app->getCurrentFrame()->isEditingLevel();
|
||||||
m_startAt->setValue(row + 1);
|
m_startAt->setValue(row + 1);
|
||||||
m_startAt->clearFocus();
|
m_startAt->clearFocus();
|
||||||
|
|
||||||
|
if (checkRhubarb()) m_rhubarbPath = Preferences::instance()->getRhubarbPath();
|
||||||
|
|
||||||
TXshLevelHandle *level = app->getCurrentLevel();
|
TXshLevelHandle *level = app->getCurrentLevel();
|
||||||
m_sl = level->getSimpleLevel();
|
m_sl = level->getSimpleLevel();
|
||||||
if (!m_sl) {
|
if (!m_sl) {
|
||||||
|
@ -548,7 +553,6 @@ void LipSyncPopup::showEvent(QShowEvent *) {
|
||||||
}
|
}
|
||||||
refreshSoundLevels();
|
refreshSoundLevels();
|
||||||
onLevelChanged(-1);
|
onLevelChanged(-1);
|
||||||
findRhubarb();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -686,53 +690,47 @@ void LipSyncPopup::saveAudio() {
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
QString LipSyncPopup::findRhubarb() {
|
bool LipSyncPopup::checkRhubarb() {
|
||||||
QString path = QDir::currentPath() + "/rhubarb/rhubarb";
|
QString exe = "rhubarb";
|
||||||
bool found = false;
|
|
||||||
#if defined(_WIN32)
|
#if defined(_WIN32)
|
||||||
path = path + ".exe";
|
exe = exe + ".exe";
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// check the user defined path in preferences first
|
||||||
|
QString path = Preferences::instance()->getRhubarbPath() + "/" + exe;
|
||||||
|
if (TSystem::doesExistFileOrLevel(TFilePath(path))) return true;
|
||||||
|
|
||||||
|
// Let's try and autodetect the exe included with release
|
||||||
|
QStringList folderList;
|
||||||
|
|
||||||
|
folderList.append(".");
|
||||||
|
folderList.append("./rhubarb"); // rhubarb folder
|
||||||
|
|
||||||
#ifdef MACOSX
|
#ifdef MACOSX
|
||||||
path = QDir::currentPath() + "/" +
|
// Look inside app
|
||||||
|
folderList.append("./" +
|
||||||
QString::fromStdString(TEnv::getApplicationFileName()) +
|
QString::fromStdString(TEnv::getApplicationFileName()) +
|
||||||
".app/rhubarb/rhubarb";
|
".app/rhubarb"); // rhubarb folder
|
||||||
if (TSystem::doesExistFileOrLevel(TFilePath(path))) {
|
#elif defined LINUX
|
||||||
found = true;
|
// Need to account for symbolic links
|
||||||
}
|
folderList.append(TEnv::getWorkingDirectory().getQString() +
|
||||||
|
"/rhubarb"); // rhubarb folder
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
std::string sPath = path.toStdString();
|
QString exePath = TSystem::findFileLocation(folderList, exe);
|
||||||
if (!found && TSystem::doesExistFileOrLevel(TFilePath(path))) {
|
|
||||||
found = true;
|
if (!exePath.isEmpty()) {
|
||||||
|
Preferences::instance()->setValue(rhubarbPath, exePath);
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (found) {
|
// give up
|
||||||
m_tabBarContainer->show();
|
return false;
|
||||||
if (m_tabBar->currentIndex() != m_stackedChooser->currentIndex())
|
|
||||||
m_tabBar->setCurrentIndex(m_stackedChooser->currentIndex());
|
|
||||||
int index = m_soundLevels->currentIndex();
|
|
||||||
int count = m_soundLevels->count();
|
|
||||||
if (index == count - 1) {
|
|
||||||
m_audioFile->show();
|
|
||||||
} else {
|
|
||||||
m_audioFile->hide();
|
|
||||||
}
|
|
||||||
setPage(m_stackedChooser->currentIndex());
|
|
||||||
return path;
|
|
||||||
} else {
|
|
||||||
m_tabBarContainer->hide();
|
|
||||||
setPage(1);
|
|
||||||
return QString("");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
void LipSyncPopup::runRhubarb() {
|
void LipSyncPopup::runRhubarb() {
|
||||||
QString path = findRhubarb();
|
|
||||||
|
|
||||||
QString cacheRoot = ToonzFolder::getCacheRootFolder().getQString();
|
QString cacheRoot = ToonzFolder::getCacheRootFolder().getQString();
|
||||||
if (!TSystem::doesExistFileOrLevel(TFilePath(cacheRoot + "/rhubarb"))) {
|
if (!TSystem::doesExistFileOrLevel(TFilePath(cacheRoot + "/rhubarb"))) {
|
||||||
TSystem::mkDir(TFilePath(cacheRoot + "/rhubarb"));
|
TSystem::mkDir(TFilePath(cacheRoot + "/rhubarb"));
|
||||||
|
@ -772,7 +770,12 @@ void LipSyncPopup::runRhubarb() {
|
||||||
m_progressDialog->show();
|
m_progressDialog->show();
|
||||||
connect(m_rhubarb, &QProcess::readyReadStandardError, this,
|
connect(m_rhubarb, &QProcess::readyReadStandardError, this,
|
||||||
&LipSyncPopup::onOutputReady);
|
&LipSyncPopup::onOutputReady);
|
||||||
m_rhubarb->start(path, args);
|
|
||||||
|
QString rhubarbExe = m_rhubarbPath + "/rhubarb";
|
||||||
|
#ifdef _WIN32
|
||||||
|
rhubarbExe = rhubarbExe + ".exe";
|
||||||
|
#endif
|
||||||
|
m_rhubarb->start(rhubarbExe, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
|
@ -811,6 +814,12 @@ void LipSyncPopup::onApplyButton() {
|
||||||
if (m_stackedChooser->currentIndex() == 0) {
|
if (m_stackedChooser->currentIndex() == 0) {
|
||||||
bool hasAudio = setAudioFile();
|
bool hasAudio = setAudioFile();
|
||||||
if (!hasAudio) return;
|
if (!hasAudio) return;
|
||||||
|
if (m_rhubarbPath.isEmpty() || m_rhubarbPath.isNull()) {
|
||||||
|
DVGui::warning(
|
||||||
|
tr("Rhubarb not found, please set the location in Preferences and "
|
||||||
|
"restart."));
|
||||||
|
return;
|
||||||
|
}
|
||||||
runRhubarb();
|
runRhubarb();
|
||||||
m_rhubarb->waitForFinished();
|
m_rhubarb->waitForFinished();
|
||||||
m_progressDialog->hide();
|
m_progressDialog->hide();
|
||||||
|
|
|
@ -78,6 +78,7 @@ class LipSyncPopup final : public DVGui::Dialog {
|
||||||
bool m_deleteFile = false;
|
bool m_deleteFile = false;
|
||||||
DVGui::ProgressDialog *m_progressDialog;
|
DVGui::ProgressDialog *m_progressDialog;
|
||||||
QProcess *m_rhubarb;
|
QProcess *m_rhubarb;
|
||||||
|
QString m_rhubarbPath;
|
||||||
QFrame *m_audioFrame;
|
QFrame *m_audioFrame;
|
||||||
QFrame *m_dataFrame;
|
QFrame *m_dataFrame;
|
||||||
QStackedWidget *m_stackedChooser;
|
QStackedWidget *m_stackedChooser;
|
||||||
|
@ -93,7 +94,7 @@ protected:
|
||||||
void refreshSoundLevels();
|
void refreshSoundLevels();
|
||||||
void saveAudio();
|
void saveAudio();
|
||||||
void runRhubarb();
|
void runRhubarb();
|
||||||
QString findRhubarb();
|
bool checkRhubarb();
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void onApplyButton();
|
void onApplyButton();
|
||||||
|
|
Loading…
Reference in a new issue