Commit 3078e77e authored by Matthias Möller's avatar Matthias Möller

add whatsThisGenerator.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@14057 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 7f666633
......@@ -46,6 +46,7 @@
#include <QtGui>
#include <QMenuBar>
#include <OpenFlipper/common/Types.hh>
#include "WhatsThisGenerator.hh"
/** \file BaseInterface.hh
......
#include "WhatsThisGenerator.hh"
/*
* @_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)
*/
WhatsThisGenerator::WhatsThisGenerator(const QString &_plugin_name)
:plugin_name_(_plugin_name)
{
}
/* \brief generates a clickable link to the documentation for whatsThis Messages
* @param _ref gives the section in the documentation for the action. The help-browser will jump into the section.
* An example: _jump = "cube" in PrimitiveGenerator refs to the section "cube" in the Documentation and the help Browser.
*
* @param _site gives the documentation site (html-site) which you want to open.
* 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.
*/
QString WhatsThisGenerator::generateLink(const QString &_ref /*= ""*/,const QString &_site /*= "index.html"*/) const
{
const QString baseHelpURL = QString(" <a href='qthelp://org.openflipper.plugin-")
+plugin_name_.toLower()
+QString("/Plugin-")
+plugin_name_+QString("/")
+_site+QString("#")+_ref + QString("'>");
const QString clickText = QString(QObject::tr("Click for more information"))+QObject::tr("</a>");
return (baseHelpURL + clickText);
}
/* \brief sets a whatsThis Message plus link to the doc for the given QAction
* @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.
* An example: _jump = "cube" in PrimitiveGenerator refs to the section "cube" in the Documentation and the help Browser.
*
* @param _site gives the documentation site (html-site) which you want to open.
* 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.
*/
void WhatsThisGenerator::setWhatsThis(QAction* _action, const QString &_msg, const QString &_ref /*= ""*/,const QString &_site /*= "index.html"*/) const
{
_action->setWhatsThis(_msg+generateLink(_ref,_site));
}
/*===========================================================================*\
* *
* OpenFlipper *
* Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen *
* www.openflipper.org *
* *
*--------------------------------------------------------------------------- *
* This file is part of OpenFlipper. *
* *
* OpenFlipper is free software: you can redistribute it and/or modify *
* it under the terms of the GNU Lesser General Public License as *
* published by the Free Software Foundation, either version 3 of *
* the License, or (at your option) any later version with the *
* following exceptions: *
* *
* If other files instantiate templates or use macros *
* or inline functions from this file, or you compile this file and *
* link it with other files to produce an executable, this file does *
* not by itself cause the resulting executable to be covered by the *
* GNU Lesser General Public License. This exception does not however *
* invalidate any other reasons why the executable file might be *
* covered by the GNU Lesser General Public License. *
* *
* OpenFlipper is distributed in the hope that it will be useful, *
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
* GNU Lesser General Public License for more details. *
* *
* You should have received a copy of the GNU LesserGeneral Public *
* License along with OpenFlipper. If not, *
* see <http://www.gnu.org/licenses/>. *
* *
\*===========================================================================*/
/*===========================================================================*\
* *
* $Revision$ *
* $LastChangedBy$ *
* $Date$ *
* *
\*===========================================================================*/
#ifndef WHATSTHISGENERATOR_HH_
#define WHATSTHISGENERATOR_HH_
#include <QAction>
#include <QString>
#include <QObject>
/** \brief a class which provides an link generator for WhatsThisMessages linking to the user doc
* If you have an QAction pointer called action, you can call:
* \code{.cpp}action->setWhatsThis("Hello");\encode
* This message "Hello" will be shown when somebody call this action in WhatsThisMode.
*
* WhatsThisGenerator provides functions linking to the user documentation.
* e.g. assume that whatsThisGen is a valid WhatsThisGenerator object
* \code{.cpp}action->setWhatsThis(QString(tr("Hello"))+whatsThisGen.generateLink()); \encode
* The code above will change the output for WhatsThisMessages to: "Hello Click here for more information"
* where "Click here for more information" is a link which will call the index.html (default parameter) of the plugin
* which you have to specify in the constructor of WhatsThisGenerator.
*
* You can also use the WhatsThisGenerator to set the WhatsThisMessage:
* \code{.cpp}whatsThisGen.setWHatsThis(action,tr("Hello"));\encode
* It has the same effect and options like the code above and is shorter.
*/
class WhatsThisGenerator : public QObject
{
Q_OBJECT;
const QString plugin_name_;
public:
WhatsThisGenerator(const QString &_plugin_name);
QString generateLink(const QString &_ref = "",const QString &_site = "index.html") const;
void setWhatsThis(QAction* _action, const QString &_msg, const QString &_ref = "",const QString &_site = "index.html") const;
};
#endif /* WHATSTHISGENERATOR_HH_ */
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