Skip to content

Commit

Permalink
Added menu items to open the OpenModelica latest & old pdf documentat…
Browse files Browse the repository at this point in the history
…ion.
  • Loading branch information
adeas31 committed Jun 24, 2015
1 parent cf67183 commit fcd77e5
Show file tree
Hide file tree
Showing 7 changed files with 81 additions and 5 deletions.
66 changes: 64 additions & 2 deletions OMEdit/OMEditGUI/MainWindow.cpp
Expand Up @@ -2026,26 +2026,78 @@ void MainWindow::openConfigurationOptions()
mpOptionsDialog->show();
}

/*!
* \brief MainWindow::openUsersGuide
* Slot activated when mpUsersGuideAction triggered signal is raised.\n
* Opens the html based version of OpenModelica users guide.
*/
void MainWindow::openUsersGuide()
{

}

/*!
* \brief MainWindow::openUsersGuideNewPdf
* Slot activated when mpUsersGuideNewPdfAction triggered signal is raised.\n
* Opens the new pdf versions of OpenModelica users guide.
*/
void MainWindow::openUsersGuidePdf()
{
QUrl usersGuidePath (QString("file:///").append(QString(Helper::OpenModelicaHome).replace("\\", "/"))
.append("/share/doc/omc/OpenModelicaUsersGuide-latest.pdf"));
if (!QDesktopServices::openUrl(usersGuidePath)) {
mpMessagesWidget->addGUIMessage(MessageItem(MessageItem::Modelica, "", false, 0, 0, 0, 0,
GUIMessages::getMessage(GUIMessages::UNABLE_TO_OPEN_FILE).arg(usersGuidePath.toString()),
Helper::scriptingKind, Helper::errorLevel));
}
}

/*!
* \brief MainWindow::openUsersGuideOldPdf
* Slot activated when mpUsersGuideOldPdfAction triggered signal is raised.\n
* Opens the old pdf versions of OpenModelica users guide.
*/
void MainWindow::openUsersGuideOldPdf()
{
QUrl usersGuidePath (QString("file:///").append(QString(Helper::OpenModelicaHome).replace("\\", "/"))
.append("/share/doc/omc/OpenModelicaUsersGuide.pdf"));
QDesktopServices::openUrl(usersGuidePath);
if (!QDesktopServices::openUrl(usersGuidePath)) {
mpMessagesWidget->addGUIMessage(MessageItem(MessageItem::Modelica, "", false, 0, 0, 0, 0,
GUIMessages::getMessage(GUIMessages::UNABLE_TO_OPEN_FILE).arg(usersGuidePath.toString()),
Helper::scriptingKind, Helper::errorLevel));
}
}

/*!
* \brief MainWindow::openSystemDocumentation
* Slot activated when mpSystemDocumentationAction triggered signal is raised.\n
* Opens the OpenModelica system documentation.
*/
void MainWindow::openSystemDocumentation()
{
QUrl systemDocumentationPath (QString("file:///").append(QString(Helper::OpenModelicaHome).replace("\\", "/"))
.append("/share/doc/omc/OpenModelicaSystem.pdf"));
QDesktopServices::openUrl(systemDocumentationPath);
if (!QDesktopServices::openUrl(systemDocumentationPath)) {
mpMessagesWidget->addGUIMessage(MessageItem(MessageItem::Modelica, "", false, 0, 0, 0, 0,
GUIMessages::getMessage(GUIMessages::UNABLE_TO_OPEN_FILE).arg(systemDocumentationPath.toString()),
Helper::scriptingKind, Helper::errorLevel));
}
}

/*!
* \brief MainWindow::openOpenModelicaScriptingDocumentation
* Opens the OpenModelica scripting documentation.
*/
void MainWindow::openOpenModelicaScriptingDocumentation()
{
QUrl openModelicaScriptingUrl (QUrl("https://build.openmodelica.org/Documentation/OpenModelica.Scripting.html"));
QDesktopServices::openUrl(openModelicaScriptingUrl);
}

/*!
* \brief MainWindow::openModelicaDocumentation
* Opens the Modelica documentation.
*/
void MainWindow::openModelicaDocumentation()
{
QUrl modelicaDocumentationUrl (QUrl("https://build.openmodelica.org/Documentation/index.html"));
Expand Down Expand Up @@ -2539,6 +2591,14 @@ void MainWindow::createActions()
mpUsersGuideAction->setStatusTip(tr("Opens the OpenModelica Users Guide"));
mpUsersGuideAction->setShortcut(QKeySequence(Qt::Key_F1));
connect(mpUsersGuideAction, SIGNAL(triggered()), SLOT(openUsersGuide()));
// users guide new pdf action
mpUsersGuidePdfAction = new QAction(tr("OpenModelica Users Guide (PDF)"), this);
mpUsersGuidePdfAction->setStatusTip(tr("Opens the OpenModelica Users Guide (PDF)"));
connect(mpUsersGuidePdfAction, SIGNAL(triggered()), SLOT(openUsersGuidePdf()));
// users guide old pdf action
mpUsersGuideOldPdfAction = new QAction(tr("OpenModelica Users Guide (Old PDF)"), this);
mpUsersGuideOldPdfAction->setStatusTip(tr("Opens the OpenModelica Users Guide (Old PDF)"));
connect(mpUsersGuideOldPdfAction, SIGNAL(triggered()), SLOT(openUsersGuideOldPdf()));
// system documentation action
mpSystemDocumentationAction = new QAction(tr("OpenModelica System Documentation"), this);
mpSystemDocumentationAction->setStatusTip(tr("Opens the OpenModelica System Documentation"));
Expand Down Expand Up @@ -2808,6 +2868,8 @@ void MainWindow::createMenus()
pHelpMenu->setTitle(tr("&Help"));
// add actions to Help menu
pHelpMenu->addAction(mpUsersGuideAction);
pHelpMenu->addAction(mpUsersGuidePdfAction);
pHelpMenu->addAction(mpUsersGuideOldPdfAction);
pHelpMenu->addAction(mpSystemDocumentationAction);
pHelpMenu->addAction(mpOpenModelicaScriptingAction);
pHelpMenu->addAction(mpModelicaDocumentationAction);
Expand Down
4 changes: 4 additions & 0 deletions OMEdit/OMEditGUI/MainWindow.h
Expand Up @@ -263,6 +263,8 @@ class MainWindow : public QMainWindow
QAction *mpOptionsAction;
// Help Menu
QAction *mpUsersGuideAction;
QAction *mpUsersGuidePdfAction;
QAction *mpUsersGuideOldPdfAction;
QAction *mpSystemDocumentationAction;
QAction *mpOpenModelicaScriptingAction;
QAction *mpModelicaDocumentationAction;
Expand Down Expand Up @@ -354,6 +356,8 @@ public slots:
void TLMSimulate();
void openConfigurationOptions();
void openUsersGuide();
void openUsersGuidePdf();
void openUsersGuideOldPdf();
void openSystemDocumentation();
void openOpenModelicaScriptingDocumentation();
void openModelicaDocumentation();
Expand Down
4 changes: 2 additions & 2 deletions OMEdit/OMEditGUI/Modeling/LibraryTreeWidget.cpp
Expand Up @@ -1244,7 +1244,7 @@ bool LibraryTreeWidget::saveTextLibraryTreeNode(LibraryTreeNode *pLibraryTreeNod
}
} else {
QMessageBox::information(this, Helper::applicationName + " - " + Helper::error, GUIMessages::getMessage(GUIMessages::ERROR_OCCURRED)
.arg(tr("Unable to save the file. %1").arg(file.errorString())), Helper::ok);
.arg(GUIMessages::getMessage(GUIMessages::UNABLE_TO_SAVE_FILE).arg(file.errorString())), Helper::ok);
return false;
}
return true;
Expand Down Expand Up @@ -1305,7 +1305,7 @@ bool LibraryTreeWidget::saveTLMLibraryTreeNode(LibraryTreeNode *pLibraryTreeNode
}
} else {
QMessageBox::information(this, Helper::applicationName + " - " + Helper::error, GUIMessages::getMessage(GUIMessages::ERROR_OCCURRED)
.arg(tr("Unable to save the file. %1").arg(file.errorString())), Helper::ok);
.arg(GUIMessages::getMessage(GUIMessages::UNABLE_TO_SAVE_FILE).arg(file.errorString())), Helper::ok);
return false;
}
getMainWindow()->addRecentFile(pLibraryTreeNode->getFileName(), Helper::utf8);
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/TLM/TLMCoSimulationOutputWidget.h
Expand Up @@ -51,6 +51,7 @@ class TLMCoSimulationOutputWidget : public QWidget
TLMCoSimulationOutputWidget(MainWindow *pMainWindow);
~TLMCoSimulationOutputWidget();
TLMCoSimulationOptions getTLMCoSimulationOptions() {return mTLMCoSimulationOptions;}
MainWindow* getMainWindow() {return mpMainWindow;}
void showTLMCoSimulationOutputWidget(TLMCoSimulationOptions tlmCoSimulationOptions);
void clear();
private:
Expand Down
5 changes: 4 additions & 1 deletion OMEdit/OMEditGUI/TLM/TLMCoSimulationThread.cpp
Expand Up @@ -233,6 +233,9 @@ void TLMCoSimulationThread::progressFileChanged()
}
mProgressFile.close();
} else {
qDebug() << QString("unable to open file %1").arg(mProgressFile.fileName());
MessagesWidget *pMessagesWidget = mpTLMCoSimulationOutputWidget->getMainWindow()->getMessagesWidget();
pMessagesWidget->addGUIMessage(MessageItem(MessageItem::Modelica, "", false, 0, 0, 0, 0,
GUIMessages::getMessage(GUIMessages::UNABLE_TO_OPEN_FILE).arg(mProgressFile.fileName()),
Helper::scriptingKind, Helper::errorLevel));
}
}
4 changes: 4 additions & 0 deletions OMEdit/OMEditGUI/Util/Helper.cpp
Expand Up @@ -528,6 +528,10 @@ QString GUIMessages::getMessage(int type)
return tr("Please make sure you are not using any OpenModelica Keywords like (model, package, record, class etc.)");
case UNABLE_TO_LOAD_FILE:
return tr("Error has occurred while loading the file/library <b>%1</b>. Unable to load the file/library.");
case UNABLE_TO_OPEN_FILE:
return tr("Unable to open file <b>%1</b>.");
case UNABLE_TO_SAVE_FILE:
return tr("Unable to save the file <b>%1</b>.");
case FILE_NOT_FOUND:
return tr("The file <b>%1</b> not found.");
case ERROR_OPENING_FILE:
Expand Down
2 changes: 2 additions & 0 deletions OMEdit/OMEditGUI/Util/Helper.h
Expand Up @@ -329,6 +329,8 @@ class GUIMessages : public QObject
REVERT_PREVIOUS_OR_FIX_ERRORS_MANUALLY,
NO_OPENMODELICA_KEYWORDS,
UNABLE_TO_LOAD_FILE,
UNABLE_TO_OPEN_FILE,
UNABLE_TO_SAVE_FILE,
FILE_NOT_FOUND,
ERROR_OPENING_FILE,
UNABLE_TO_LOAD_MODEL,
Expand Down

0 comments on commit fcd77e5

Please sign in to comment.