From e216a2853d55398c68294f889615d125920676cf Mon Sep 17 00:00:00 2001 From: Brandon King Date: Mon, 16 Nov 2009 18:37:49 -0800 Subject: [PATCH] Updated the QAssistant launching code for Qt 4.5 (At least on windows; needs testing on other platforms). --- qui/MussaWindow.cpp | 41 ++++++++++++++++++++++++++++++----------- qui/MussaWindow.hpp | 4 +++- 2 files changed, 33 insertions(+), 12 deletions(-) diff --git a/qui/MussaWindow.cpp b/qui/MussaWindow.cpp index b0342e4..f302f8e 100644 --- a/qui/MussaWindow.cpp +++ b/qui/MussaWindow.cpp @@ -11,12 +11,15 @@ #include #include #include +#include #include #include +#include #include #include #include #include +#include #include #include @@ -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 } diff --git a/qui/MussaWindow.hpp b/qui/MussaWindow.hpp index f02f091..bba3106 100644 --- a/qui/MussaWindow.hpp +++ b/qui/MussaWindow.hpp @@ -11,6 +11,7 @@ #include #include #include +#include #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(); -- 2.30.2