framelessmainwindowlinux.h 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. #ifndef FRAMELESSMAINWINDOWLINUX_H
  2. #define FRAMELESSMAINWINDOWLINUX_H
  3. #include "framelessmainwindow.h"
  4. #include <QRect>
  5. #include <QVector>
  6. namespace vnotex
  7. {
  8. #ifndef Q_OS_WIN
  9. class FramelessMainWindowLinux : public FramelessMainWindow
  10. {
  11. Q_OBJECT
  12. public:
  13. FramelessMainWindowLinux(bool p_frameless, QWidget *p_parent = nullptr);
  14. void setTitleBar(QWidget *p_titleBar) Q_DECL_OVERRIDE;
  15. protected:
  16. bool eventFilter(QObject *p_obj, QEvent *p_event) Q_DECL_OVERRIDE;
  17. void mousePressEvent(QMouseEvent *p_event) Q_DECL_OVERRIDE;
  18. void mouseReleaseEvent(QMouseEvent *p_event) Q_DECL_OVERRIDE;
  19. void mouseMoveEvent(QMouseEvent *p_event) Q_DECL_OVERRIDE;
  20. void showEvent(QShowEvent *p_event) Q_DECL_OVERRIDE;
  21. private:
  22. enum Area
  23. {
  24. Left = 0,
  25. TopLeft,
  26. Top,
  27. TopRight,
  28. Right,
  29. BottomRight,
  30. Bottom,
  31. BottomLeft,
  32. Caption,
  33. None
  34. };
  35. Area hitArea(const QPoint &p_pos) const;
  36. void doResize(QEvent *p_event);
  37. void recordMousePress(const QPoint &p_pos);
  38. const int m_resizeAreaWidth = 6;
  39. int m_titleBarHeight = 0;
  40. Area m_mousePressArea = Area::None;
  41. QPoint m_mousePressPoint;
  42. bool m_mousePressed = false;
  43. QRect m_rectOnMousePress;
  44. };
  45. #else
  46. class FramelessMainWindowLinuxDummy
  47. {
  48. public:
  49. FramelessMainWindowLinuxDummy() = default;
  50. };
  51. #endif
  52. }
  53. #endif // FRAMELESSMAINWINDOWLINUX_H