StatusbarInterface.hh 7.01 KB
Newer Older
1
/*===========================================================================*\
Jan Möbius's avatar
Jan Möbius committed
2 3
*                                                                            *
*                              OpenFlipper                                   *
Martin Schultz's avatar
Martin Schultz committed
4 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
 *           Copyright (c) 2001-2015, RWTH-Aachen University                 *
 *           Department of Computer Graphics and Multimedia                  *
 *                          All rights reserved.                             *
 *                            www.openflipper.org                            *
 *                                                                           *
 *---------------------------------------------------------------------------*
 * This file is part of OpenFlipper.                                         *
 *---------------------------------------------------------------------------*
 *                                                                           *
 * Redistribution and use in source and binary forms, with or without        *
 * modification, are permitted provided that the following conditions        *
 * are met:                                                                  *
 *                                                                           *
 * 1. Redistributions of source code must retain the above copyright notice, *
 *    this list of conditions and the following disclaimer.                  *
 *                                                                           *
 * 2. Redistributions in binary form must reproduce the above copyright      *
 *    notice, this list of conditions and the following disclaimer in the    *
 *    documentation and/or other materials provided with the distribution.   *
 *                                                                           *
 * 3. Neither the name of the copyright holder nor the names of its          *
 *    contributors may be used to endorse or promote products derived from   *
 *    this software without specific prior written permission.               *
 *                                                                           *
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS       *
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED *
 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A           *
 * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER *
 * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,  *
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,       *
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR        *
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    *
 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING      *
 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS        *
 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.              *
Jan Möbius's avatar
Jan Möbius committed
39
*                                                                            *
40 41
\*===========================================================================*/

42
#pragma once
43

Matthias Möller's avatar
Matthias Möller committed
44
#include <OpenFlipper/common/Types.hh>
Matthias Möller's avatar
Matthias Möller committed
45

46
#include <QWidget>
47

48 49 50 51 52 53 54 55 56

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

/** Namespace for Application status enum
 *
 */
57 58
namespace ApplicationStatus {
  
59 60 61 62 63 64 65 66 67 68
  /** \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)
  };
69 70 71 72

}


73 74 75 76 77 78 79
 /** \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.
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96
 */
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
       */
97
      virtual void showStatusMessage(QString _message, int _timeout = 0) {};
98 99
      
      
100 101 102 103
      /** \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.
104
       * 
105
       * @param _status New status
106
       */
107
      void setStatus( ApplicationStatus::applicationStatus _status) {};
108 109 110 111 112 113
      
      /** \brief Removes the current message from the statusBar
       * 
       */
      void clearStatusMessage() {};
      
Dirk Wilden's avatar
Dirk Wilden committed
114 115
      /** \brief Add a widget on the right side of the statusBar
       * 
116 117 118 119
       * 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
120
       */
121
      void addWidgetToStatusbar(QWidget* _widget) {};
Dirk Wilden's avatar
Dirk Wilden committed
122
      
123 124
};

125 126 127 128 129 130 131 132 133 134 135 136 137 138 139

/** \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
140
<li> include StatusbarInterface.hh in your plugins header file
141 142 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
<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

*/



182 183
Q_DECLARE_INTERFACE(StatusbarInterface,"OpenFlipper.StatusbarInterface/1.0")