fixed gifs on the emotepicker

This commit is contained in:
fourtf 2017-09-17 02:13:57 +02:00
parent 3e9f71dbf9
commit e31bb48384
13 changed files with 33 additions and 32 deletions

View file

@ -131,4 +131,9 @@ EmoteManager &ChannelManager::getEmoteManager()
return this->emoteManager;
}
WindowManager &ChannelManager::getWindowManager()
{
return this->windowManager;
}
} // namespace chatterino

View file

@ -30,6 +30,7 @@ public:
const std::string &getUserID(const std::string &username);
EmoteManager &getEmoteManager();
WindowManager &getWindowManager();
// Special channels
const std::shared_ptr<twitch::TwitchChannel> whispersChannel;

View file

@ -8,6 +8,7 @@
#include "ui_accountpopupform.h"
#include "util/distancebetweenpoints.hpp"
#include "widgets/chatwidget.hpp"
#include "windowmanager.hpp"
#include <QDebug>
#include <QDesktopServices>
@ -25,8 +26,9 @@ using namespace chatterino::messages;
namespace chatterino {
namespace widgets {
ChannelView::ChannelView(BaseWidget *parent)
ChannelView::ChannelView(WindowManager &windowManager, BaseWidget *parent)
: BaseWidget(parent)
, windowManager(windowManager)
, scrollBar(this)
, userPopupWidget(std::shared_ptr<Channel>())
{
@ -44,6 +46,9 @@ ChannelView::ChannelView(BaseWidget *parent)
this->layoutMessages();
});
this->repaintGifsConnection =
windowManager.repaintGifs.connect([&] { this->updateGifEmotes(); });
}
ChannelView::~ChannelView()

View file

@ -83,7 +83,7 @@ class ChannelView : public BaseWidget
Q_OBJECT
public:
explicit ChannelView(BaseWidget *parent = 0);
explicit ChannelView(WindowManager &windowManager, BaseWidget *parent = 0);
~ChannelView();
void updateGifEmotes();
@ -117,6 +117,8 @@ private:
QRect rect;
};
WindowManager &windowManager;
void detachChannel();
void drawMessages(QPainter &painter);
@ -149,6 +151,7 @@ private:
boost::signals2::connection messageAppendedConnection;
boost::signals2::connection messageRemovedConnection;
boost::signals2::connection repaintGifsConnection;
private slots:
void wordTypeMaskChanged()

View file

@ -52,8 +52,8 @@ ChatWidget::ChatWidget(ChannelManager &_channelManager, NotebookPage *parent)
, channel(_channelManager.emptyChannel)
, vbox(this)
, header(this)
, view(this)
, input(this, _channelManager.getEmoteManager())
, view(_channelManager.getWindowManager(), this)
, input(this, _channelManager.getEmoteManager(), _channelManager.getWindowManager())
{
this->vbox.setSpacing(0);
this->vbox.setMargin(1);
@ -87,7 +87,7 @@ ChatWidget::ChatWidget(ChannelManager &_channelManager, NotebookPage *parent)
ChatWidget::~ChatWidget()
{
channelNameUpdated("");
this->channelNameUpdated("");
}
std::shared_ptr<Channel> ChatWidget::getChannel() const

View file

@ -13,10 +13,12 @@
namespace chatterino {
namespace widgets {
ChatWidgetInput::ChatWidgetInput(ChatWidget *_chatWidget, EmoteManager &emoteManager)
ChatWidgetInput::ChatWidgetInput(ChatWidget *_chatWidget, EmoteManager &emoteManager,
WindowManager &windowManager)
: BaseWidget(_chatWidget)
, chatWidget(_chatWidget)
, emoteManager(emoteManager)
, windowManager(windowManager)
, emotesLabel(this)
{
this->setMaximumHeight(150);
@ -47,7 +49,8 @@ ChatWidgetInput::ChatWidgetInput(ChatWidget *_chatWidget, EmoteManager &emoteMan
connect(&this->emotesLabel, &RippleEffectLabel::clicked, [this] {
if (this->emotePopup == nullptr) {
this->emotePopup = new EmotePopup(this->colorScheme, this->emoteManager);
this->emotePopup =
new EmotePopup(this->colorScheme, this->emoteManager, this->windowManager);
}
this->emotePopup->resize(300, 500);

View file

@ -26,7 +26,7 @@ class ChatWidgetInput : public BaseWidget
Q_OBJECT
public:
ChatWidgetInput(ChatWidget *_chatWidget, EmoteManager &);
ChatWidgetInput(ChatWidget *_chatWidget, EmoteManager &, WindowManager &);
~ChatWidgetInput();
protected:
@ -39,6 +39,7 @@ private:
ChatWidget *const chatWidget;
EmotePopup *emotePopup = nullptr;
EmoteManager &emoteManager;
WindowManager &windowManager;
boost::signals2::connection textLengthVisibleChangedConnection;
QHBoxLayout hbox;

View file

@ -11,7 +11,8 @@ using namespace chatterino::messages;
namespace chatterino {
namespace widgets {
EmotePopup::EmotePopup(ColorScheme &colorScheme, EmoteManager &emoteManager)
EmotePopup::EmotePopup(ColorScheme &colorScheme, EmoteManager &emoteManager,
WindowManager &windowManager)
: BaseWidget(colorScheme, 0)
, emoteManager(emoteManager)
{
@ -19,7 +20,7 @@ EmotePopup::EmotePopup(ColorScheme &colorScheme, EmoteManager &emoteManager)
this->setLayout(layout);
layout->setMargin(0);
view = new ChannelView(this);
view = new ChannelView(windowManager, this);
layout->addWidget(view);
}

View file

@ -11,7 +11,7 @@ namespace widgets {
class EmotePopup : public BaseWidget
{
public:
explicit EmotePopup(ColorScheme &, EmoteManager &);
explicit EmotePopup(ColorScheme &, EmoteManager &, WindowManager &);
void loadChannel(std::shared_ptr<Channel> channel);

View file

@ -108,23 +108,6 @@ void MainWindow::repaintVisibleChatWidgets(Channel *channel)
}
}
void MainWindow::repaintGifEmotes()
{
auto *page = this->notebook.getSelectedPage();
if (page == nullptr) {
return;
}
const std::vector<ChatWidget *> &widgets = page->getChatWidgets();
for (auto it = widgets.begin(); it != widgets.end(); ++it) {
ChatWidget *widget = *it;
widget->updateGifEmotes();
}
}
void MainWindow::load(const boost::property_tree::ptree &tree)
{
this->notebook.load(tree);

View file

@ -32,7 +32,6 @@ public:
void layoutVisibleChatWidgets(Channel *channel = nullptr);
void repaintVisibleChatWidgets(Channel *channel = nullptr);
void repaintGifEmotes();
void load(const boost::property_tree::ptree &tree);
boost::property_tree::ptree save();

View file

@ -41,9 +41,7 @@ void WindowManager::repaintVisibleChatWidgets(Channel *channel)
void WindowManager::repaintGifEmotes()
{
if (this->mainWindow != nullptr) {
this->mainWindow->repaintGifEmotes();
}
this->repaintGifs();
}
// void WindowManager::updateAll()

View file

@ -30,6 +30,8 @@ public:
void load();
void save();
boost::signals2::signal<void()> repaintGifs;
private:
std::mutex windowMutex;