2019-09-08 22:27:57 +02:00
|
|
|
#pragma once
|
|
|
|
|
Sort and force grouping of includes (#4172)
This change enforces strict include grouping using IncludeCategories
In addition to adding this to the .clang-format file and applying it in the tests/src and src directories, I also did the following small changes:
In ChatterSet.hpp, I changed lrucache to a <>include
In Irc2.hpp, I change common/SignalVector.hpp to a "project-include"
In AttachedWindow.cpp, NativeMessaging.cpp, WindowsHelper.hpp, BaseWindow.cpp, and StreamerMode.cpp, I disabled clang-format for the windows-includes
In WindowDescriptors.hpp, I added the missing vector include. It was previously not needed because the include was handled by another file that was previously included first.
clang-format minimum version has been bumped, so Ubuntu version used in the check-formatting job has been bumped to 22.04 (which is the latest LTS)
2022-11-27 19:32:53 +01:00
|
|
|
#include "common/FlagsEnum.hpp"
|
2019-09-08 22:27:57 +02:00
|
|
|
#include "widgets/BaseWidget.hpp"
|
|
|
|
|
|
|
|
#include <pajlada/signals/signalholder.hpp>
|
2022-12-31 15:41:01 +01:00
|
|
|
#include <QTimer>
|
Sort and force grouping of includes (#4172)
This change enforces strict include grouping using IncludeCategories
In addition to adding this to the .clang-format file and applying it in the tests/src and src directories, I also did the following small changes:
In ChatterSet.hpp, I changed lrucache to a <>include
In Irc2.hpp, I change common/SignalVector.hpp to a "project-include"
In AttachedWindow.cpp, NativeMessaging.cpp, WindowsHelper.hpp, BaseWindow.cpp, and StreamerMode.cpp, I disabled clang-format for the windows-includes
In WindowDescriptors.hpp, I added the missing vector include. It was previously not needed because the include was handled by another file that was previously included first.
clang-format minimum version has been bumped, so Ubuntu version used in the check-formatting job has been bumped to 22.04 (which is the latest LTS)
2022-11-27 19:32:53 +01:00
|
|
|
|
|
|
|
#include <functional>
|
2019-09-08 22:27:57 +02:00
|
|
|
|
|
|
|
class QHBoxLayout;
|
|
|
|
struct tagMSG;
|
|
|
|
typedef struct tagMSG MSG;
|
|
|
|
|
2019-10-07 15:46:08 +02:00
|
|
|
namespace chatterino {
|
2019-09-08 22:27:57 +02:00
|
|
|
|
|
|
|
class Button;
|
|
|
|
class EffectLabel;
|
|
|
|
class TitleBarButton;
|
|
|
|
enum class TitleBarButtonStyle;
|
|
|
|
|
|
|
|
class BaseWindow : public BaseWidget
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
|
|
|
enum Flags {
|
|
|
|
None = 0,
|
|
|
|
EnableCustomFrame = 1,
|
|
|
|
Frameless = 2,
|
|
|
|
TopMost = 4,
|
|
|
|
DisableCustomScaling = 8,
|
|
|
|
FramelessDraggable = 16,
|
2020-08-15 18:59:17 +02:00
|
|
|
DontFocus = 32,
|
2020-10-31 16:42:48 +01:00
|
|
|
Dialog = 64,
|
2022-12-03 11:50:22 +01:00
|
|
|
DisableLayoutSave = 128,
|
2019-09-08 22:27:57 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
enum ActionOnFocusLoss { Nothing, Delete, Close, Hide };
|
|
|
|
|
2019-09-08 22:58:17 +02:00
|
|
|
explicit BaseWindow(FlagsEnum<Flags> flags_ = None,
|
|
|
|
QWidget *parent = nullptr);
|
2020-08-22 22:53:31 +02:00
|
|
|
~BaseWindow() override;
|
2019-09-08 22:27:57 +02:00
|
|
|
|
|
|
|
void setInitialBounds(const QRect &bounds);
|
|
|
|
QRect getBounds();
|
|
|
|
|
|
|
|
QWidget *getLayoutContainer();
|
|
|
|
bool hasCustomWindowFrame();
|
|
|
|
TitleBarButton *addTitleBarButton(const TitleBarButtonStyle &style,
|
|
|
|
std::function<void()> onClicked);
|
|
|
|
EffectLabel *addTitleBarLabel(std::function<void()> onClicked);
|
|
|
|
|
|
|
|
void setStayInScreenRect(bool value);
|
|
|
|
bool getStayInScreenRect() const;
|
|
|
|
|
|
|
|
void setActionOnFocusLoss(ActionOnFocusLoss value);
|
|
|
|
ActionOnFocusLoss getActionOnFocusLoss() const;
|
|
|
|
|
|
|
|
void moveTo(QWidget *widget, QPoint point, bool offset = true);
|
|
|
|
|
|
|
|
virtual float scale() const override;
|
|
|
|
float qtFontScale() const;
|
|
|
|
|
|
|
|
pajlada::Signals::NoArgSignal closing;
|
|
|
|
|
|
|
|
static bool supportsCustomWindowFrame();
|
|
|
|
|
|
|
|
protected:
|
2023-02-13 21:45:58 +01:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
|
|
bool nativeEvent(const QByteArray &eventType, void *message,
|
|
|
|
qintptr *result) override;
|
|
|
|
#else
|
|
|
|
bool nativeEvent(const QByteArray &eventType, void *message,
|
|
|
|
long *result) override;
|
|
|
|
#endif
|
2019-09-08 22:27:57 +02:00
|
|
|
virtual void scaleChangedEvent(float) override;
|
|
|
|
|
|
|
|
virtual void paintEvent(QPaintEvent *) override;
|
|
|
|
|
|
|
|
virtual void changeEvent(QEvent *) override;
|
|
|
|
virtual void leaveEvent(QEvent *) override;
|
|
|
|
virtual void resizeEvent(QResizeEvent *) override;
|
|
|
|
virtual void moveEvent(QMoveEvent *) override;
|
|
|
|
virtual void closeEvent(QCloseEvent *) override;
|
2019-09-08 22:58:17 +02:00
|
|
|
virtual void showEvent(QShowEvent *) override;
|
2019-09-08 22:27:57 +02:00
|
|
|
|
|
|
|
virtual void themeChangedEvent() 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();
|
|
|
|
|
|
|
|
boost::optional<QColor> overrideBackgroundColor_;
|
|
|
|
|
|
|
|
private:
|
|
|
|
void init();
|
2023-01-07 11:41:39 +01:00
|
|
|
void moveIntoDesktopRect(QPoint point);
|
2019-09-08 22:27:57 +02:00
|
|
|
void calcButtonsSizes();
|
|
|
|
void drawCustomWindowFrame(QPainter &painter);
|
|
|
|
void onFocusLost();
|
|
|
|
|
|
|
|
bool handleDPICHANGED(MSG *msg);
|
|
|
|
bool handleSHOWWINDOW(MSG *msg);
|
|
|
|
bool handleSIZE(MSG *msg);
|
|
|
|
bool handleMOVE(MSG *msg);
|
2023-02-13 21:45:58 +01:00
|
|
|
#if QT_VERSION >= QT_VERSION_CHECK(6, 0, 0)
|
|
|
|
bool handleNCCALCSIZE(MSG *msg, qintptr *result);
|
|
|
|
bool handleNCHITTEST(MSG *msg, qintptr *result);
|
|
|
|
#else
|
|
|
|
bool handleNCCALCSIZE(MSG *msg, long *result);
|
2019-09-08 22:27:57 +02:00
|
|
|
bool handleNCHITTEST(MSG *msg, long *result);
|
2023-02-13 21:45:58 +01:00
|
|
|
#endif
|
2019-09-08 22:27:57 +02:00
|
|
|
|
|
|
|
bool enableCustomFrame_;
|
|
|
|
ActionOnFocusLoss actionOnFocusLoss_ = Nothing;
|
|
|
|
bool frameless_;
|
|
|
|
bool stayInScreenRect_ = false;
|
|
|
|
bool shown_ = false;
|
2019-09-08 22:58:17 +02:00
|
|
|
FlagsEnum<Flags> flags_;
|
2019-09-08 22:27:57 +02:00
|
|
|
float nativeScale_ = 1;
|
2019-12-26 23:41:31 +01:00
|
|
|
bool isResizeFixing_ = false;
|
2019-09-08 22:27:57 +02:00
|
|
|
|
|
|
|
struct {
|
|
|
|
QLayout *windowLayout = nullptr;
|
|
|
|
QHBoxLayout *titlebarBox = nullptr;
|
|
|
|
QWidget *titleLabel = nullptr;
|
|
|
|
TitleBarButton *minButton = nullptr;
|
|
|
|
TitleBarButton *maxButton = nullptr;
|
|
|
|
TitleBarButton *exitButton = nullptr;
|
|
|
|
QWidget *layoutBase = nullptr;
|
|
|
|
std::vector<Button *> buttons;
|
|
|
|
} ui_;
|
|
|
|
|
|
|
|
#ifdef USEWINSDK
|
|
|
|
QRect initalBounds_;
|
|
|
|
QRect currentBounds_;
|
|
|
|
QRect nextBounds_;
|
|
|
|
QTimer useNextBounds_;
|
|
|
|
bool isNotMinimizedOrMaximized_{};
|
|
|
|
#endif
|
|
|
|
|
|
|
|
pajlada::Signals::SignalHolder connections_;
|
|
|
|
|
|
|
|
friend class BaseWidget;
|
|
|
|
};
|
|
|
|
|
2019-10-07 15:46:08 +02:00
|
|
|
} // namespace chatterino
|