Skip to content

Commit

Permalink
Re #6630. More logging and os-dependant assistant location.
Browse files Browse the repository at this point in the history
  • Loading branch information
peterfpeterson committed Mar 5, 2013
1 parent f27ab8b commit 8069958
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 5 deletions.
24 changes: 19 additions & 5 deletions Code/Mantid/MantidPlot/src/HelpWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const string BASEURL("qthelp://org.mantidproject/doc/");
HelpWindow::HelpWindow() :
m_collectionFile(""),
m_cacheFile(""),
m_log(Mantid::Kernel::Logger::get("HelpWindow"))
m_assistantExe(""),
m_log(Mantid::Kernel::Logger::get("HelpWindow"))
{
this->determineFileLocs();
this->start();
Expand Down Expand Up @@ -107,12 +108,12 @@ void HelpWindow::start()
args << QLatin1String("-collectionFile")
<< QLatin1String(m_collectionFile.c_str())
<< QLatin1String("-enableRemoteControl");
m_process->start(QLatin1String("/usr/bin/assistant"), args);
m_process->start(QLatin1String(m_assistantExe.c_str()), args);
if (!m_process->waitForStarted())
return;
m_log.debug() << QString("/usr/bin/assistant").toStdString()
<< " " << args.join(QString(" ")).toStdString()
<< " (state = " << m_process->state() << ")\n";
m_log.debug() << m_assistantExe
<< " " << args.join(QString(" ")).toStdString()
<< " (state = " << m_process->state() << ")\n";
}

/**
Expand Down Expand Up @@ -143,6 +144,7 @@ void HelpWindow::findCollectionFile(std::string &binDir)

// try next to the executable
Poco::Path path(binDir, COLLECTION);
m_log.debug() << "Trying \"" << path.absolute().toString() << "\"\n";
if (Poco::File(path).exists())
{
m_collectionFile =path.absolute().toString();
Expand All @@ -151,6 +153,7 @@ void HelpWindow::findCollectionFile(std::string &binDir)

// try one level up
path = Poco::Path(binDir, "../"+COLLECTION);
m_log.debug() << "Trying \"" << path.absolute().toString() << "\"\n";
if (Poco::File(path).exists())
{
m_collectionFile = path.absolute().toString();
Expand All @@ -159,6 +162,7 @@ void HelpWindow::findCollectionFile(std::string &binDir)

// try where the builds will put it
path = Poco::Path(binDir, "../qtassistant/"+COLLECTION);
m_log.debug() << "Trying \"" << path.absolute().toString() << "\"\n";
if (Poco::File(path).exists())
{
m_collectionFile = path.absolute().toString();
Expand All @@ -167,6 +171,7 @@ void HelpWindow::findCollectionFile(std::string &binDir)

// try in a good linux install location
path = Poco::Path(binDir, "../share/doc/" + COLLECTION);
m_log.debug() << "Trying \"" << path.absolute().toString() << "\"\n";
if (Poco::File(path).exists())
{
m_collectionFile = path.absolute().toString();
Expand All @@ -189,6 +194,15 @@ void HelpWindow::determineFileLocs()
this->findCollectionFile(binDir);
m_log.debug() << "using collection file \"" << m_collectionFile << "\"\n";

// location for qtassistant
#ifdef __linux__
// linux it is in system location
m_assistantExe = "/usr/bin/assistant";
#else
// windows it is next to MantidPlot
m_assistantExe = Poco::Path(binDir, "assistant").absolute().toString();
#endif

// determine cache file location
m_cacheFile = "mantid.qhc";
QString dataLoc = QDesktopServices::storageLocation(QDesktopServices::DataLocation);
Expand Down
2 changes: 2 additions & 0 deletions Code/Mantid/MantidPlot/src/HelpWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@ class HelpWindow
/** The full path of the cache file. If it is not
determined this is an empty string. */
std::string m_cacheFile;
/// QT assistant executable.
std::string m_assistantExe;
/// The logger for the class.
Mantid::Kernel::Logger& m_log;

Expand Down

0 comments on commit 8069958

Please sign in to comment.