mirror-chatterino2/src/widgets/basewindow.hpp

73 lines
2 KiB
C++
Raw Normal View History

#pragma once
#include "basewidget.hpp"
#include "widgets/helper/titlebarbutton.hpp"
2018-01-24 15:08:22 +01:00
#include <functional>
class QHBoxLayout;
namespace chatterino {
namespace widgets {
class RippleEffectButton;
2018-02-05 23:32:38 +01:00
class RippleEffectLabel;
class TitleBarButton;
class BaseWindow : public BaseWidget
{
Q_OBJECT
public:
explicit BaseWindow(singletons::ThemeManager &_themeManager, QWidget *parent,
bool enableCustomFrame = false);
explicit BaseWindow(BaseWidget *parent, bool enableCustomFrame = false);
explicit BaseWindow(QWidget *parent = nullptr, bool enableCustomFrame = false);
QWidget *getLayoutContainer();
bool hasCustomWindowFrame();
void addTitleBarButton(const TitleBarButton::Style &style, std::function<void()> onClicked);
2018-02-05 23:32:38 +01:00
RippleEffectLabel *addTitleBarLabel(std::function<void()> onClicked);
void setStayInScreenRect(bool value);
bool getStayInScreenRect() const;
void moveTo(QWidget *widget, QPoint point);
protected:
#ifdef USEWINSDK
virtual void showEvent(QShowEvent *);
virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
virtual void paintEvent(QPaintEvent *) override;
virtual void scaleChangedEvent(float) override;
#endif
virtual void changeEvent(QEvent *) override;
virtual void leaveEvent(QEvent *) override;
virtual void resizeEvent(QResizeEvent *) override;
2018-01-25 20:49:49 +01:00
virtual void themeRefreshEvent() override;
private:
void init();
void moveIntoDesktopRect(QWidget *parent);
void calcButtonsSizes();
bool enableCustomFrame;
bool stayInScreenRect = false;
2018-01-24 15:08:22 +01:00
bool shown = false;
struct {
QHBoxLayout *titlebarBox;
QWidget *titleLabel;
TitleBarButton *minButton = nullptr;
TitleBarButton *maxButton = nullptr;
TitleBarButton *exitButton = nullptr;
QWidget *layoutBase;
std::vector<RippleEffectButton *> buttons;
} ui;
};
} // namespace widgets
} // namespace chatterino