#pragma once #include "BaseWidget.hpp" #include "widgets/helper/TitlebarButton.hpp" #include #include class QHBoxLayout; namespace chatterino { class RippleEffectButton; class RippleEffectLabel; class TitleBarButton; class BaseWindow : public BaseWidget { Q_OBJECT public: enum Flags { None = 0, EnableCustomFrame = 1, Frameless = 2, TopMost = 4, DeleteOnFocusOut = 8, DisableCustomScaling = 16, FramelessDraggable = 32, }; explicit BaseWindow(QWidget *parent = nullptr, Flags flags_ = None); QWidget *getLayoutContainer(); bool hasCustomWindowFrame(); void addTitleBarButton(const TitleBarButton::Style &style, std::function onClicked); RippleEffectLabel *addTitleBarLabel(std::function onClicked); void setStayInScreenRect(bool value); bool getStayInScreenRect() const; void moveTo(QWidget *widget, QPoint point, bool offset = true); virtual float getScale() const override; Flags getFlags(); protected: #ifdef USEWINSDK virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result) override; virtual void scaleChangedEvent(float) override; #endif virtual void paintEvent(QPaintEvent *) override; virtual void changeEvent(QEvent *) override; virtual void leaveEvent(QEvent *) override; virtual void resizeEvent(QResizeEvent *) override; virtual void themeRefreshEvent() override; virtual bool event(QEvent *event) override; virtual void wheelEvent(QWheelEvent *event) override; void mousePressEvent(QMouseEvent *event) override; void mouseReleaseEvent(QMouseEvent *event) override; void mouseMoveEvent(QMouseEvent *event) override; QPointF movingRelativePos; bool moving{}; void updateScale(); private: void init(); void moveIntoDesktopRect(QWidget *parent); void calcButtonsSizes(); bool enableCustomFrame_; bool frameless_; bool stayInScreenRect_ = false; bool shown_ = false; Flags flags_; float nativeScale_ = 1; struct { QLayout *windowLayout = nullptr; QHBoxLayout *titlebarBox = nullptr; QWidget *titleLabel = nullptr; TitleBarButton *minButton = nullptr; TitleBarButton *maxButton = nullptr; TitleBarButton *exitButton = nullptr; QWidget *layoutBase = nullptr; std::vector buttons; } ui_; pajlada::Signals::SignalHolder connections_; std::vector managedConnections; }; } // namespace chatterino