diff options
author | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2022-03-20 09:58:04 +0100 |
---|---|---|
committer | Dominik Riebeling <Dominik.Riebeling@gmail.com> | 2022-03-20 10:00:25 +0100 |
commit | ccdd9e6784c1aaee8ebb35f192dae647895c67bc (patch) | |
tree | 2ec8164d4b6f504adc3f2d441f4c20a0e77ad8e7 | |
parent | c21d10cb33e0d123d4b53acdc28e73002d240634 (diff) | |
download | rockbox-ccdd9e6784.tar.gz rockbox-ccdd9e6784.zip |
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
-rw-r--r-- | utils/rbutilqt/base/encttssettings.h | 3 | ||||
-rw-r--r-- | utils/rbutilqt/base/ttsfestival.cpp | 6 | ||||
-rw-r--r-- | utils/rbutilqt/encttscfggui.cpp | 33 | ||||
-rw-r--r-- | utils/rbutilqt/encttscfggui.h | 6 |
4 files changed, 24 insertions, 24 deletions
diff --git a/utils/rbutilqt/base/encttssettings.h b/utils/rbutilqt/base/encttssettings.h index 1258d81d57..ef3e5728b5 100644 --- a/utils/rbutilqt/base/encttssettings.h +++ b/utils/rbutilqt/base/encttssettings.h @@ -108,8 +108,7 @@ public: virtual void saveSettings() = 0; signals: - void busy(); // emit this if a operation takes time - void busyEnd(); // emit this at the end of a busy section + void busy(bool show); // emit this if a operation takes time protected: //! Child class should fill in the setttingsList diff --git a/utils/rbutilqt/base/ttsfestival.cpp b/utils/rbutilqt/base/ttsfestival.cpp index fbb8166a9a..fce1d8cb3e 100644 --- a/utils/rbutilqt/base/ttsfestival.cpp +++ b/utils/rbutilqt/base/ttsfestival.cpp @@ -336,14 +336,14 @@ QString TTSFestival::queryServer(QString query, int timeout) return ""; // this operation could take some time - emit busy(); + emit busy(true); LOG_INFO() << "queryServer with" << query; if (!ensureServerRunning()) { LOG_ERROR() << "queryServer: ensureServerRunning failed"; - emit busyEnd(); + emit busy(false); return ""; } @@ -391,7 +391,7 @@ QString TTSFestival::queryServer(QString query, int timeout) while(QDateTime::currentDateTime() < tmpEndTime) QCoreApplication::processEvents(QEventLoop::AllEvents); } - emit busyEnd(); + emit busy(false); socket.disconnectFromHost(); if(response == "nil") diff --git a/utils/rbutilqt/encttscfggui.cpp b/utils/rbutilqt/encttscfggui.cpp index cd2cf24f5b..e0f203bc1c 100644 --- a/utils/rbutilqt/encttscfggui.cpp +++ b/utils/rbutilqt/encttscfggui.cpp @@ -40,14 +40,14 @@ EncTtsCfgGui::EncTtsCfgGui(QDialog* parent, EncTtsSettingInterface* iface, QStri m_busyCnt(0) { // 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->setModal(true); m_busyDlg->setLabel(nullptr); m_busyDlg->setCancelButton(nullptr); - m_busyDlg->hide(); - connect(iface, &EncTtsSettingInterface::busy, this, &EncTtsCfgGui::showBusy); - connect(iface, &EncTtsSettingInterface::busyEnd, this, &EncTtsCfgGui::hideBusy); + m_busyDlg->setMinimumDuration(100); + m_busyDlg->setValue(1); + connect(iface, &EncTtsSettingInterface::busy, this, &EncTtsCfgGui::busyDialog); //setup the window 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(); - - m_busyCnt++; -} - -void EncTtsCfgGui::hideBusy() -{ - m_busyCnt--; - - if(m_busyCnt == 0) m_busyDlg->hide(); + if(show) + { + m_busyDlg->setValue(0); + m_busyCnt++; + } + else + { + m_busyDlg->setValue(1); + if(m_busyCnt > 0) + { + m_busyCnt--; + } + } } diff --git a/utils/rbutilqt/encttscfggui.h b/utils/rbutilqt/encttscfggui.h index bf9f08a384..109aebd399 100644 --- a/utils/rbutilqt/encttscfggui.h +++ b/utils/rbutilqt/encttscfggui.h @@ -40,10 +40,8 @@ private slots: void accept(void); //! close window and dont save configuration void reject(void); - //! shows a busy dialog. counts calls. - void showBusy(); - //! hides the busy dialog, counts calls - void hideBusy(); + //! show / hide the busy dialog, counts calls + void busyDialog(bool show); private: //! creates all dynamic window content |