floatingwidgettitlebar.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /****************************************************************************
  2. **
  3. ** Copyright (C) 2020 Uwe Kindler
  4. ** Contact: https://www.qt.io/licensing/
  5. **
  6. ** This file is part of Qt Creator.
  7. **
  8. ** Commercial License Usage
  9. ** Licensees holding valid commercial Qt licenses may use this file in
  10. ** accordance with the commercial license agreement provided with the
  11. ** Software or, alternatively, in accordance with the terms contained in
  12. ** a written agreement between you and The Qt Company. For licensing terms
  13. ** and conditions see https://www.qt.io/terms-conditions. For further
  14. ** information use the contact form at https://www.qt.io/contact-us.
  15. **
  16. ** GNU General Public License Usage
  17. ** Alternatively, this file may be used under the terms of the GNU
  18. ** General Public License version 3 as published by the Free Software
  19. ** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
  20. ** included in the packaging of this file. Please review the following
  21. ** information to ensure the GNU General Public License requirements will
  22. ** be met: https://www.gnu.org/licenses/gpl-3.0.html.
  23. **
  24. ****************************************************************************/
  25. #pragma once
  26. #include <QWidget>
  27. namespace ADS {
  28. class FloatingDockContainer;
  29. struct FloatingWidgetTitleBarPrivate;
  30. /**
  31. * Titlebar for floating widgets to capture non client are mouse events.
  32. * Linux does not support NonClieantArea mouse events like
  33. * QEvent::NonClientAreaMouseButtonPress. Because these events are required
  34. * for the docking system to work properly, we use our own titlebar here to
  35. * capture the required mouse events.
  36. */
  37. class FloatingWidgetTitleBar : public QWidget
  38. {
  39. Q_OBJECT
  40. private:
  41. FloatingWidgetTitleBarPrivate *d; ///< private data (pimpl)
  42. protected:
  43. virtual void mousePressEvent(QMouseEvent *event) override;
  44. virtual void mouseReleaseEvent(QMouseEvent *event) override;
  45. virtual void mouseMoveEvent(QMouseEvent *event) override;
  46. public:
  47. using Super = QWidget;
  48. explicit FloatingWidgetTitleBar(FloatingDockContainer *parent = nullptr);
  49. /**
  50. * Virtual Destructor
  51. */
  52. virtual ~FloatingWidgetTitleBar() override;
  53. /**
  54. * Enables / disables the window close button.
  55. */
  56. void enableCloseButton(bool enable);
  57. /**
  58. * Sets the window title, that means, the text of the internal tile label.
  59. */
  60. void setTitle(const QString &text);
  61. signals:
  62. /**
  63. * This signal is emitted, if the close button is clicked.
  64. */
  65. void closeRequested();
  66. };
  67. } // namespace ADS