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