diff --git a/chatterino.pro b/chatterino.pro
index 328a10b1c..8b36f80a3 100644
--- a/chatterino.pro
+++ b/chatterino.pro
@@ -4,7 +4,7 @@
#
#-------------------------------------------------
-QT += core gui network multimedia
+QT += core gui network multimedia webengine webenginewidgets webchannel
CONFIG += communi
COMMUNI += core model util
CONFIG += c++14
diff --git a/resources/chat.html b/resources/chat.html
new file mode 100644
index 000000000..10cb94919
--- /dev/null
+++ b/resources/chat.html
@@ -0,0 +1,90 @@
+
+
+
+
+ Title
+
+
+
+
+
+
+
+
+
+
diff --git a/resources/resources.qrc b/resources/resources.qrc
index e09f97853..e812457ab 100644
--- a/resources/resources.qrc
+++ b/resources/resources.qrc
@@ -32,6 +32,7 @@
images/UserProfile_22x.png
images/VSO_Link_blue_16x.png
sounds/ping2.wav
+ chat.html
qt.conf
diff --git a/src/messages/word.cpp b/src/messages/word.cpp
index fc81a76f1..9dfa532fa 100644
--- a/src/messages/word.cpp
+++ b/src/messages/word.cpp
@@ -127,6 +127,11 @@ int Word::getCharacterLength() const
return this->isImage() ? 2 : this->getText().length() + 1;
}
+const QString &Word::getEmoteURL() const
+{
+ return emoteURL;
+}
+
std::vector &Word::getCharacterWidthCache() const
{
// lock not required because there is only one gui thread
diff --git a/src/messages/word.hpp b/src/messages/word.hpp
index 0c0142d9f..f341a5034 100644
--- a/src/messages/word.hpp
+++ b/src/messages/word.hpp
@@ -114,6 +114,7 @@ public:
int getYOffset() const;
void setOffset(int _xOffset, int _yOffset);
int getCharacterLength() const;
+ const QString &getEmoteURL() const;
std::vector &getCharacterWidthCache() const;
@@ -122,6 +123,7 @@ private:
QString text;
MessageColor color;
bool _isImage;
+ QString emoteURL;
Type type;
QString copyText;
diff --git a/src/widgets/channelview.cpp b/src/widgets/channelview.cpp
index c1bb189bb..e6eda1122 100644
--- a/src/widgets/channelview.cpp
+++ b/src/widgets/channelview.cpp
@@ -35,7 +35,7 @@ ChannelView::ChannelView(WindowManager &windowManager, BaseWidget *parent)
#ifndef Q_OS_MAC
// this->setAttribute(Qt::WA_OpaquePaintEvent);
#endif
- this->setMouseTracking(true);
+ /*this->setMouseTracking(true);
QObject::connect(&SettingsManager::getInstance(), &SettingsManager::wordTypeMaskChanged, this,
&ChannelView::wordTypeMaskChanged);
@@ -59,7 +59,14 @@ ChannelView::ChannelView(WindowManager &windowManager, BaseWidget *parent)
this->goToBottom->setVisible(false);
connect(goToBottom, &RippleEffectLabel::clicked, this,
- [this] { QTimer::singleShot(180, [this] { this->scrollBar.scrollToBottom(); }); });
+ [this] { QTimer::singleShot(180, [this] { this->scrollBar.scrollToBottom(); }); });*/
+
+ setLayout(&vbox);
+ vbox.addWidget(&web);
+
+ web.load(QUrl("qrc:/chat.html"));
+ web.page()->setBackgroundColor(this->colorScheme.ChatBackground);
+ web.setContextMenuPolicy(Qt::ContextMenuPolicy::NoContextMenu);
}
ChannelView::~ChannelView()
@@ -112,7 +119,6 @@ bool ChannelView::layoutMessages()
for (std::size_t i = messages.getLength() - 1; i > 0; i--) {
auto *message = messages[i].get();
-
message->layout(layoutWidth, true);
h -= message->getHeight();
@@ -296,18 +302,29 @@ void ChannelView::setChannel(std::shared_ptr channel)
// on new message
this->messageAppendedConnection =
channel->messageAppended.connect([this](SharedMessage &message) {
- SharedMessageRef deleted;
+ //SharedMessageRef deleted;
- auto messageRef = new MessageRef(message);
+ auto command = QString("addMessage('%1','%2'").arg("", "");
+ for (const auto &word : message->getWords()) {
+ command += ",";
+ if (word.isText()) {
+ command += "{type:'text', data:'" + word.getText() + "'}";
+ } else {
+ command += "{type:'emote', data:'" + word.getEmoteURL() + "'}";
+ }
+ }
+ command += ");";
+ qDebug() << command;
+ web.page()->runJavaScript(command);
- if (this->messages.appendItem(SharedMessageRef(messageRef), deleted)) {
+ /*if (this->messages.appendItem(SharedMessageRef(messageRef), deleted)) {
qreal value = std::max(0.0, this->getScrollBar().getDesiredValue() - 1);
this->getScrollBar().setDesiredValue(value, false);
- }
+ }*/
- layoutMessages();
- update();
+ //layoutMessages();
+ //update();
});
// on message removed
@@ -348,7 +365,7 @@ void ChannelView::detachChannel()
void ChannelView::resizeEvent(QResizeEvent *)
{
- this->scrollBar.resize(this->scrollBar.width(), height());
+ /*this->scrollBar.resize(this->scrollBar.width(), height());
this->scrollBar.move(width() - this->scrollBar.width(), 0);
this->goToBottom->setGeometry(0, this->height() - 32, this->width(), 32);
@@ -357,7 +374,7 @@ void ChannelView::resizeEvent(QResizeEvent *)
layoutMessages();
- this->update();
+ this->update();*/
}
void ChannelView::setSelection(const SelectionItem &start, const SelectionItem &end)
diff --git a/src/widgets/channelview.hpp b/src/widgets/channelview.hpp
index d232b5813..9e9cb3b0c 100644
--- a/src/widgets/channelview.hpp
+++ b/src/widgets/channelview.hpp
@@ -14,6 +14,7 @@
#include
#include
#include
+#include
#include
@@ -159,6 +160,9 @@ private:
boost::signals2::connection repaintGifsConnection;
boost::signals2::connection layoutConnection;
+ QWebEngineView web;
+ QVBoxLayout vbox;
+
private slots:
void wordTypeMaskChanged()
{
diff --git a/src/widgets/chatwidget.cpp b/src/widgets/chatwidget.cpp
index 1b47a839e..825294e96 100644
--- a/src/widgets/chatwidget.cpp
+++ b/src/widgets/chatwidget.cpp
@@ -196,7 +196,6 @@ void ChatWidget::paintEvent(QPaintEvent *)
{
// color the background of the chat
QPainter painter(this);
-
painter.fillRect(this->rect(), this->colorScheme.ChatBackground);
}
diff --git a/src/widgets/mainwindow.cpp b/src/widgets/mainwindow.cpp
index d6d140b62..358ba4a72 100644
--- a/src/widgets/mainwindow.cpp
+++ b/src/widgets/mainwindow.cpp
@@ -77,16 +77,6 @@ void MainWindow::repaintVisibleChatWidgets(Channel *channel)
if (page == nullptr) {
return;
}
-
- const std::vector &widgets = page->getChatWidgets();
-
- for (auto it = widgets.begin(); it != widgets.end(); ++it) {
- ChatWidget *widget = *it;
-
- if (channel == nullptr || channel == widget->getChannel().get()) {
- widget->layoutMessages();
- }
- }
}
void MainWindow::load(const boost::property_tree::ptree &tree)