Updated the QAssistant launching code for Qt 4.5 (At least on windows; needs testing...
authorBrandon King <kingb@caltech.edu>
Tue, 17 Nov 2009 02:37:49 +0000 (18:37 -0800)
committerBrandon King <kingb@caltech.edu>
Tue, 17 Nov 2009 02:37:49 +0000 (18:37 -0800)
qui/MussaWindow.cpp
qui/MussaWindow.hpp

index b0342e40c0e186ba7731a28367735985f424d12d..f302f8e184d7b88a81d93f9e6908951db830c6dd 100644 (file)
 #include <QFileDialog>
 #include <QHBoxLayout>
 #include <QIcon>
+#include <QLibraryInfo>
 #include <QMenuBar>
 #include <QMessageBox>
+#include <QProcess>
 #include <QScrollBar>
 #include <QStatusBar>
 #include <QString>
 #include <QStringList>
+#include <QTextStream>
 #include <QUrl>
 #include <QWhatsThis>
 
@@ -66,7 +69,7 @@ MussaWindow::MussaWindow(MussaRef analysis_, QWidget *parent) :
   saveBrowserPixmapAction(0),
   whatsThisAction(0),
   viewMussaAlignmentAction(0),
-  manualAssistant(0)
+  assistantProcess(0)
 {
   init_resources();
   
@@ -314,6 +317,7 @@ void MussaWindow::setupWidgets()
 void MussaWindow::setupAssistant()
 {
 #if defined(QT_QTASSISTANT_FOUND)
+  /*
   QStringList manualAssistantArgs;
   manualAssistantArgs = QStringList();
   manualAssistantArgs << "-profile" << "./doc/manual/mussagl_manual.adp";
@@ -321,6 +325,7 @@ void MussaWindow::setupAssistant()
   manualAssistant->setArguments(manualAssistantArgs);
   connect(manualAssistant, SIGNAL(error(QString)),
          this, SLOT(assistantError(QString)));
+  */
 #endif
 }
   
@@ -689,16 +694,31 @@ void MussaWindow::toggleMotifs()
 void MussaWindow::showManual()
 {
 #if defined(QT_QTASSISTANT_FOUND)
-  if (manualAssistant) { 
-    manualAssistant->openAssistant();
-  } else {
-    QMessageBox::warning(this,
-                         tr("Mussa Help Error"),
-                         tr("QtAssistant not setup correctly"),
-                         QMessageBox::Ok,
-                         QMessageBox::NoButton,
-                         QMessageBox::NoButton);
+  
+  // Only define the process once.
+  if (!assistantProcess)
+    assistantProcess = new QProcess(this);
+  
+  // No need to fire up the process again if it is already running.
+  if (assistantProcess->state() == QProcess::Running)
+    return;
+  
+  QString app = QLibraryInfo::location(QLibraryInfo::BinariesPath)
+      + QLatin1String("/assistant");
+
+  assistantProcess->start(app, QStringList() << QLatin1String("-enableRemoteControl")
+                           << QLatin1String("-collectionFile") << QLatin1String("mussagl_manual.qhc"));
+  if (!assistantProcess->waitForStarted()) {
+      QMessageBox::critical(this, tr("Remote Control"),
+         tr("Could not start Qt Assistant from %1.").arg(app));
+      return;
   }
+
+  // show index page
+  QTextStream str(assistantProcess);
+  str << QLatin1String("SetSource qthelp://edu.caltech.woldlab.mussagl.1_0_0/doc/mussagl_manual.html")
+      << QLatin1Char('\0') << endl;
+
 #else
   QUrl manual_url("http://woldlab.caltech.edu/~king/mussagl_manual/");
   if (not QDesktopServices::openUrl(manual_url)) {
@@ -708,7 +728,6 @@ void MussaWindow::showManual()
                          QMessageBox::Ok,
                          QMessageBox::NoButton,
                          QMessageBox::NoButton);
-  }
 #endif //QT_QTASSISTANT_FOUND
 }
 
index f02f0917c299392c1600b9ba68db8a02b79f2884..bba3106191748925ffb57bc83c77b2ee7878ff3c 100644 (file)
@@ -11,6 +11,7 @@
 #include <QProgressDialog>
 #include <QSpinBox>
 #include <QToolBar>
+#include <QProcess>
 
 #include "qui/MussaAlignedWindow.hpp"
 #include "qui/motif_editor/MotifEditor.hpp"
@@ -142,7 +143,8 @@ protected:
   QAction *whatsThisAction;
   QAction *viewMussaAlignmentAction;
 
-  QAssistantClient *manualAssistant;
+  //QAssistantClient *manualAssistant;
+  QProcess *assistantProcess;
 
   //! initialze the actions
   void setupActions();