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-06-11 15:04:54 +02:00
|
|
|
#include <pajlada/signals/signalholder.hpp>
|
2018-01-24 15:08:22 +01:00
|
|
|
|
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-06-06 13:35:06 +02:00
|
|
|
enum Flags {
|
|
|
|
None = 0,
|
|
|
|
EnableCustomFrame = 1,
|
|
|
|
Frameless = 2,
|
|
|
|
TopMost = 4,
|
2018-06-11 15:04:54 +02:00
|
|
|
DeleteOnFocusOut = 8,
|
|
|
|
DisableCustomScaling = 16,
|
2018-06-19 19:42:15 +02:00
|
|
|
FramelessDraggable = 32,
|
2018-06-06 13:35:06 +02:00
|
|
|
};
|
2018-05-23 22:27:29 +02:00
|
|
|
|
2018-06-11 15:04:54 +02:00
|
|
|
explicit BaseWindow(QWidget *parent = nullptr, Flags flags_ = None);
|
2018-01-15 01:35:35 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
|
2018-05-26 17:11:09 +02:00
|
|
|
void moveTo(QWidget *widget, QPoint point, bool offset = true);
|
2018-01-22 20:52:32 +01:00
|
|
|
|
2018-06-24 13:32:56 +02:00
|
|
|
virtual float getScale() const override;
|
|
|
|
|
2018-05-24 10:03:07 +02:00
|
|
|
Flags getFlags();
|
|
|
|
|
2018-01-14 21:55:36 +01:00
|
|
|
protected:
|
|
|
|
#ifdef USEWINSDK
|
2018-06-06 13:35:06 +02:00
|
|
|
virtual void showEvent(QShowEvent *) override;
|
|
|
|
virtual bool nativeEvent(const QByteArray &eventType, void *message, long *result) override;
|
|
|
|
virtual void scaleChangedEvent(float) override;
|
2018-01-14 21:55:36 +01:00
|
|
|
#endif
|
|
|
|
|
2018-06-06 13:35:06 +02:00
|
|
|
virtual void paintEvent(QPaintEvent *) override;
|
2018-06-06 10:46:23 +02:00
|
|
|
|
2018-06-06 13:35:06 +02:00
|
|
|
virtual void changeEvent(QEvent *) override;
|
|
|
|
virtual void leaveEvent(QEvent *) override;
|
|
|
|
virtual void resizeEvent(QResizeEvent *) override;
|
2018-01-14 21:55:36 +01:00
|
|
|
|
2018-06-06 13:35:06 +02:00
|
|
|
virtual void themeRefreshEvent() override;
|
|
|
|
virtual bool event(QEvent *event) override;
|
2018-06-11 15:04:54 +02:00
|
|
|
virtual void wheelEvent(QWheelEvent *event) override;
|
|
|
|
|
2018-06-24 18:09:11 +02:00
|
|
|
void mousePressEvent(QMouseEvent *event) override;
|
|
|
|
void mouseReleaseEvent(QMouseEvent *event) override;
|
|
|
|
void mouseMoveEvent(QMouseEvent *event) override;
|
|
|
|
QPointF movingRelativePos;
|
|
|
|
bool moving{};
|
|
|
|
|
2018-06-11 15:04:54 +02:00
|
|
|
void updateScale();
|
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
|
|
|
|
2018-06-11 15:04:54 +02:00
|
|
|
bool enableCustomFrame_;
|
|
|
|
bool frameless_;
|
|
|
|
bool stayInScreenRect_ = false;
|
|
|
|
bool shown_ = false;
|
|
|
|
Flags flags_;
|
|
|
|
float nativeScale_ = 1;
|
2018-01-15 01:35:35 +01:00
|
|
|
|
2018-04-18 18:10:47 +02:00
|
|
|
struct {
|
2018-06-24 21:57:03 +02:00
|
|
|
QLayout *windowLayout = nullptr;
|
2018-05-23 22:27:29 +02:00
|
|
|
QHBoxLayout *titlebarBox = nullptr;
|
|
|
|
QWidget *titleLabel = nullptr;
|
2018-04-18 18:10:47 +02:00
|
|
|
TitleBarButton *minButton = nullptr;
|
|
|
|
TitleBarButton *maxButton = nullptr;
|
|
|
|
TitleBarButton *exitButton = nullptr;
|
2018-05-23 22:27:29 +02:00
|
|
|
QWidget *layoutBase = nullptr;
|
2018-04-18 18:10:47 +02:00
|
|
|
std::vector<RippleEffectButton *> buttons;
|
2018-06-11 15:04:54 +02:00
|
|
|
} ui_;
|
|
|
|
|
|
|
|
pajlada::Signals::SignalHolder connections_;
|
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
|