Skip to content

Commit 30ceabf

Browse files
committed
GUI - Show an error message when the selected language fails to load, and add a warning about stopping runs & recordings (due to restart) when changing language.
1 parent f01c901 commit 30ceabf

File tree

3 files changed

+19
-1
lines changed

3 files changed

+19
-1
lines changed

app/gui/qt/mainwindow.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -301,6 +301,11 @@ MainWindow::MainWindow(QApplication& app, QSplashScreen* splash)
301301
toggleOSCServer(1);
302302

303303
app.setActiveWindow(tabs->currentWidget());
304+
305+
if (!i18n) {
306+
showLanguageLoadingError();
307+
}
308+
304309
showWelcomeScreen();
305310
}
306311

@@ -1628,6 +1633,18 @@ void MainWindow::startupError(QString msg)
16281633
#endif
16291634
}
16301635

1636+
void MainWindow::showLanguageLoadingError() {
1637+
QMessageBox msgBox(this);
1638+
msgBox.setIcon(QMessageBox::Warning);
1639+
msgBox.setText(QString(tr("Failed to load translations for language: %1")).arg(sonicPii18n->getNativeLanguageName(this->ui_language)));
1640+
msgBox.setInformativeText(tr("Falling back to English. Sorry about this.") + "\n" + tr("Please consider reporting a bug at") + "\nhttp://github.com/sonic-pi-net/sonic-pi/issues");
1641+
1642+
QPushButton *okButton = msgBox.addButton(tr("OK"), QMessageBox::AcceptRole);
1643+
msgBox.setDefaultButton(okButton);
1644+
1645+
msgBox.exec();
1646+
}
1647+
16311648
void MainWindow::replaceBuffer(QString id, QString content, int line, int index, int first_line)
16321649
{
16331650
SonicPiScintilla* ws = filenameToWorkspace(id.toStdString());

app/gui/qt/mainwindow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,7 @@ class MainWindow : public QMainWindow
239239
void splashClose();
240240
void setMessageBoxStyle();
241241
void startupError(QString msg);
242+
void showLanguageLoadingError();
242243
void tabNext();
243244
void tabPrev();
244245
void tabGoto(int index);

app/gui/qt/widgets/settingswidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -556,7 +556,7 @@ void SettingsWidget::updateUILanguage(int index) {
556556

557557
QMessageBox msgBox(this);
558558
msgBox.setText(QString(tr("You've selected a new language: %1")).arg(new_lang));
559-
msgBox.setInformativeText(tr("Do you want to apply this language?\nApplying the new language will restart Sonic Pi."));
559+
msgBox.setInformativeText(tr("Do you want to apply this language?") + "\n" + tr("Applying the new language will stop any current runs & recordings, and restart Sonic Pi."));
560560
QPushButton *restartButton = msgBox.addButton(tr("Apply and Restart"), QMessageBox::ActionRole);
561561
QPushButton *dismissButton = msgBox.addButton(tr("Cancel"), QMessageBox::RejectRole);
562562
msgBox.setDefaultButton(restartButton);

0 commit comments

Comments
 (0)