Engauge Digitizer
2
Toggle main menu visibility
Loading...
Searching...
No Matches
Help
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
19
const
int
MIN_WIDTH
= 600;
20
const
int
MIN_HEIGHT
= 600;
21
22
HelpWindow::HelpWindow
(QWidget *parent) :
23
QDockWidget (parent)
24
{
25
setMinimumWidth (
MIN_WIDTH
);
26
setMinimumHeight (
MIN_HEIGHT
);
27
28
#if !defined(OSX_DEBUG) && !defined(OSX_RELEASE)
29
QHelpEngine *helpEngine =
new
QHelpEngine (helpPath());
30
helpEngine->setupData();
31
32
QTabWidget *tabs =
new
QTabWidget;
33
tabs->addTab (helpEngine->contentWidget(),
34
tr (
"Contents"
));
35
tabs->addTab (helpEngine->indexWidget(),
36
tr (
"Index"
));
37
38
HelpBrowser
*browser =
new
HelpBrowser
(helpEngine);
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)));
47
connect (helpEngine->indexWidget (), SIGNAL (linkActivated (QUrl, QString)), browser, SLOT (setSource (QUrl)));
48
49
QSplitter *splitter =
new
QSplitter (Qt::Horizontal);
50
splitter->insertWidget (0, tabs);
51
splitter->insertWidget (1, browser);
52
53
setWidget (splitter);
54
#endif
55
}
56
57
#if !defined(OSX_DEBUG) && !defined(OSX_RELEASE)
58
QString 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
63
QStringList paths;
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
80
QString pathAsIs = *itr;
81
82
QFileInfo fileAsIs (pathAsIs);
83
if
(fileAsIs.exists()) {
84
return
pathAsIs;
85
}
86
87
QString pathWithPrefix = QApplication::applicationDirPath() + pathAsIs;
88
89
QFileInfo fileWithPrefix (pathWithPrefix);
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
HelpBrowser.h
MIN_HEIGHT
const int MIN_HEIGHT
Definition
HelpWindow.cpp:20
MIN_WIDTH
const int MIN_WIDTH
Definition
HelpWindow.cpp:19
HelpWindow.h
Logger.h
HelpBrowser
Text browser with resource loading enhanced for use as help text browser.
Definition
HelpBrowser.h:16
HelpWindow::HelpWindow
HelpWindow(QWidget *parent)
Single constructor.
Definition
HelpWindow.cpp:22
Generated on
for Engauge Digitizer by
1.17.0