forked from len0rd/rockbox
rbutil: Fix TTS "waiting for engine" appearing randomly.
QProgressDialog shows / hides itself automatically based on the progress value set, so calling hide() directly doesn't prevent the dialog from showing itself. Change the logic to set a value instead. Fixes the progress dialog sometimes appearing in situations where it wasn't used at all. Change-Id: Ifef063f31b7f888bb74f180dea0679e81cc5c8fe
This commit is contained in:
parent
c21d10cb33
commit
ccdd9e6784
4 changed files with 24 additions and 24 deletions
|
@ -108,8 +108,7 @@ public:
|
||||||
virtual void saveSettings() = 0;
|
virtual void saveSettings() = 0;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void busy(); // emit this if a operation takes time
|
void busy(bool show); // emit this if a operation takes time
|
||||||
void busyEnd(); // emit this at the end of a busy section
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
//! Child class should fill in the setttingsList
|
//! Child class should fill in the setttingsList
|
||||||
|
|
|
@ -336,14 +336,14 @@ QString TTSFestival::queryServer(QString query, int timeout)
|
||||||
return "";
|
return "";
|
||||||
|
|
||||||
// this operation could take some time
|
// this operation could take some time
|
||||||
emit busy();
|
emit busy(true);
|
||||||
|
|
||||||
LOG_INFO() << "queryServer with" << query;
|
LOG_INFO() << "queryServer with" << query;
|
||||||
|
|
||||||
if (!ensureServerRunning())
|
if (!ensureServerRunning())
|
||||||
{
|
{
|
||||||
LOG_ERROR() << "queryServer: ensureServerRunning failed";
|
LOG_ERROR() << "queryServer: ensureServerRunning failed";
|
||||||
emit busyEnd();
|
emit busy(false);
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -391,7 +391,7 @@ QString TTSFestival::queryServer(QString query, int timeout)
|
||||||
while(QDateTime::currentDateTime() < tmpEndTime)
|
while(QDateTime::currentDateTime() < tmpEndTime)
|
||||||
QCoreApplication::processEvents(QEventLoop::AllEvents);
|
QCoreApplication::processEvents(QEventLoop::AllEvents);
|
||||||
}
|
}
|
||||||
emit busyEnd();
|
emit busy(false);
|
||||||
socket.disconnectFromHost();
|
socket.disconnectFromHost();
|
||||||
|
|
||||||
if(response == "nil")
|
if(response == "nil")
|
||||||
|
|
|
@ -40,14 +40,14 @@ EncTtsCfgGui::EncTtsCfgGui(QDialog* parent, EncTtsSettingInterface* iface, QStri
|
||||||
m_busyCnt(0)
|
m_busyCnt(0)
|
||||||
{
|
{
|
||||||
// create a busy Dialog
|
// create a busy Dialog
|
||||||
m_busyDlg= new QProgressDialog("", "", 0, 0,this);
|
m_busyDlg= new QProgressDialog("", "", 0, 1, this);
|
||||||
m_busyDlg->setWindowTitle(tr("Waiting for engine..."));
|
m_busyDlg->setWindowTitle(tr("Waiting for engine..."));
|
||||||
m_busyDlg->setModal(true);
|
m_busyDlg->setModal(true);
|
||||||
m_busyDlg->setLabel(nullptr);
|
m_busyDlg->setLabel(nullptr);
|
||||||
m_busyDlg->setCancelButton(nullptr);
|
m_busyDlg->setCancelButton(nullptr);
|
||||||
m_busyDlg->hide();
|
m_busyDlg->setMinimumDuration(100);
|
||||||
connect(iface, &EncTtsSettingInterface::busy, this, &EncTtsCfgGui::showBusy);
|
m_busyDlg->setValue(1);
|
||||||
connect(iface, &EncTtsSettingInterface::busyEnd, this, &EncTtsCfgGui::hideBusy);
|
connect(iface, &EncTtsSettingInterface::busy, this, &EncTtsCfgGui::busyDialog);
|
||||||
|
|
||||||
//setup the window
|
//setup the window
|
||||||
setWindowTitle(name);
|
setWindowTitle(name);
|
||||||
|
@ -279,18 +279,21 @@ QWidget* EncTtsCfgGui::createButton(EncTtsSetting* setting)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void EncTtsCfgGui::showBusy()
|
void EncTtsCfgGui::busyDialog(bool show)
|
||||||
{
|
{
|
||||||
if(m_busyCnt == 0) m_busyDlg->show();
|
if(show)
|
||||||
|
{
|
||||||
|
m_busyDlg->setValue(0);
|
||||||
m_busyCnt++;
|
m_busyCnt++;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
void EncTtsCfgGui::hideBusy()
|
{
|
||||||
|
m_busyDlg->setValue(1);
|
||||||
|
if(m_busyCnt > 0)
|
||||||
{
|
{
|
||||||
m_busyCnt--;
|
m_busyCnt--;
|
||||||
|
}
|
||||||
if(m_busyCnt == 0) m_busyDlg->hide();
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -40,10 +40,8 @@ private slots:
|
||||||
void accept(void);
|
void accept(void);
|
||||||
//! close window and dont save configuration
|
//! close window and dont save configuration
|
||||||
void reject(void);
|
void reject(void);
|
||||||
//! shows a busy dialog. counts calls.
|
//! show / hide the busy dialog, counts calls
|
||||||
void showBusy();
|
void busyDialog(bool show);
|
||||||
//! hides the busy dialog, counts calls
|
|
||||||
void hideBusy();
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
//! creates all dynamic window content
|
//! creates all dynamic window content
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue