WhatsThisGenerator.cc 2.91 KB
Newer Older
Matthias Möller's avatar
Matthias Möller committed
1 2
#include "WhatsThisGenerator.hh"

3 4
/** Constructor for the whatsThisGenerator initializing the plugin name.
 *
5 6
 * @param _plugin_name the name of the plugin which is used \note use only the name and NOT the prefix Plugin- (e.g. SkeletonEditing for Plugin-SkeletonEditing).
 *  If you want to reference in the core user plugin, then _plugin = "user"
Matthias Möller's avatar
Matthias Möller committed
7
 */
8
WhatsThisGenerator::WhatsThisGenerator(const QString &_plugin_name) :
9
plugin_name_((_plugin_name != "user") ? QString("Plugin-")+_plugin_name : _plugin_name)
Matthias Möller's avatar
Matthias Möller committed
10 11 12 13
{
}


14
/**	\brief generates a clickable link to the documentation for whatsThis Messages
Matthias Möller's avatar
Matthias Möller committed
15
 * @param _ref gives the section in the documentation for the action. The help-browser will jump into the section.
Matthias Möller's avatar
Matthias Möller committed
16 17
 *                      An example: _jump = "Cube" in PrimitiveGenerator refs to the section "Cube" in the Documentation and the help Browser.
 *                      \note use the doxygen reference name (always one word), not the section name
Matthias Möller's avatar
Matthias Möller committed
18 19
 *
 * @param _site gives the documentation site (html-site) which you want to open.
Matthias Möller's avatar
Matthias Möller committed
20 21
 *                      Default is the site "index.html".
 *                      You need this parameter if you have more than one site in your plugin documentation and want to refer on one of this.
Matthias Möller's avatar
Matthias Möller committed
22
 */
23
QString WhatsThisGenerator::generateLink(const QString &_ref /*= ""*/, const QString &_site /*= "index.html"*/) const
Matthias Möller's avatar
Matthias Möller committed
24
{
25
  const QString baseHelpURL = QString(" <a href='qthelp://org.openflipper.")
Matthias Möller's avatar
Matthias Möller committed
26
                                         + plugin_name_.toLower()
27
                                         + QString("/")
Matthias Möller's avatar
Matthias Möller committed
28 29
                                         + plugin_name_+QString("/")
                                         + _site+QString("#")+_ref + QString("'>");
Matthias Möller's avatar
Matthias Möller committed
30

Matthias Möller's avatar
Matthias Möller committed
31 32
  const QString clickText = QString(QObject::tr("Click for more information"))+QObject::tr("</a>");
  return (baseHelpURL + clickText);
Matthias Möller's avatar
Matthias Möller committed
33 34
}

35
/**	\brief sets a whatsThis Message plus link to the doc for the given QAction
Matthias Möller's avatar
Matthias Möller committed
36 37 38 39
 * @param _action action where the message should appear.
 * @param _msg help message for the user. This is the default Whatsthis Text which you set with QAction::setWhatsThis
 *
 * @param _ref gives the section in the documentation for the action. The help-browser will jump into the section.
Matthias Möller's avatar
Matthias Möller committed
40 41
 *                      An example: _jump = "Cube" in PrimitiveGenerator refs to the section "Cube" in the Documentation and the help Browser.
 *                      \note use the doxygen reference name (always one word), not the section name
Matthias Möller's avatar
Matthias Möller committed
42 43
 *
 * @param _site gives the documentation site (html-site) which you want to open.
Matthias Möller's avatar
Matthias Möller committed
44 45
 * 	                    Default is the site "index.html".
 * 	                    You need this parameter if you have more than one site in your plugin documentation and want to refer on one of this.
Matthias Möller's avatar
Matthias Möller committed
46 47 48
 */
void WhatsThisGenerator::setWhatsThis(QAction* _action, const QString &_msg, const QString &_ref /*= ""*/,const QString &_site /*= "index.html"*/) const
{
49
  _action->setWhatsThis(_msg + generateLink(_ref, _site));
Matthias Möller's avatar
Matthias Möller committed
50
}