#pragma once #include "widgets/basewidget.hpp" #include "widgets/chatwidget.hpp" #include "widgets/notebookpage.hpp" #include "widgets/notebookpagedroppreview.hpp" #include "widgets/notebooktab.hpp" #include #include #include #include #include #include #include #include namespace chatterino { class ChannelManager; namespace widgets { class NotebookPage : public BaseWidget { Q_OBJECT public: NotebookPage(ChannelManager &_channelManager, Notebook *parent, NotebookTab *_tab); ChannelManager &channelManager; std::pair removeFromLayout(ChatWidget *widget); void addToLayout(ChatWidget *widget, std::pair position); const std::vector &getChatWidgets() const; NotebookTab *getTab() const; void addChat(bool openChannelNameDialog = false); static bool isDraggingSplit; static ChatWidget *draggingSplit; static std::pair dropPosition; protected: virtual void paintEvent(QPaintEvent *) override; virtual void enterEvent(QEvent *) override; virtual void leaveEvent(QEvent *) override; virtual void mouseReleaseEvent(QMouseEvent *event) override; virtual void dragEnterEvent(QDragEnterEvent *event) override; virtual void dragMoveEvent(QDragMoveEvent *event) override; virtual void dragLeaveEvent(QDragLeaveEvent *event) override; virtual void dropEvent(QDropEvent *event) override; private: struct DropRegion { QRect rect; std::pair position; DropRegion(QRect rect, std::pair position) { this->rect = rect; this->position = position; } }; NotebookTab *tab; struct { QVBoxLayout parentLayout; QHBoxLayout hbox; } ui; std::vector chatWidgets; std::vector dropRegions; NotebookPageDropPreview dropPreview; void setPreviewRect(QPoint mousePos); std::pair getChatPosition(const ChatWidget *chatWidget); ChatWidget *createChatWidget(); public: void load(const boost::property_tree::ptree &tree); boost::property_tree::ptree save(); }; } // namespace widgets } // namespace chatterino