mirror-chatterino2/src/widgets/notebookpage.hpp

107 lines
2.7 KiB
C++
Raw Normal View History

#pragma once
2016-12-29 17:31:07 +01:00
#include "widgets/basewidget.hpp"
2017-06-11 09:31:45 +02:00
#include "widgets/chatwidget.hpp"
#include "widgets/notebookpage.hpp"
#include "widgets/notebookpagedroppreview.hpp"
#include "widgets/notebooktab.hpp"
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 {
class ChannelManager;
class CompletionManager;
2017-01-18 21:30:23 +01:00
namespace widgets {
class NotebookPage : public BaseWidget
2016-12-29 17:31:07 +01:00
{
2017-01-11 18:52:09 +01:00
Q_OBJECT
2016-12-29 17:31:07 +01:00
public:
NotebookPage(ChannelManager &_channelManager, Notebook *parent, NotebookTab *_tab);
ChannelManager &channelManager;
CompletionManager &completionManager;
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-05-29 21:26:55 +02:00
void addChat(bool openChannelNameDialog = false);
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
int currentX = 0;
int currentY = 0;
std::map<int, int> lastRequestedY;
void refreshCurrentFocusCoordinates(bool alsoSetLastRequested = false);
void requestFocus(int x, int y);
2016-12-30 18:00:25 +01:00
protected:
virtual bool eventFilter(QObject *object, QEvent *event) override;
virtual void paintEvent(QPaintEvent *) override;
2017-01-01 02:30:42 +01:00
virtual void showEvent(QShowEvent *) 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;
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;
}
};
NotebookTab *tab;
struct {
QVBoxLayout parentLayout;
2017-01-01 02:30:42 +01:00
QHBoxLayout hbox;
} ui;
2017-04-12 17:46:44 +02:00
std::vector<ChatWidget *> chatWidgets;
std::vector<DropRegion> dropRegions;
NotebookPageDropPreview dropPreview;
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);
ChatWidget *createChatWidget();
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:52:22 +02:00
} // namespace widgets
} // namespace chatterino