ctkToolTipTrapper.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. /*=========================================================================
  2. Library: CTK
  3. Copyright (c) Kitware Inc.
  4. Licensed under the Apache License, Version 2.0 (the "License");
  5. you may not use this file except in compliance with the License.
  6. You may obtain a copy of the License at
  7. http://www.apache.org/licenses/LICENSE-2.0.txt
  8. Unless required by applicable law or agreed to in writing, software
  9. distributed under the License is distributed on an "AS IS" BASIS,
  10. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  11. See the License for the specific language governing permissions and
  12. limitations under the License.
  13. =========================================================================*/
  14. /*=========================================================================
  15. Program: ParaView
  16. Module: pqToolTipTrapper.h
  17. Copyright (c) 2005-2008 Sandia Corporation, Kitware Inc.
  18. All rights reserved.
  19. ParaView is a free software; you can redistribute it and/or modify it
  20. under the terms of the ParaView license version 1.2.
  21. See http://www.paraview.org/paraview/project/license.html for the full ParaView license.
  22. A copy of this license can be obtained by contacting
  23. Kitware Inc.
  24. 28 Corporate Drive
  25. Clifton Park, NY 12065
  26. USA
  27. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  28. ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  29. LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  30. A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR
  31. CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
  32. EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  33. PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
  34. PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
  35. LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
  36. NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  37. SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  38. =========================================================================*/
  39. #ifndef __ctkToolTipTrapper_h
  40. #define __ctkToolTipTrapper_h
  41. // Qt includes
  42. #include <QObject>
  43. // CTK includes
  44. #include "ctkWidgetsExport.h"
  45. class ctkToolTipTrapperPrivate;
  46. /// To prevent tooltips from appearing, create an instance of this object.
  47. class CTK_WIDGETS_EXPORT ctkToolTipTrapper : public QObject
  48. {
  49. Q_OBJECT
  50. Q_PROPERTY( bool enabled READ isEnabled WRITE setEnabled)
  51. public:
  52. typedef QObject Superclass;
  53. /// Constructs a ToolTip trapper which is a child of objectParent
  54. /// The trapper is enabled by default
  55. explicit ctkToolTipTrapper(QObject* objectParent = 0);
  56. /// Constructs a ToolTip trapper which is a child of objectParent
  57. /// If enable is false, the trapper doesn't install the event filter
  58. explicit ctkToolTipTrapper(bool enable, QObject* objectParent = 0);
  59. virtual ~ctkToolTipTrapper();
  60. /// Returns true if the eventFilter is installed and ToolTip events are
  61. /// filtered
  62. bool isEnabled()const;
  63. /// Automatically called when the tooltip is enabled. It prevents the
  64. /// tooltips events from being processed. You shouldn't have to call
  65. /// it manually.
  66. bool eventFilter(QObject* watched, QEvent* event);
  67. public slots:
  68. /// If true, it installs the eventFilter on the application. Otherwise
  69. /// it removes it.
  70. void setEnabled(bool enable);
  71. protected:
  72. QScopedPointer<ctkToolTipTrapperPrivate> d_ptr;
  73. private:
  74. Q_DECLARE_PRIVATE(ctkToolTipTrapper);
  75. Q_DISABLE_COPY(ctkToolTipTrapper);
  76. };
  77. #endif