mirror-chatterino2/src/widgets/notebookpage.hpp
Rasmus Karlsson 3bf111a091 More progress on tab-complete
There are missing parts to the "account-based" emotes that needs to be
completed before emote completion can be considered done. For now, when
I've been testing, I've been manually injecting the oauthClient and
oauthToken to the settings file with the `user_subscriptions` scope
2017-07-23 14:16:13 +02:00

97 lines
2.3 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;
class CompletionManager;
namespace widgets {
class NotebookPage : public BaseWidget
{
Q_OBJECT
public:
NotebookPage(ChannelManager &_channelManager, Notebook *parent, NotebookTab *_tab);
ChannelManager &channelManager;
CompletionManager &completionManager;
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:
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<int, int> position;
DropRegion(QRect rect, std::pair<int, int> position)
{
this->rect = rect;
this->position = position;
}
};
NotebookTab *tab;
struct {
QVBoxLayout parentLayout;
QHBoxLayout hbox;
} ui;
std::vector<ChatWidget *> chatWidgets;
std::vector<DropRegion> dropRegions;
NotebookPageDropPreview dropPreview;
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