Skip to content

Commit

Permalink
- Using OMC to get environment variables like OpenModelicaHome and Op…
Browse files Browse the repository at this point in the history
…enModelicaLibrary.

git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@7550 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
adeas31 committed Dec 22, 2010
1 parent 8c7359c commit b587517
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 15 deletions.
4 changes: 3 additions & 1 deletion OMEdit/OMEditGUI/DocumentationWidget.cpp
Expand Up @@ -93,7 +93,9 @@ DocumentationViewer::DocumentationViewer(DocumentationWidget *pParent)
{
mpParentDocumentationWidget = pParent;
// set the base url for documentation.
setBaseUrl(Helper::documentationBaseUrl);
// We need to replace the back slashes(\) with forward slash(/), since QWebView baseurl doesn't handle it.
QString baseUrl = QString(Helper::OpenModelicaLibrary).replace("\\", "/").append(Helper::documentationBaseUrl);
setBaseUrl(baseUrl);
// set page font settings
settings()->setFontFamily(QWebSettings::StandardFont, "Verdana");
settings()->setFontSize(QWebSettings::DefaultFontSize, 10);
Expand Down
7 changes: 4 additions & 3 deletions OMEdit/OMEditGUI/Helper.cpp
Expand Up @@ -36,7 +36,9 @@
QString Helper::applicationName = "OMEdit";
QString Helper::applicationVersion = "Version: 1.6.0";
QString Helper::applicationIntroText = "OpenModelica Connection Editor";
QString Helper::OpenModelicaHome = getenv("OPENMODELICAHOME");
// these two variables are set once we are connected to OMC......in OMCProxy::startServer().
QString Helper::OpenModelicaHome = QString();
QString Helper::OpenModelicaLibrary = QString();
QString Helper::omcServerName = "OMEdit";
QString Helper::omFileTypes = "*.mo";
QString Helper::omFileOpenText = "Modelica Files (*.mo)";
Expand All @@ -48,8 +50,7 @@ QString Helper::tmpPath = QString(getenv("OPENMODELICAHOME")).append(QString("/t
QString Helper::tmpPath = QString("/tmp/OMEdit");
#endif
QString Helper::settingsFileName = QString("OMEdit-Settings.xml");
// We need to replace the back slashes(\) with forward slash(/), since QWebView baseurl doesn't handle it.
QString Helper::documentationBaseUrl = QString(getenv("OPENMODELICALIBRARY")).replace("\\", "/").append(QString("/Modelica/Images/"));
QString Helper::documentationBaseUrl = QString("/Modelica/Images/");
QString Helper::readOnly = QString("Read-Only");
QString Helper::writeAble = QString("Writeable");
QString Helper::iconView = QString("Icon View");
Expand Down
1 change: 1 addition & 0 deletions OMEdit/OMEditGUI/Helper.h
Expand Up @@ -45,6 +45,7 @@ class Helper
static QString applicationVersion;
static QString applicationIntroText;
static QString OpenModelicaHome;
static QString OpenModelicaLibrary;
static QString omcServerName;
static QString omFileTypes;
static QString omFileOpenText;
Expand Down
6 changes: 5 additions & 1 deletion OMEdit/OMEditGUI/OMCProxy.cpp
Expand Up @@ -225,7 +225,7 @@ bool OMCProxy::startServer()
return false;
}
sendCommand("getInstallationDirectoryPath()");
Helper::OpenModelicaHome = getResult();
Helper::OpenModelicaHome = StringHandler::removeFirstLastQuotes(getResult());
QDir dir;
if (!dir.exists(Helper::tmpPath)) {
if (!dir.mkdir(Helper::tmpPath)) {
Expand All @@ -234,7 +234,11 @@ bool OMCProxy::startServer()
return false;
}
}
// set the temp directory.
changeDirectory(Helper::tmpPath);
// set the OpenModelicaLibrary variable.
getEnvironmentVar("OPENMODELICALIBRARY");
Helper::OpenModelicaLibrary = StringHandler::removeFirstLastQuotes(getResult());
return true;
}

Expand Down
21 changes: 11 additions & 10 deletions OMEdit/OMEditGUI/mainwindow.cpp
Expand Up @@ -607,13 +607,13 @@ void MainWindow::openUserManual()
{
QUrl userManualPath;
// since in MAC OS X the url adds extra quotes to it, so we need to handle it differently.
#ifdef Q_OS_MAC
userManualPath = QUrl(QString("file:///").append(QString(getenv("OPENMODELICAHOME")))
.append("/share/doc/omedit/OMEdit-UserManual.pdf"));
#else
//#ifdef Q_OS_MAC
// userManualPath = QUrl(QString("file:///").append(QString(getenv("OPENMODELICAHOME")))
// .append("/share/doc/omedit/OMEdit-UserManual.pdf"));
//#else
userManualPath = QUrl(QString("file:///").append(Helper::OpenModelicaHome.replace("\\", "/"))
.append("/share/doc/omedit/OMEdit-UserManual.pdf"));
#endif
//#endif
QDesktopServices::openUrl(userManualPath);
}

Expand All @@ -622,15 +622,16 @@ void MainWindow::openAbout()
const char* dateStr = __DATE__; // "Mmm dd yyyy", so dateStr+7 = "yyyy"
QString OMCVersion = mpOMCProxy->getVersion();
QString aboutText = QString("OMEdit - ").append(Helper::applicationIntroText).append(" ")
.append(Helper::applicationVersion).append(" Copyright ").append(dateStr + 7)
.append(Helper::applicationVersion).append("\n")
.append("Connected to OpenModelica ").append(OMCVersion).append("\n\n")
.append("Copyright ").append(dateStr + 7)
.append(" Link").append(QChar(246, 0)).append("ping University.\n")
.append("Distributed under OSMC-PL and GPL, see www.openmodelica.org.\n\n")
.append("Connected to OpenModelica ").append(OMCVersion).append("\n")
.append("Created by Syed Adeel Asghar and Sonia Tariq as part of their final thesis.\n\n")
.append("Created by Adeel Asghar and Sonia Tariq as part of their final thesis.\n\n")
.append("Supervisor: Dr. Mohsen Torabzadeh-Tari\n")
.append("Advisor: Martin Sj").append(QChar(246, 0)).append("lund\n")
.append("Advisor: Mr. Martin Sj").append(QChar(246, 0)).append("lund\n")
.append("Examiner: Prof. Peter Fritzson\n\n")
.append("Special Thanks to Adrian Pop for helping in OMC related issues.");
.append("Special Thanks to Dr. Adrian Pop for helping in OMC related issues.");

QMessageBox::about(this, QString("About ").append(Helper::applicationName), aboutText);
}
Expand Down

0 comments on commit b587517

Please sign in to comment.