WhatsThisGenerator.hh 4.71 KB
Newer Older
Matthias Möller's avatar
Matthias Möller committed
1 2 3
/*===========================================================================*\
*                                                                            *
 *                              OpenFlipper                                   *
Jan Möbius's avatar
Jan Möbius committed
4
 *      Copyright (C) 2001-2014 by Computer Graphics Group, RWTH Aachen       *
Matthias Möller's avatar
Matthias Möller committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
 *                           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>
49
#include <OpenFlipper/common/GlobalDefines.hh>
Matthias Möller's avatar
Matthias Möller committed
50 51 52

/** \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:
53
 *	 \code{.cpp}action->setWhatsThis("Hello");\endcode
Matthias Möller's avatar
Matthias Möller committed
54 55 56 57
 *	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
58
 *		\code{.cpp}action->setWhatsThis(QString(tr("Hello"))+whatsThisGen.generateLink()); \endcode
Matthias Möller's avatar
Matthias Möller committed
59 60 61 62 63
 *	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:
64
 *		\code{.cpp}whatsThisGen.setWHatsThis(action,tr("Hello"));\endcode
Matthias Möller's avatar
Matthias Möller committed
65 66
 *	It has the same effect and options like the code above and is shorter.
 */
67 68 69 70 71
class DLLEXPORT WhatsThisGenerator: public QObject {

  Q_OBJECT

  const QString plugin_name_;
Matthias Möller's avatar
Matthias Möller committed
72 73

public:
74
  WhatsThisGenerator(const QString &_plugin_name);
Matthias Möller's avatar
Matthias Möller committed
75

76
  QString generateLink(const QString &_ref = "", const QString &_site = "index.html") const;
Matthias Möller's avatar
Matthias Möller committed
77

78 79 80 81 82
  void setWhatsThis(
      QAction* _action,
      const QString &_msg,
      const QString &_ref = "",
      const QString &_site = "index.html") const;
Matthias Möller's avatar
Matthias Möller committed
83 84 85 86 87

};


#endif /* WHATSTHISGENERATOR_HH_ */