2017-06-07 10:09:24 +02:00
|
|
|
#pragma once
|
2016-12-29 17:31:07 +01:00
|
|
|
|
2017-06-11 09:31:45 +02:00
|
|
|
#include "channel.hpp"
|
|
|
|
#include "messages/limitedqueuesnapshot.hpp"
|
|
|
|
#include "messages/messageref.hpp"
|
|
|
|
#include "messages/word.hpp"
|
|
|
|
#include "messages/wordpart.hpp"
|
2017-06-26 16:41:20 +02:00
|
|
|
#include "widgets/basewidget.hpp"
|
2017-06-11 09:31:45 +02:00
|
|
|
#include "widgets/chatwidgetheader.hpp"
|
|
|
|
#include "widgets/chatwidgetinput.hpp"
|
|
|
|
#include "widgets/chatwidgetview.hpp"
|
2017-01-01 02:30:42 +01:00
|
|
|
|
2017-01-18 04:33:30 +01:00
|
|
|
#include <QFont>
|
2017-06-10 23:53:39 +02:00
|
|
|
#include <QShortcut>
|
2017-01-18 04:33:30 +01:00
|
|
|
#include <QVBoxLayout>
|
|
|
|
#include <QWidget>
|
2017-01-29 11:38:00 +01:00
|
|
|
#include <boost/property_tree/ptree.hpp>
|
2017-02-02 22:15:09 +01:00
|
|
|
#include <boost/signals2/connection.hpp>
|
2017-01-18 04:33:30 +01:00
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
namespace chatterino {
|
2017-06-13 21:13:58 +02:00
|
|
|
|
|
|
|
class ChannelManager;
|
2017-06-26 16:41:20 +02:00
|
|
|
class ColorScheme;
|
2017-07-23 14:16:13 +02:00
|
|
|
class CompletionManager;
|
2017-06-13 21:13:58 +02:00
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
namespace widgets {
|
2017-01-18 21:30:23 +01:00
|
|
|
|
2017-06-26 16:41:20 +02:00
|
|
|
class NotebookPage;
|
|
|
|
|
2017-06-10 22:48:28 +02:00
|
|
|
// Each ChatWidget consists of three sub-elements that handle their own part of the chat widget:
|
|
|
|
// ChatWidgetHeader
|
|
|
|
// - Responsible for rendering which channel the ChatWidget is in, and the menu in the top-left of
|
|
|
|
// the chat widget
|
|
|
|
// ChatWidgetView
|
|
|
|
// - Responsible for rendering all chat messages, and the scrollbar
|
|
|
|
// ChatWidgetInput
|
|
|
|
// - Responsible for rendering and handling user text input
|
|
|
|
//
|
|
|
|
// Each sub-element has a reference to the parent Chat Widget
|
2017-06-26 16:41:20 +02:00
|
|
|
class ChatWidget : public BaseWidget
|
2016-12-29 17:31:07 +01:00
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2017-06-26 16:41:20 +02:00
|
|
|
ChatWidget(ChannelManager &_channelManager, NotebookPage *parent);
|
2017-01-01 02:30:42 +01:00
|
|
|
~ChatWidget();
|
2016-12-29 17:31:07 +01:00
|
|
|
|
2017-06-11 11:36:42 +02:00
|
|
|
std::shared_ptr<Channel> getChannel() const;
|
|
|
|
std::shared_ptr<Channel> &getChannelRef();
|
2017-01-17 00:15:44 +01:00
|
|
|
|
|
|
|
void showChangeChannelPopup();
|
2017-04-12 17:46:44 +02:00
|
|
|
messages::LimitedQueueSnapshot<messages::SharedMessageRef> getMessagesSnapshot();
|
2017-07-02 14:40:36 +02:00
|
|
|
void layoutMessages(bool forceUpdate = false);
|
2017-04-12 17:46:44 +02:00
|
|
|
void updateGifEmotes();
|
2017-02-02 22:15:09 +01:00
|
|
|
|
2017-06-11 20:53:43 +02:00
|
|
|
void giveFocus();
|
|
|
|
|
2017-07-09 17:49:02 +02:00
|
|
|
pajlada::Settings::Setting<std::string> channelName;
|
|
|
|
|
2016-12-29 17:31:07 +01:00
|
|
|
protected:
|
2017-07-02 14:28:37 +02:00
|
|
|
virtual void paintEvent(QPaintEvent *) override;
|
2016-12-29 17:31:07 +01:00
|
|
|
|
2017-07-23 14:16:13 +02:00
|
|
|
public:
|
2017-06-13 21:13:58 +02:00
|
|
|
ChannelManager &channelManager;
|
2017-07-23 14:16:13 +02:00
|
|
|
CompletionManager &completionManager;
|
2017-06-13 21:13:58 +02:00
|
|
|
|
2017-07-23 14:16:13 +02:00
|
|
|
private:
|
2017-06-11 11:36:42 +02:00
|
|
|
void setChannel(std::shared_ptr<Channel> newChannel);
|
2017-05-29 21:02:01 +02:00
|
|
|
void detachChannel();
|
2017-04-12 17:46:44 +02:00
|
|
|
|
2017-07-09 17:49:02 +02:00
|
|
|
void channelNameUpdated(const std::string &newChannelName);
|
|
|
|
|
2017-06-11 11:36:42 +02:00
|
|
|
messages::LimitedQueue<messages::SharedMessageRef> messages;
|
2017-02-02 22:15:09 +01:00
|
|
|
|
2017-06-11 11:36:42 +02:00
|
|
|
std::shared_ptr<Channel> channel;
|
2017-01-18 04:33:30 +01:00
|
|
|
|
2017-06-11 11:36:42 +02:00
|
|
|
QVBoxLayout vbox;
|
|
|
|
ChatWidgetHeader header;
|
|
|
|
ChatWidgetView view;
|
|
|
|
ChatWidgetInput input;
|
2017-01-29 11:38:00 +01:00
|
|
|
|
2017-06-11 11:36:42 +02:00
|
|
|
boost::signals2::connection messageAppendedConnection;
|
|
|
|
boost::signals2::connection messageRemovedConnection;
|
2017-02-02 22:15:09 +01:00
|
|
|
|
2017-01-29 11:38:00 +01:00
|
|
|
public:
|
|
|
|
void load(const boost::property_tree::ptree &tree);
|
|
|
|
boost::property_tree::ptree save();
|
2017-06-10 23:53:39 +02:00
|
|
|
|
|
|
|
public slots:
|
|
|
|
// Add new split to the notebook page that this chat widget is in
|
|
|
|
// Maybe we should use this chat widget as a hint to where the new split should be created
|
|
|
|
void doAddSplit();
|
|
|
|
|
|
|
|
// Close current split (chat widget)
|
|
|
|
void doCloseSplit();
|
|
|
|
|
|
|
|
// Show a dialog for changing the current splits/chat widgets channel
|
|
|
|
void doChangeChannel();
|
2017-06-11 09:11:55 +02:00
|
|
|
|
|
|
|
// Open popup copy of this chat widget
|
|
|
|
// XXX: maybe make current chatwidget a popup instead?
|
|
|
|
void doPopup();
|
|
|
|
|
|
|
|
// Clear chat from all messages
|
|
|
|
void doClearChat();
|
|
|
|
|
|
|
|
// Open link to twitch channel in default browser
|
|
|
|
void doOpenChannel();
|
|
|
|
|
|
|
|
// Open popup player of twitch channel in default browser
|
|
|
|
void doOpenPopupPlayer();
|
2016-12-29 17:31:07 +01:00
|
|
|
};
|
2017-01-29 11:38:00 +01:00
|
|
|
|
2017-04-14 17:52:22 +02:00
|
|
|
} // namespace widgets
|
|
|
|
} // namespace chatterino
|