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; return this->emoteManager;
} }
WindowManager &ChannelManager::getWindowManager()
{
return this->windowManager;
}
} // namespace chatterino } // namespace chatterino

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -11,7 +11,7 @@ namespace widgets {
class EmotePopup : public BaseWidget class EmotePopup : public BaseWidget
{ {
public: public:
explicit EmotePopup(ColorScheme &, EmoteManager &); explicit EmotePopup(ColorScheme &, EmoteManager &, WindowManager &);
void loadChannel(std::shared_ptr<Channel> channel); 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) void MainWindow::load(const boost::property_tree::ptree &tree)
{ {
this->notebook.load(tree); this->notebook.load(tree);

View file

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

View file

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

View file

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