(#976) Make currentPreviewImage shareable between ChannelView-s

This commit is contained in:
rexim 2019-06-12 00:22:26 +07:00
parent e1a901aa98
commit 3f4d3ce14a
2 changed files with 9 additions and 6 deletions

View file

@ -105,6 +105,8 @@ namespace {
}
} // namespace
ImagePtr ChannelView::currentPreviewImage = nullptr;
ChannelView::ChannelView(BaseWidget *parent)
: BaseWidget(parent)
, scrollBar_(new Scrollbar(this))
@ -313,11 +315,13 @@ void ChannelView::queueUpdate()
// this->repaint();
auto tooltipWidget = TooltipWidget::getInstance();
if (this->currentPreviewImage) {
auto pixmap = this->currentPreviewImage->pixmap();
if (ChannelView::currentPreviewImage) {
auto pixmap = ChannelView::currentPreviewImage->pixmap();
if (pixmap) {
tooltipWidget->setImage(*pixmap);
}
} else {
tooltipWidget->clearImage();
}
this->update();
@ -1228,10 +1232,9 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
{
auto emoteElement = dynamic_cast<const EmoteElement*>(&hoverLayoutElement->getCreator());
if (emoteElement && getSettings()->emotesTooltipPreview.getValue()) {
this->currentPreviewImage = emoteElement->getEmote()->images.getImage(3.0);
ChannelView::currentPreviewImage = emoteElement->getEmote()->images.getImage(3.0);
} else {
this->currentPreviewImage = nullptr;
tooltipWidget->clearImage();
ChannelView::currentPreviewImage = nullptr;
}
tooltipWidget->moveTo(this, event->globalPos());

View file

@ -210,7 +210,7 @@ private:
static constexpr int leftPadding = 8;
static constexpr int scrollbarPadding = 8;
ImagePtr currentPreviewImage = nullptr;
static ImagePtr currentPreviewImage;
private slots:
void wordFlagsChanged()