ccOverlayDialog.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. #pragma once
  2. //##########################################################################
  3. //# #
  4. //# CLOUDCOMPARE #
  5. //# #
  6. //# This program is free software; you can redistribute it and/or modify #
  7. //# it under the terms of the GNU General Public License as published by #
  8. //# the Free Software Foundation; version 2 or later of the License. #
  9. //# #
  10. //# This program is distributed in the hope that it will be useful, #
  11. //# but WITHOUT ANY WARRANTY; without even the implied warranty of #
  12. //# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the #
  13. //# GNU General Public License for more details. #
  14. //# #
  15. //# COPYRIGHT: EDF R&D / TELECOM ParisTech (ENST-TSI) #
  16. //# #
  17. //##########################################################################
  18. #include "CCPluginAPI.h"
  19. //Qt
  20. #include <QDialog>
  21. #include <QList>
  22. class ccGLWindowInterface;
  23. //! Generic overlay dialog interface
  24. class CCPLUGIN_LIB_API ccOverlayDialog : public QDialog
  25. {
  26. Q_OBJECT
  27. public:
  28. //! Default constructor
  29. explicit ccOverlayDialog(QWidget* parent = nullptr, Qt::WindowFlags flags = Qt::FramelessWindowHint | Qt::Tool);
  30. //! Destructor
  31. ~ccOverlayDialog() override;
  32. //! Links the overlay dialog with a MDI window
  33. /** Warning: link can't be modified while dialog is displayed/process is running!
  34. \return success
  35. **/
  36. virtual bool linkWith(ccGLWindowInterface* win);
  37. //! Starts process
  38. /** \return success
  39. **/
  40. virtual bool start();
  41. //! Stops process/dialog
  42. /** Automatically emits the 'processFinished' signal (with input state as argument).
  43. \param accepted process/dialog result
  44. **/
  45. virtual void stop(bool accepted);
  46. //reimplemented from QDialog
  47. void reject() override;
  48. //! Adds a keyboard shortcut (single key) that will be overridden from the associated window
  49. /** When an overridden key is pressed, the shortcutTriggered(int) signal is emitted.
  50. **/
  51. void addOverriddenShortcut(Qt::Key key);
  52. //! Returns whether the tool is currently started or not
  53. bool started() const { return m_processing; }
  54. Q_SIGNALS:
  55. //! Signal emitted when process is finished
  56. /** \param accepted specifies how the process finished (accepted or not)
  57. **/
  58. void processFinished(bool accepted);
  59. //! Signal emitted when an overridden key shortcut is pressed
  60. /** See ccOverlayDialog::addOverriddenShortcut
  61. **/
  62. void shortcutTriggered(int key);
  63. //! Signal emitted when a 'show' event is detected
  64. void shown();
  65. protected:
  66. //! Slot called when the linked window is deleted (calls 'onClose')
  67. virtual void onLinkedWindowDeletion(ccGLWindowInterface* object = nullptr);
  68. protected:
  69. //inherited from QObject
  70. bool eventFilter(QObject *obj, QEvent *e) override;
  71. //! Associated (MDI) window
  72. ccGLWindowInterface* m_associatedWin;
  73. //! Running/processing state
  74. bool m_processing;
  75. //! Overridden keys
  76. QList<int> m_overriddenKeys;
  77. };