Isis 3 Programmer Reference
HelpTool.cpp
1 #include "HelpTool.h"
2 
3 #include <QAction>
4 #include <QApplication>
5 #include <QMenu>
6 #include <QString>
7 #include <QToolBar>
8 #include <QWhatsThis>
9 
10 #include "IException.h"
11 #include "MainWindow.h"
12 #include "Workspace.h"
13 #include "Preference.h"
14 
15 
16 namespace Isis {
17  // Constructor
18  HelpTool::HelpTool(QWidget *parent) : Tool(parent) {
19  p_whatsThis = new QAction(parent);
20  p_whatsThis->setShortcut(Qt::SHIFT + Qt::Key_F1);
21  p_whatsThis->setText("&What's This?");
22  p_whatsThis->setIcon(QPixmap(toolIconDir() + "/contexthelp.png"));
23  p_whatsThis->setToolTip("What's This");
24  QString whatsThis =
25  "<b>Function:</b> Use this to get longer descriptions of button \
26  functions \
27  <p><b>Shortcut:</b> Shift+F1</p>";
28  p_whatsThis->setWhatsThis(whatsThis);
29  connect(p_whatsThis, SIGNAL(triggered()), this, SLOT(whatsThis()));
30 
31  p_aboutProgram = new QAction(parent);
32  p_aboutProgram->setShortcut(Qt::CTRL + Qt::Key_H);
33  QString s = "About ";
34  s += QApplication::applicationName();
35  p_aboutProgram->setText(s);
36  connect(p_aboutProgram, SIGNAL(triggered()), this, SLOT(aboutProgram()));
37 
38  }
39 
40  // Add actions to the Help menu
41  void HelpTool::addTo(QMenu *menu) {
42  menu->addAction(p_whatsThis);
43  menu->addAction(p_aboutProgram);
44  }
45 
48  perm->addAction(p_whatsThis);
49  }
50 
51  // The user pressed the whatsThis button so do something
52  void HelpTool::whatsThis() {
53  QWhatsThis::enterWhatsThisMode();
54  }
55 
56 
63  FileName file(
64  "$ISISROOT/doc/Application/presentation/PrinterFriendly/" +
65  QApplication::applicationName() + "/" +
66  QApplication::applicationName() + ".html");
67 
68  PvlGroup &uig = Preference::Preferences().findGroup("UserInterface");
69  QString command = (QString) uig["GuiHelpBrowser"] +
70  (QString)" file:" + file.expanded() + " &";
71  if(system(command.toLatin1().data()) != 0) {
72  IString msg = "Failed to execute [" + command + "]";
74  }
75  }
76 }
void addToPermanent(QToolBar *perm)
Add actions to the permanent toolbar.
Definition: HelpTool.cpp:47
File name manipulation and expansion.
Definition: FileName.h:116
void addTo(QMenu *menu)
Definition: HelpTool.cpp:41
This error is for when a programmer made an API call that was illegal.
Definition: IException.h:162
void aboutProgram()
Slot to print program information.
Definition: HelpTool.cpp:62
Contains multiple PvlContainers.
Definition: PvlGroup.h:57
#define _FILEINFO_
Macro for the filename and line number.
Definition: IException.h:40
QString expanded() const
Returns a QString of the full file name including the file path, excluding the attributes.
Definition: FileName.cpp:212
Isis exception class.
Definition: IException.h:107
Adds specific functionality to C++ strings.
Definition: IString.h:181
Namespace for ISIS/Bullet specific routines.
Definition: Apollo.h:31