Skip to content

Commit

Permalink
Removed the prompt for switching to OF if translation fails (#8663)
Browse files Browse the repository at this point in the history
The NF is better than OF now so its no point to prompt to the user to try with OF.
The option to enable OF is still there.
  • Loading branch information
adeas31 committed Mar 9, 2022
1 parent 1597fe0 commit 5b39f81
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 114 deletions.
17 changes: 0 additions & 17 deletions OMEdit/OMEditLIB/Options/OptionsDialog.cpp
Expand Up @@ -733,13 +733,6 @@ void OptionsDialog::readNotificationsSettings()
if (mpSettings->contains("notifications/alwaysAskForTextEditorError")) {
mpNotificationsPage->getAlwaysAskForTextEditorErrorCheckBox()->setChecked(mpSettings->value("notifications/alwaysAskForTextEditorError").toBool());
}
if (mpSettings->contains("notifications/promptOldFrontend")) {
bool ok;
int currentIndex = mpNotificationsPage->getOldFrontendComboBox()->findData(mpSettings->value("notifications/promptOldFrontend").toInt(&ok));
if (currentIndex > -1 && ok) {
mpNotificationsPage->getOldFrontendComboBox()->setCurrentIndex(currentIndex);
}
}
}

//! Reads the LineStyle section settings from omedit.ini
Expand Down Expand Up @@ -1454,7 +1447,6 @@ void OptionsDialog::saveNotificationsSettings()
mpSettings->setValue("notifications/saveModelForBitmapInsertion", mpNotificationsPage->getSaveModelForBitmapInsertionCheckBox()->isChecked());
mpSettings->setValue("notifications/alwaysAskForDraggedComponentName", mpNotificationsPage->getAlwaysAskForDraggedComponentName()->isChecked());
mpSettings->setValue("notifications/alwaysAskForTextEditorError", mpNotificationsPage->getAlwaysAskForTextEditorErrorCheckBox()->isChecked());
mpSettings->setValue("notifications/promptOldFrontend", mpNotificationsPage->getOldFrontendComboBox()->itemData(mpNotificationsPage->getOldFrontendComboBox()->currentIndex()).toInt());
}

//! Saves the LineStyle section settings to omedit.ini
Expand Down Expand Up @@ -4203,13 +4195,6 @@ NotificationsPage::NotificationsPage(OptionsDialog *pOptionsDialog)
// create the always ask for text editor error
mpAlwaysAskForTextEditorErrorCheckBox = new QCheckBox(tr("Always ask for what to do with the text editor error"));
mpAlwaysAskForTextEditorErrorCheckBox->setChecked(true);
// prompt for old frontend
mpOldFrontendLabel = new Label(tr("If new frontend for code generation fails?"));
mpOldFrontendComboBox = new QComboBox;
mpOldFrontendComboBox->addItem(tr("Always ask for old frontend"), NotificationsPage::AlwaysAskForOF);
mpOldFrontendComboBox->addItem(tr("Try with old frontend once"), NotificationsPage::TryOnceWithOF);
mpOldFrontendComboBox->addItem(tr("Switch to old frontend permanently"), NotificationsPage::SwitchPermanentlyToOF);
mpOldFrontendComboBox->addItem(tr("Keep using new frontend"), NotificationsPage::KeepUsingNF);
// set the layout of notifications group
QGridLayout *pNotificationsLayout = new QGridLayout;
pNotificationsLayout->setAlignment(Qt::AlignTop);
Expand All @@ -4220,8 +4205,6 @@ NotificationsPage::NotificationsPage(OptionsDialog *pOptionsDialog)
pNotificationsLayout->addWidget(mpSaveModelForBitmapInsertionCheckBox, 4, 0, 1, 2);
pNotificationsLayout->addWidget(mpAlwaysAskForDraggedComponentName, 5, 0, 1, 2);
pNotificationsLayout->addWidget(mpAlwaysAskForTextEditorErrorCheckBox, 6, 0, 1, 2);
pNotificationsLayout->addWidget(mpOldFrontendLabel, 7, 0);
pNotificationsLayout->addWidget(mpOldFrontendComboBox, 7, 1);
mpNotificationsGroupBox->setLayout(pNotificationsLayout);
// set the layout
QVBoxLayout *pLayout = new QVBoxLayout;
Expand Down
3 changes: 0 additions & 3 deletions OMEdit/OMEditLIB/Options/OptionsDialog.h
Expand Up @@ -725,7 +725,6 @@ class NotificationsPage : public QWidget
QCheckBox* getSaveModelForBitmapInsertionCheckBox() {return mpSaveModelForBitmapInsertionCheckBox;}
QCheckBox* getAlwaysAskForDraggedComponentName() {return mpAlwaysAskForDraggedComponentName;}
QCheckBox* getAlwaysAskForTextEditorErrorCheckBox() {return mpAlwaysAskForTextEditorErrorCheckBox;}
QComboBox* getOldFrontendComboBox() {return mpOldFrontendComboBox;}
private:
OptionsDialog *mpOptionsDialog;
QGroupBox *mpNotificationsGroupBox;
Expand All @@ -736,8 +735,6 @@ class NotificationsPage : public QWidget
QCheckBox *mpSaveModelForBitmapInsertionCheckBox;
QCheckBox *mpAlwaysAskForDraggedComponentName;
QCheckBox *mpAlwaysAskForTextEditorErrorCheckBox;
Label *mpOldFrontendLabel;
QComboBox *mpOldFrontendComboBox;
};

class LineStylePage : public QWidget
Expand Down
94 changes: 0 additions & 94 deletions OMEdit/OMEditLIB/Simulation/SimulationDialog.cpp
Expand Up @@ -1082,100 +1082,6 @@ bool SimulationDialog::translateModel(QString simulationParameters)
MainWindow::instance()->getOMCProxy()->setCommandLineOptions(QString("--preOptModules+=%1").arg(mpLibraryTreeItem->mSimulationOptions.getDataReconciliationAlgorithm()));
}
bool result = MainWindow::instance()->getOMCProxy()->translateModel(mClassName, simulationParameters);
if (!result) {
//! @todo Remove this once new frontend is used as default and old frontend is removed.
bool newFrontendEnabled = true;
QList<QString> options = MainWindow::instance()->getOMCProxy()->getCommandLineOptions();
foreach (QString option, options) {
if (option.contains("nonewInst")) {
newFrontendEnabled = false;
break;
}
}

if (newFrontendEnabled) {
QSettings *pSettings = Utilities::getApplicationSettings();
int answer;
QComboBox *pOldFrontendComboBox = OptionsDialog::instance()->getNotificationsPage()->getOldFrontendComboBox();
if (pOldFrontendComboBox->itemData(pOldFrontendComboBox->currentIndex()) == NotificationsPage::AlwaysAskForOF) {
QDialog *pOldFrontEndSelectionDialog = new QDialog;
pOldFrontEndSelectionDialog->setAttribute(Qt::WA_DeleteOnClose);
pOldFrontEndSelectionDialog->setWindowTitle(QString("%1 -%2").arg(Helper::applicationName, Helper::question));
pOldFrontEndSelectionDialog->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
// Icon
Label *pPixmapLabel = new Label;
QStyle *pStyle = this->style();
int iconSize = pStyle->pixelMetric(QStyle::PM_MessageBoxIconSize, 0, this);
pPixmapLabel->setPixmap(pStyle->standardIcon(QStyle::SP_MessageBoxQuestion, 0, this).pixmap(iconSize, iconSize));
// Label
Label *pMessageLabel = new Label(tr("The code generation process failed, see the Messages Browser for detailed diagnostic messages.<br /><br />"
"Most likely this is due to some issues in the Modelica source code, but it could also be due to some issues with the new OpenModelica compiler frontend.<br />"
"In this case, you may re-try the code generation with the old frontend, see also <b>%1->Simulation->Enable old frontend for code generation</b>.").arg(Helper::toolsOptionsPath));
pMessageLabel->setTextFormat(Qt::RichText);
pMessageLabel->setTextInteractionFlags(pMessageLabel->textInteractionFlags() | Qt::LinksAccessibleByMouse | Qt::LinksAccessibleByKeyboard);
pMessageLabel->setOpenExternalLinks(true);
// Checkbox
QCheckBox *pRememberCheckBox = new QCheckBox(tr("Remember my decision and do not ask again"));
// buttons
QPushButton *pTryOnceButton = new QPushButton(tr("Try with old frontend once"));
pTryOnceButton->setAutoDefault(false);
connect(pTryOnceButton, SIGNAL(clicked()), pOldFrontEndSelectionDialog, SLOT(accept()));
QSignalMapper signalMapper;
QPushButton *pSwitchButton = new QPushButton(tr("Switch to old frontend permanently"));
pSwitchButton->setAutoDefault(false);
connect(pSwitchButton, SIGNAL(clicked()), &signalMapper, SLOT(map()));
QPushButton *pKeepButton = new QPushButton(tr("Keep using new frontend"));
pKeepButton->setAutoDefault(true);
connect(pKeepButton, SIGNAL(clicked()), &signalMapper, SLOT(map()));
signalMapper.setMapping(pSwitchButton, 2);
signalMapper.setMapping(pKeepButton, 3);
connect(&signalMapper, SIGNAL(mapped(int)), pOldFrontEndSelectionDialog, SLOT(done(int)));
QDialogButtonBox *pButtonBox = new QDialogButtonBox(Qt::Horizontal);
pButtonBox->addButton(pKeepButton, QDialogButtonBox::ActionRole);
pButtonBox->addButton(pTryOnceButton, QDialogButtonBox::ActionRole);
pButtonBox->addButton(pSwitchButton, QDialogButtonBox::ActionRole);
// horizontal layout
QHBoxLayout *pHorizontalLayout = new QHBoxLayout;
pHorizontalLayout->addWidget(pPixmapLabel, 0, Qt::AlignTop);
pHorizontalLayout->addWidget(pMessageLabel, 0, Qt::AlignTop);
// main layout
QGridLayout *pMainLayout = new QGridLayout;
pMainLayout->addLayout(pHorizontalLayout, 0, 0, 1, 2, Qt::AlignTop | Qt::AlignLeft);
pMainLayout->addWidget(pRememberCheckBox, 1, 0, Qt::AlignLeft | Qt::AlignBottom);
pMainLayout->addWidget(pButtonBox, 1, 1, Qt::AlignRight | Qt::AlignBottom);
pOldFrontEndSelectionDialog->setLayout(pMainLayout);
answer = pOldFrontEndSelectionDialog->exec();
if (answer > 1 && pRememberCheckBox->isChecked()) {
pSettings->setValue("notifications/promptOldFrontend", answer);
pOldFrontendComboBox->setCurrentIndex(pOldFrontendComboBox->findData(answer));
}
} else {
answer = pOldFrontendComboBox->itemData(pOldFrontendComboBox->currentIndex()).toInt();
}

switch (answer) {
case 1:
MainWindow::instance()->getOMCProxy()->disableNewInstantiation();
result = MainWindow::instance()->getOMCProxy()->translateModel(mClassName, simulationParameters);
break;
case 2:
OptionsDialog::instance()->getSimulationPage()->getTranslationFlagsWidget()->getOldInstantiationCheckBox()->setChecked(true);
mpTranslationFlagsWidget->getOldInstantiationCheckBox()->setChecked(true);
if (mpLibraryTreeItem->mSimulationOptions.isValid()) {
mpLibraryTreeItem->mSimulationOptions.setOldInstantiation(true);
}
MainWindow::instance()->getOMCProxy()->disableNewInstantiation();
result = MainWindow::instance()->getOMCProxy()->translateModel(mClassName, simulationParameters);
break;
case 3:
break;
case 0:
default:
// user cancelled. Do nothing.
break;
}
}
}
// reset simulation settings
OptionsDialog::instance()->saveSimulationSettings();
OptionsDialog::instance()->saveNFAPISettings();
Expand Down

0 comments on commit 5b39f81

Please sign in to comment.