2017-06-07 10:09:24 +02:00
|
|
|
#pragma once
|
2016-12-29 17:31:07 +01:00
|
|
|
|
2017-06-26 16:41:20 +02:00
|
|
|
#include "widgets/basewidget.hpp"
|
2017-11-12 17:21:50 +01:00
|
|
|
#include "widgets/helper/droppreview.hpp"
|
|
|
|
#include "widgets/helper/notebooktab.hpp"
|
|
|
|
#include "widgets/split.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>
|
|
|
|
|
2017-01-18 21:30:23 +01:00
|
|
|
namespace chatterino {
|
2017-06-13 21:13:58 +02:00
|
|
|
|
|
|
|
class ChannelManager;
|
|
|
|
|
2017-01-18 21:30:23 +01:00
|
|
|
namespace widgets {
|
|
|
|
|
2017-11-12 17:21:50 +01:00
|
|
|
class SplitContainer : 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
|
|
|
|
2017-12-28 18:15:27 +01:00
|
|
|
const std::string uuid;
|
|
|
|
const std::string settingRoot;
|
2017-12-22 14:44:31 +01:00
|
|
|
|
2016-12-29 17:31:07 +01:00
|
|
|
public:
|
2017-12-22 14:44:31 +01:00
|
|
|
SplitContainer(ChannelManager &_channelManager, Notebook *parent, NotebookTab *_tab,
|
2017-12-28 18:15:27 +01:00
|
|
|
const std::string &_uuid);
|
|
|
|
|
|
|
|
const std::string &getUUID() const
|
|
|
|
{
|
|
|
|
return this->uuid;
|
|
|
|
}
|
2017-06-26 16:41:20 +02:00
|
|
|
|
|
|
|
ChannelManager &channelManager;
|
2017-01-01 02:30:42 +01:00
|
|
|
|
2017-11-12 17:21:50 +01:00
|
|
|
std::pair<int, int> removeFromLayout(Split *widget);
|
|
|
|
void addToLayout(Split *widget, std::pair<int, int> position = std::pair<int, int>(-1, -1));
|
2017-01-01 02:30:42 +01:00
|
|
|
|
2017-11-12 17:21:50 +01:00
|
|
|
const std::vector<Split *> &getChatWidgets() const;
|
2017-04-12 17:46:44 +02:00
|
|
|
NotebookTab *getTab() const;
|
2017-01-16 03:15:07 +01:00
|
|
|
|
2017-12-22 14:44:31 +01:00
|
|
|
void addChat(bool openChannelNameDialog = false, std::string chatUUID = std::string());
|
2017-05-29 21:26:55 +02:00
|
|
|
|
2017-01-01 02:30:42 +01:00
|
|
|
static bool isDraggingSplit;
|
2017-11-12 17:21:50 +01:00
|
|
|
static Split *draggingSplit;
|
2017-01-01 02:30:42 +01:00
|
|
|
static std::pair<int, int> dropPosition;
|
2016-12-30 18:00:25 +01:00
|
|
|
|
2017-08-12 15:41:14 +02:00
|
|
|
int currentX = 0;
|
|
|
|
int currentY = 0;
|
|
|
|
std::map<int, int> lastRequestedY;
|
|
|
|
|
|
|
|
void refreshCurrentFocusCoordinates(bool alsoSetLastRequested = false);
|
|
|
|
void requestFocus(int x, int y);
|
|
|
|
|
2017-11-12 17:21:50 +01:00
|
|
|
void updateFlexValues();
|
|
|
|
|
2016-12-30 18:00:25 +01:00
|
|
|
protected:
|
2017-08-12 15:41:14 +02:00
|
|
|
virtual bool eventFilter(QObject *object, QEvent *event) override;
|
2017-07-02 13:10:06 +02:00
|
|
|
virtual void paintEvent(QPaintEvent *) override;
|
2017-01-01 02:30:42 +01:00
|
|
|
|
2017-08-12 15:41:14 +02:00
|
|
|
virtual void showEvent(QShowEvent *) override;
|
|
|
|
|
2017-07-02 13:10:06 +02:00
|
|
|
virtual void enterEvent(QEvent *) override;
|
|
|
|
virtual void leaveEvent(QEvent *) override;
|
|
|
|
virtual void mouseReleaseEvent(QMouseEvent *event) override;
|
2017-01-01 13:07:36 +01:00
|
|
|
|
2017-07-02 13:10:06 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2017-06-13 21:13:58 +02:00
|
|
|
NotebookTab *tab;
|
2017-01-16 03:15:07 +01:00
|
|
|
|
2017-07-02 13:10:06 +02:00
|
|
|
struct {
|
|
|
|
QVBoxLayout parentLayout;
|
2017-01-01 02:30:42 +01:00
|
|
|
|
2017-07-02 13:10:06 +02:00
|
|
|
QHBoxLayout hbox;
|
|
|
|
} ui;
|
2017-04-12 17:46:44 +02:00
|
|
|
|
2017-11-12 17:21:50 +01:00
|
|
|
std::vector<Split *> chatWidgets;
|
2017-07-02 13:10:06 +02:00
|
|
|
std::vector<DropRegion> dropRegions;
|
|
|
|
|
2017-12-22 14:44:31 +01:00
|
|
|
pajlada::Settings::Setting<std::vector<std::vector<std::string>>> chats;
|
|
|
|
|
2017-07-02 13:10:06 +02:00
|
|
|
NotebookPageDropPreview dropPreview;
|
2017-01-01 02:30:42 +01:00
|
|
|
|
|
|
|
void setPreviewRect(QPoint mousePos);
|
2017-01-28 22:35:23 +01:00
|
|
|
|
2017-11-12 17:21:50 +01:00
|
|
|
std::pair<int, int> getChatPosition(const Split *chatWidget);
|
2017-01-29 12:26:22 +01:00
|
|
|
|
2017-12-22 14:44:31 +01:00
|
|
|
Split *createChatWidget(const std::string &uuid);
|
2017-06-26 16:41:20 +02:00
|
|
|
|
2017-01-28 22:35:23 +01:00
|
|
|
public:
|
2017-08-13 16:52:16 +02:00
|
|
|
void refreshTitle();
|
|
|
|
|
2017-12-22 14:44:31 +01:00
|
|
|
void loadSplits();
|
|
|
|
|
|
|
|
void save();
|
2016-12-29 17:31:07 +01:00
|
|
|
};
|
2017-01-28 22:35:23 +01:00
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
} // namespace widgets
|
|
|
|
} // namespace chatterino
|