StatusbarInterface.hh 7.05 KB
Newer Older
1
/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
2 3
*                                                                            *
*                              OpenFlipper                                   *
Jan Möbius's avatar
Jan Möbius committed
4
*      Copyright (C) 2001-2011 by Computer Graphics Group, RWTH Aachen       *
Jan Möbius's avatar
Jan Möbius 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
*                           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/>.                                       *
*                                                                            *
33 34 35
\*===========================================================================*/

/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
36 37 38 39 40
*                                                                            *
*   $Revision$                                                       *
*   $LastChangedBy$                                                *
*   $Date$                     *
*                                                                            *
41
\*===========================================================================*/
42 43 44 45

#ifndef STATUSBARINTERFACE_HH
#define STATUSBARINTERFACE_HH

46 47 48
#include <QtGui>
#include <OpenFlipper/common/Types.hh>
#include <QStatusBar>
49

50 51 52 53 54 55 56 57 58

/** \file StatusbarInterface.hh
*
* Interface for controlling OpenFlippers statusbar .\ref statusbarInterfacePage
*/

/** Namespace for Application status enum
 *
 */
59 60
namespace ApplicationStatus {
  
61 62 63 64 65 66 67 68 69 70
  /** \brief Enum for the statusBar Status Icon
   *
   * This enum is used to controll the small activity icon of OpenFlipper.
   * See \ref statusbarInterfacePage
   */
  enum applicationStatus {
    READY,     //!< Status is ready (green light)
    PROCESSING,//!< Status is processing but system will allow interaction (yellow light)
    BLOCKED    //!< Status is processing and blocked system will not allow interaction (red light)
  };
71 72 73 74

}


75 76 77 78 79 80 81
 /** \brief Control OpenFlippers status bar
 *
 * \ref statusbarInterfacePage "Detailed description"
 * \n
 *
 * This interface can be used to send messages to OpenFlippers statusbar.
 * It is also possible to add your own widget to the bar.
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98
 */
class StatusbarInterface {

   private slots :

   public :

      /// Destructor
     virtual ~StatusbarInterface() {};

    signals :

      /** \brief Show a message in the status bar
       * 
       * You can specify a timeout if the message should be removed after
       * _timeout milliseconds
       */
99
      virtual void showStatusMessage(QString _message, int _timeout = 0) {};
100 101
      
      
102 103 104 105
      /** \brief Sets the status icon of the StatusBar
       *
       * OpenFlipper statusbar contains a small icon in the statusbar which can be used to indicate
       * the current status of the application. The valid values are defined in the enum ApplicationStatus::applicationStatus.
106
       * 
107
       * @param _status New status
108
       */
109
      void setStatus( ApplicationStatus::applicationStatus _status) {};
110 111 112 113 114 115
      
      /** \brief Removes the current message from the statusBar
       * 
       */
      void clearStatusMessage() {};
      
Dirk Wilden's avatar
Dirk Wilden committed
116 117
      /** \brief Add a widget on the right side of the statusBar
       * 
118 119 120 121
       * Use this function if you want to add an additional widget to the statusbar.
       * It will be added on the right side.
       *
       * @param _widget The widget that should be added to the statusbar
Dirk Wilden's avatar
Dirk Wilden committed
122
       */
123
      void addWidgetToStatusbar(QWidget* _widget) {};
Dirk Wilden's avatar
Dirk Wilden committed
124
      
125 126
};

127 128 129 130 131 132 133 134 135 136 137 138 139 140 141

/** \page statusbarInterfacePage Statusbar Interface
\image html StatusbarInterface.png
\n
The StatusbarInterface can be used by plugins to send messages to OpenFlippers
statusbar. The statusbar is located below the GL viewer.

Messages can be controlled via StatusbarInterface::setStatus(),StatusbarInterface::clearStatusMessage()

Additionally it is possible to add small widgets to it ( StatusbarInterface::addWidgetToStatusbar).

A small icon can be controlled to indicate OpenFlippers status via StatusbarInterface::setStatus().

To use the StatusbarInterface:
<ul>
Jan Möbius's avatar
Jan Möbius committed
142
<li> include StatusbarInterface.hh in your plugins header file
143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183
<li> derive your plugin from the class StatusbarInterface
<li> add Q_INTERFACES(StatusbarInterface) to your plugin class
<li> And add the signals or slots you want to use to your plugin class (You don't need to implement all of them)
</ul>

The following code shows a simple example to send a message to the statusbar.
\code
void ExamplePlugin::function()
{
  ...

  // Print the text "Your Status Message" for 4 seconds in the statusBar
  emit showStatusMessage( tr("Your Status Message"), 4000 );

  ...
}
\endcode

The following code shows a simple example to add a widget to the statusbar.
Usually you should implement the BaseInterface::pluginsInitialized() function from BaseInterface.
In this function you can setup your widget for the status bar.
\code
void ExamplePlugin::pluginsInitialized()
{

  // Create the widget
  QWidget* infoBar = new QWidget();

  // Setup buttons or anything else in your widget
  ...

  // Add the new widget to the statusBar
  emit addWidgetToStatusbar(infoBar);

}
\endcode

*/



184 185 186
Q_DECLARE_INTERFACE(StatusbarInterface,"OpenFlipper.StatusbarInterface/1.0")

#endif // STATUSBARINTERFACE_HH