mirror-chatterino2/widgets/notebookpage.h

85 lines
2 KiB
C
Raw Normal View History

2016-12-29 17:31:07 +01:00
#ifndef NOTEBOOKPAGE_H
#define NOTEBOOKPAGE_H
2017-01-18 21:30:23 +01:00
#include "widgets/chatwidget.h"
#include "widgets/notebookpage.h"
#include "widgets/notebookpagedroppreview.h"
#include "widgets/notebooktab.h"
2016-12-30 12:20:26 +01:00
2017-01-18 04:52:47 +01:00
#include <QDragEnterEvent>
#include <QHBoxLayout>
#include <QRect>
#include <QVBoxLayout>
#include <QVector>
#include <QWidget>
#include <boost/property_tree/ptree.hpp>
2017-02-02 02:46:33 +01:00
#include <boost/signals2.hpp>
2017-01-18 04:52:47 +01:00
2017-01-18 21:30:23 +01:00
namespace chatterino {
namespace widgets {
2016-12-29 17:31:07 +01:00
class NotebookPage : public QWidget
{
2017-01-11 18:52:09 +01:00
Q_OBJECT
2016-12-29 17:31:07 +01:00
public:
2017-04-12 17:46:44 +02:00
NotebookPage(QWidget *parent, NotebookTab *_tab);
2017-01-01 02:30:42 +01:00
2017-01-11 18:52:09 +01:00
std::pair<int, int> removeFromLayout(ChatWidget *widget);
void addToLayout(ChatWidget *widget, std::pair<int, int> position);
2017-01-01 02:30:42 +01:00
2017-04-12 17:46:44 +02:00
const std::vector<ChatWidget *> &getChatWidgets() const;
NotebookTab *getTab() const;
2017-01-01 02:30:42 +01:00
static bool isDraggingSplit;
2017-01-11 18:52:09 +01:00
static ChatWidget *draggingSplit;
2017-01-01 02:30:42 +01:00
static std::pair<int, int> dropPosition;
2016-12-30 18:00:25 +01:00
protected:
2017-04-12 17:46:44 +02:00
void paintEvent(QPaintEvent *) override;
2017-01-01 02:30:42 +01:00
2017-01-18 14:48:42 +01:00
void enterEvent(QEvent *) override;
void leaveEvent(QEvent *) override;
void mouseReleaseEvent(QMouseEvent *event) override;
2017-04-12 17:46:44 +02:00
void dragEnterEvent(QDragEnterEvent *event) override;
void dragMoveEvent(QDragMoveEvent *event) override;
void dragLeaveEvent(QDragLeaveEvent *event) override;
void dropEvent(QDropEvent *event) override;
2017-01-01 02:30:42 +01:00
2017-04-12 17:46:44 +02:00
private:
2017-01-11 18:52:09 +01:00
struct DropRegion {
2017-01-01 02:30:42 +01:00
QRect rect;
std::pair<int, int> position;
DropRegion(QRect rect, std::pair<int, int> position)
{
this->rect = rect;
this->position = position;
}
};
2017-04-12 17:46:44 +02:00
NotebookTab *_tab;
2017-04-12 17:46:44 +02:00
QVBoxLayout _parentbox;
QHBoxLayout _hbox;
2017-01-01 02:30:42 +01:00
2017-04-12 17:46:44 +02:00
std::vector<ChatWidget *> _chatWidgets;
std::vector<DropRegion> _dropRegions;
NotebookPageDropPreview _preview;
2017-01-01 02:30:42 +01:00
void setPreviewRect(QPoint mousePos);
2017-01-29 12:26:22 +01:00
std::pair<int, int> getChatPosition(const ChatWidget *chatWidget);
public:
2017-01-29 11:38:00 +01:00
void load(const boost::property_tree::ptree &tree);
boost::property_tree::ptree save();
2016-12-29 17:31:07 +01:00
};
2017-04-14 17:47:28 +02:00
} // namespace widgets
} // namespace chatterino
2016-12-29 17:31:07 +01:00
2017-01-11 18:52:09 +01:00
#endif // NOTEBOOKPAGE_H