Commit 28d13fea authored by hkrishna's avatar hkrishna
Browse files

updating help to use internal help

git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@21898 18c085ea-50e0-402c-830e-de6fd14e8384
parent fc6f23ee
......@@ -69,6 +69,7 @@ bool GUIBase::writeToConsole = true;
bool GUIBase::autoUpdate = false;
bool GUIBase::makeDefaultConfirm = true;
FileServerList *GUIBase::fileServer = 0;
QvisHelpWindow* GUIBase::helpWindow = NULL;
// ****************************************************************************
// Method: GUIBase::GUIBase
......@@ -1646,3 +1647,31 @@ GUIBase::GetPlotDescription(const QString &plotName) const
return retval;
}
// ****************************************************************************
// Method: QvisWindowBase::RegisterHelpWindow & GetHelpWindow
//
// Purpose:
// Helper function to allow widgets to interface with the Existing Help Window
//
// Arguments:
//
//
// Programmer:
// Creation: Sept 19, 2013
//
// Modifications:
//
// ****************************************************************************
void
GUIBase::RegisterHelpWindow(QvisHelpWindow* help)
{
helpWindow = help;
}
QvisHelpWindow*
GUIBase::GetHelpWindow()
{
return helpWindow;
}
......@@ -53,6 +53,7 @@ class ViewerState;
struct StatusSubject;
struct QualifiedFilename;
class SimpleObserver;
class QvisHelpWindow;
// ****************************************************************************
// Class: GUIBase
......@@ -182,6 +183,9 @@ protected:
int dbState) const;
QString GetPlotDescription(const QString &plotName) const;
static void RegisterHelpWindow(QvisHelpWindow* help);
static QvisHelpWindow* GetHelpWindow();
private:
static ViewerProxy *viewer;
protected:
......@@ -191,6 +195,7 @@ protected:
static bool makeDefaultConfirm;
static MessageAttributes *msgAttr;
static FileServerList *fileServer;
static QvisHelpWindow* helpWindow;
};
#endif
......@@ -1809,6 +1809,9 @@ QvisGUIApplication::FinalInitialization()
visitTimer->StopTimer(completeInit, "VisIt to be ready");
moreInit = false;
emit VisItIsReady();
///initialize the help window since every widget will now have access to it.
RegisterHelpWindow(dynamic_cast<QvisHelpWindow*>(GetInitializedWindowPointer(WINDOW_HELP)));
}
//
......
......@@ -1075,6 +1075,57 @@ QvisHelpWindow::openHelp(QTreeWidgetItem *item)
}
}
// ****************************************************************************
// Method: QvisHelpWindow::openHelp
//
// Purpose:
// This is a Qt slot function that is called when an item in the contents
// listview is clicked. We display the page associated with the item.
//
// Arguments:
// item : The item that was clicked.
//
// Programmer: Brad Whitlock
// Creation: Fri Jul 12 13:03:00 PST 2002
//
// Modifications:
// Brad Whitlock, Thu Jun 19 16:27:10 PDT 2008
// Qt 4.
//
// ****************************************************************************
void
QvisHelpWindow::openHelp(const QString& entry)
{
if(!isCreated) {
CreateEntireWindow();
}
show();
helpContents->clearSelection();
/// find closest match in help index..
QModelIndexList list = helpContents->model()->match(helpContents->model()->index(0,0), Qt::DisplayRole,
entry, -1, Qt::MatchStartsWith | Qt::MatchRecursive);
if(list.size() == 0)
displayTitle(entry + " help not found...");
else {
helpContents->expand(list.back());
helpContents->scrollTo(list.back());
helpContents->setCurrentIndex(list.back());
QString document(list.back().data(Qt::UserRole).toString());
if(!document.isEmpty())
displayPage(document);
else
displayTitle(entry + " help not found...");
}
}
// ****************************************************************************
// Method: QvisHelpWindow::topicExpanded
//
......
......@@ -108,6 +108,7 @@ public slots:
void displayReleaseNotes();
void displayReleaseNotesIfAvailable();
void displayContributors();
void openHelp(const QString& entry);
virtual void show();
private slots:
void activeTabChanged(int);
......
......@@ -46,6 +46,7 @@
#include <QvisPostableWindow.h>
#include <QvisNotepadArea.h>
#include <DataNode.h>
#include <QvisHelpWindow.h>
//
// Static members.
......@@ -109,26 +110,6 @@ QvisPostableWindow::QvisPostableWindow(const QString &captionString,
notepad = n;
addLayoutStretch = true;
helpWindow = new QDockWidget();
helpWindow->setBaseSize(400,400);
QWidget* centralwidget = new QWidget(helpWindow);
QVBoxLayout* verticalLayout = new QVBoxLayout(centralwidget);
helpText = new QTextEdit(centralwidget);
helpText->setBaseSize(400,800);
verticalLayout->addWidget(helpText);
helpWindow->setWidget(centralwidget);
addDockWidget(Qt::RightDockWidgetArea, helpWindow);
helpWindow->hide();
}
void
QvisPostableWindow::hideEvent(QHideEvent *)
{
helpWindow->hide();
}
// ****************************************************************************
......@@ -613,47 +594,16 @@ QvisPostableWindow::unpost()
// Modifications:
//
// ****************************************************************************
#include <QNetworkRequest>
#include <QNetworkReply>
void
QvisPostableWindow::help()
{
if(helpWindow->isVisible())
return;
if(helpText->document()->toPlainText().length() > 0){
helpWindow->show();
helpWindow->setFloating(true);
helpWindow->resize(600,600);
return;
}
helpWindow->setWindowTitle(windowTitle() + " Help");
helpText->clear();
if(!GetHelpWindow()) return;
QString window = windowTitle();
window.replace(" ", "_");
window = window.remove("attributes");
QString prefix = QString("http://visitusers.org/index.php?title=%1").arg(window);
QUrl url(prefix);
QNetworkRequest request(url);
QNetworkAccessManager* manager = new QNetworkAccessManager();
connect(manager, SIGNAL(finished(QNetworkReply*)),
this, SLOT(downloadHelp(QNetworkReply*)));
manager->get(request);
helpWindow->show();
helpWindow->setFloating(true);
helpWindow->resize(600,600);
}
void
QvisPostableWindow::downloadHelp(QNetworkReply *reply){
QString out(reply->readAll());
helpText->append(out);
GetHelpWindow()->openHelp(window.trimmed());
}
// ****************************************************************************
......@@ -698,7 +648,6 @@ QvisPostableWindow::hide()
else
QvisWindowBase::hide();
helpWindow->hide();
isPosted = false;
}
......@@ -843,14 +792,14 @@ QvisPostableWindow::CreateEntireWindow()
QHBoxLayout *buttonLayout = new QHBoxLayout(0);
vLayout->addLayout(buttonLayout);
buttonLayout->addStretch();
helpButton = new QPushButton(this);
helpButton->setText(tr("?"));
connect(helpButton, SIGNAL(clicked()), this, SLOT(help()));
buttonLayout->addWidget(helpButton);
postButton = new QPushButton(tr("Post"));
buttonLayout->addWidget(postButton);
dismissButton = new QPushButton(tr("Dismiss"));
buttonLayout->addWidget(dismissButton);
helpButton = new QToolButton(this);
helpButton->setText(tr("?"));
connect(helpButton, SIGNAL(clicked()), this, SLOT(help()));
buttonLayout->addWidget(helpButton);
if(notepad != 0 && addLayoutStretch)
vLayout->addStretch(0);
......
......@@ -48,7 +48,7 @@ class QPushButton;
class QToolButton;
class QVBoxLayout;
class QTextEdit;
class QNetworkReply;
class QvisHelpWindow;
// ****************************************************************************
// Class: QvisPostableWindow
......@@ -117,7 +117,6 @@ public:
void SetAddStretch(bool);
protected:
virtual void UpdateWindow(bool doAll);
virtual void hideEvent(QHideEvent *);
public slots:
virtual void raise();
virtual void show();
......@@ -125,7 +124,6 @@ public slots:
virtual void post(bool avoid_scroll=false);
virtual void unpost();
virtual void help();
void downloadHelp(QNetworkReply*reply);
protected:
bool isCreated;
bool isPosted;
......@@ -135,10 +133,8 @@ protected:
QVBoxLayout *topLayout;
QPushButton *postButton;
QPushButton *dismissButton;
QToolButton *helpButton;
QPushButton *helpButton;
QvisNotepadArea *notepad;
QTextEdit *helpText;
QDockWidget *helpWindow;
static bool postWhenShown;
static bool postEnabled;
......
......@@ -277,7 +277,7 @@ QvisPostableWindowSimpleObserver::CreateEntireWindow()
{
QPushButton *resetButton = new QPushButton(tr("Reset"), topCentral);
connect(resetButton, SIGNAL(clicked()), this, SLOT(reset()));
buttonLayout->addWidget(resetButton, 0, 4, 1, 2);
buttonLayout->addWidget(resetButton, 0, 4);
}
if(buttonCombination & LoadButton)
......@@ -306,6 +306,10 @@ QvisPostableWindowSimpleObserver::CreateEntireWindow()
// grid layout.
buttonLayout->setColumnStretch(1, 50);
}
QPushButton *helpButton = new QPushButton(topCentral);
helpButton->setText(tr("?"));
connect(helpButton, SIGNAL(clicked()), this, SLOT(help()));
buttonLayout->addWidget(helpButton, 1, 2);
postButton = new QPushButton(tr("Post"), topCentral);
// Make the window post itself when the post button is clicked.
......@@ -321,10 +325,6 @@ QvisPostableWindowSimpleObserver::CreateEntireWindow()
connect(dismissButton, SIGNAL(clicked()), this, SLOT(hide()));
buttonLayout->addWidget(dismissButton, 1, 4);
QToolButton *helpButton = new QToolButton(topCentral);
helpButton->setText(tr("?"));
connect(helpButton, SIGNAL(clicked()), this, SLOT(help()));
buttonLayout->addWidget(helpButton, 1, 5);
if(notepad != 0 && stretchWindow)
vLayout->addStretch(0);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment