@@ -69,10 +69,10 @@ MainWidget::MainWidget(QSettings *settings, QWidget *parent)
6969 m_settings->setValue (" MainWidget/max_audio_seg_length" , max_audio_seg_length);
7070
7171 // Automatically load config when widget is initialized
72- const QString modelPath = m_modelPathEdit->text ();
73- if (!modelPath.isEmpty ()) {
74- loadLanguagesFromConfig (std::filesystem::path ( modelPath. toStdWString ()) );
75- updateTimeStepInfo (std::filesystem::path ( modelPath. toStdWString ()) );
72+ const auto modelPath = std::filesystem::path ( m_modelPathEdit->text (). toLocal8Bit (). toStdString () );
73+ if (!modelPath.empty ()) {
74+ loadLanguagesFromConfig (modelPath);
75+ updateTimeStepInfo (modelPath);
7676 }
7777}
7878
@@ -132,6 +132,8 @@ void MainWidget::setModelLoadingStatus(const QString &status) {
132132 m_modelStatusLabel->setStyleSheet (" QLabel { color: green; font-weight: bold; }" );
133133 } else if (status.contains (" Failed" ) || status.contains (" failed" ) || status.contains (" Error" )) {
134134 m_modelStatusLabel->setStyleSheet (" QLabel { color: red; font-weight: bold; }" );
135+ } else if (status.contains (" Loading" ) || status.contains (" loading" )) {
136+ m_modelStatusLabel->setStyleSheet (" QLabel { color: blue; font-weight: bold; }" );
135137 } else {
136138 m_modelStatusLabel->setStyleSheet (" QLabel { color: gray; font-style: italic; }" );
137139 }
@@ -311,8 +313,10 @@ void MainWidget::setupActionButtons() {
311313}
312314
313315void MainWidget::browseModelPath () {
314- const QString dir = QFileDialog::getExistingDirectory (this , " Select Model Directory" , m_modelPathEdit->text (),
315- QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks);
316+ const QString dir =
317+ QFileDialog::getExistingDirectory (this , " Select Model Directory" , m_modelPathEdit->text ().toLocal8Bit (),
318+ QFileDialog::ShowDirsOnly | QFileDialog::DontResolveSymlinks)
319+ .toLocal8Bit ();
316320
317321 if (!dir.isEmpty ()) {
318322 m_modelPathEdit->setText (dir);
@@ -376,20 +380,23 @@ bool MainWidget::loadModel(std::string &message) {
376380 return false ;
377381 }
378382
379- std::filesystem::path modelPath = m_modelPathEdit->text ().toStdWString ();
383+ std::filesystem::path modelPath = m_modelPathEdit->text ().toLocal8Bit (). toStdString ();
380384
381385 // Get execution provider from combo box
382386 const auto provider = static_cast <Game::ExecutionProvider>(m_providerCombo->currentData ().toInt ());
383387 const int deviceId = m_deviceCombo->currentData ().toInt ();
384388 std::string msg;
389+
390+ QMetaObject::invokeMethod (
391+ this , [this ] { setModelLoadingStatus (" Model is loading, please wait 3-10 seconds!" ); }, Qt::QueuedConnection);
385392 if (m_game->load_model (modelPath, provider, deviceId, msg)) {
386393 updateParameterValues ();
387394 // Successfully loaded, update UI
388395 QMetaObject::invokeMethod (
389396 this ,
390397 [this , modelPath] {
391398 setModelLoadingStatus (" Model loaded successfully!" );
392- m_settings->setValue (" MainWidget/modelPath" , QString::fromStdString (modelPath.string ()));
399+ m_settings->setValue (" MainWidget/modelPath" , QString::fromStdWString (modelPath.wstring ()));
393400 },
394401 Qt::QueuedConnection);
395402 } else {
@@ -546,6 +553,7 @@ void MainWidget::onExportMidiTask() {
546553 return ;
547554 }
548555
556+ m_runButton->setEnabled (false );
549557 m_progressBar->setValue (0 );
550558
551559 QFuture<void > future = QtConcurrent::run ([this ] {
@@ -561,6 +569,7 @@ void MainWidget::onExportMidiTask() {
561569 .arg (m_wavPathLineEdit->text ().toLocal8Bit ().toStdString ()));
562570 },
563571 Qt::QueuedConnection);
572+ QMetaObject::invokeMethod (m_runButton, " setEnabled" , Qt::QueuedConnection, Q_ARG (bool , true ));
564573 return ;
565574 }
566575
@@ -570,15 +579,15 @@ void MainWidget::onExportMidiTask() {
570579 QMetaObject::invokeMethod (
571580 this ,
572581 [this , msg_] {
573- QMessageBox::information (this , " Fail" , " Model load failed! - " + QString::fromStdString (msg_));
582+ QMessageBox::information (this , " Fail" , " Model load failed! - " + QString::fromLocal8Bit (msg_));
574583 },
575584 Qt::QueuedConnection);
585+ QMetaObject::invokeMethod (m_runButton, " setEnabled" , Qt::QueuedConnection, Q_ARG (bool , true ));
576586 return ;
577587 }
578588 }
579589
580590 updateParameterValues ();
581- QMetaObject::invokeMethod (m_runButton, " setEnabled" , Qt::QueuedConnection, Q_ARG (bool , false ));
582591 const bool success = m_game->get_midi (
583592 m_wavPathLineEdit->text ().toLocal8Bit ().toStdString (), midis, static_cast <float >(m_tempoSpin->value ()), msg,
584593 [this ](const int progress) {
0 commit comments