Engauge Digitizer 2
Loading...
Searching...
No Matches
HelpWindow.cpp
Go to the documentation of this file.
1/******************************************************************************************************
2 * (C) 2014 markummitchell@github.com. This file is part of Engauge Digitizer, which is released *
3 * under GNU General Public License version 2 (GPLv2) or (at your option) any later version. See file *
4 * LICENSE or go to gnu.org/licenses for details. Distribution requires prior written permission. *
5 ******************************************************************************************************/
6
7#include "HelpBrowser.h"
8#include "HelpWindow.h"
9#include "Logger.h"
10#include <QApplication>
11#include <QDir>
12#include <QFileInfo>
13#include <QHelpContentWidget>
14#include <QHelpEngine>
15#include <QHelpIndexWidget>
16#include <QSplitter>
17#include <QTabWidget>
18
19const int MIN_WIDTH = 600;
20const int MIN_HEIGHT = 600;
21
23 QDockWidget (parent)
24{
27
28#if !defined(OSX_DEBUG) && !defined(OSX_RELEASE)
29 QHelpEngine *helpEngine = new QHelpEngine (helpPath());
30 helpEngine->setupData();
31
33 tabs->addTab (helpEngine->contentWidget(),
34 tr ("Contents"));
35 tabs->addTab (helpEngine->indexWidget(),
36 tr ("Index"));
37
39
40 // URL is constructed from <namespace>, <virtualFolder> and <file> in engauge.qhp. If this line shows
41 // the error message 'QTextBrowser: No document for qthelp...' then one of the following applies:
42 // (1) the qhc file has not been built and put into the bin/documentation folder
43 // (2) in qtcreator the build is getting put into some directory other than engauge-digitizer/bin
44 browser->setSource (QUrl ("qthelp://engaugedigitizer.net/doc/index.html"));
45
46 connect (helpEngine->contentWidget (), SIGNAL (linkActivated (QUrl)), browser, SLOT (setSource (QUrl)));
48
49 QSplitter *splitter = new QSplitter (Qt::Horizontal);
50 splitter->insertWidget (0, tabs);
51 splitter->insertWidget (1, browser);
52
54#endif
55}
56
57#if !defined(OSX_DEBUG) && !defined(OSX_RELEASE)
58QString HelpWindow::helpPath() const
59{
60 // Possible locations of help file. Each entry is first tried as is, and then with
61 // applicationDirPath as a prefix. Each entry should probably start with a slash. This
62 // search approach offers some flexibility in the help file location
64#ifdef HELPDIR
65#define QUOTE(string) _QUOTE(string)
66#define _QUOTE(string) #string
67 QString path = QString ("%1/engauge.qhc")
68 .arg (QUOTE (HELPDIR));
69 paths << path;
70#endif
71 paths << "/documentation/engauge.qhc";
72 paths << "/../share/doc/engauge-digitizer/engauge.qhc";
73 paths << "/../documentation/engauge.qhc"; // snap
74 paths << "/usr/share/engauge-digitizer-doc/engauge.qhc";
75 paths << "/usr/share/doc/engauge-digitizer/engauge.qhc"; // cygwin
76
77 QStringList::iterator itr;
78 for (itr = paths.begin(); itr != paths.end(); itr++) {
79
81
83 if (fileAsIs.exists()) {
84 return pathAsIs;
85 }
86
87 QString pathWithPrefix = QApplication::applicationDirPath() + pathAsIs;
88
90 if (fileWithPrefix.exists()) {
91 return pathWithPrefix;
92 }
93 }
94
95 return ""; // Empty file, since help file was never found, will simply result in empty help contents
96}
97#endif
const int INNER_RADIUS_MIN
const int MIN_HEIGHT
const int MIN_WIDTH
Text browser with resource loading enhanced for use as help text browser.
Definition HelpBrowser.h:16
HelpWindow(QWidget *parent)
Single constructor.