mirror-chatterino2/src/widgets/notebookpage.hpp
Rasmus Karlsson 7df7da70cb A lot of changes
Remove unused constructor of messages::Message
Fixed LimitedQueueSnapshot _-prefixes
Changed LimitedQueueSnapshot's usage of int to std::size_t
ColorScheme is no longer a singleton
Created a "BaseWidget" class which is pretty much a QWidget except it
has a reference of ColorScheme since most widgets will need a reference
to the style they should use.
BaseWidget can be implemented either with a BaseWidget parent (which
will copy the ColorScheme reference from the parent) or with a
normal QWidget parent and an explicit ColorScheme reference.
Save main window geometry on close
Fix font changing in the Settings Dialog
Update settings library version
2017-06-26 19:53:31 +02:00

92 lines
2.2 KiB
C++

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