WindowsFramelessWindow.h 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. #ifndef WINDOWSFRAMELESSWINDOW_H
  2. #define WINDOWSFRAMELESSWINDOW_H
  3. #include <QMainWindow>
  4. class WindowsWindowEffect;
  5. class TitleBar;
  6. class WindowsFramelessWindow : public QMainWindow
  7. {
  8. Q_OBJECT
  9. public:
  10. explicit WindowsFramelessWindow(QWidget *parent = nullptr);
  11. void setTitleBar(TitleBar *tBar);
  12. void setResizeEnabled(bool isEnabled);
  13. bool getResizeEnabled() const;
  14. WindowsWindowEffect *getWindowEffect() const;
  15. TitleBar *getTitleBar() const;
  16. protected:
  17. virtual QString effectType() const { return ""; };
  18. private:
  19. WindowsWindowEffect *windowEffect;
  20. TitleBar *titleBar;
  21. bool isResizeEnabled;
  22. private slots:
  23. void onScreenChanged(QScreen *screen);
  24. signals:
  25. // QWidget interface
  26. protected:
  27. void resizeEvent(QResizeEvent *event) Q_DECL_OVERRIDE;
  28. bool nativeEvent(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE;
  29. };
  30. class AcrylicWindow : public WindowsFramelessWindow
  31. {
  32. Q_OBJECT
  33. public:
  34. explicit AcrylicWindow(QWidget *parent = nullptr);
  35. // interface
  36. protected:
  37. QString effectType() const Q_DECL_OVERRIDE;
  38. void closeEvent(QCloseEvent *event) Q_DECL_OVERRIDE;
  39. bool nativeEvent(const QByteArray &eventType, void *message, long *result) Q_DECL_OVERRIDE;
  40. private:
  41. bool closedByKey;
  42. };
  43. #endif // WINDOWSFRAMELESSWINDOW_H