Extract TooltipWidget updating into a separate class

This commit is contained in:
rexim
2019-06-12 01:03:04 +07:00
parent 3f4d3ce14a
commit 3838157d82
5 changed files with 56 additions and 16 deletions
+4 -14
View File
@@ -23,6 +23,7 @@
#include "widgets/dialogs/UserInfoPopup.hpp"
#include "widgets/helper/EffectLabel.hpp"
#include "widgets/splits/Split.hpp"
#include "TooltipPreviewImage.hpp"
#include <QClipboard>
#include <QDebug>
@@ -105,8 +106,6 @@ namespace {
}
} // namespace
ImagePtr ChannelView::currentPreviewImage = nullptr;
ChannelView::ChannelView(BaseWidget *parent)
: BaseWidget(parent)
, scrollBar_(new Scrollbar(this))
@@ -314,16 +313,6 @@ void ChannelView::queueUpdate()
// this->repaint();
auto tooltipWidget = TooltipWidget::getInstance();
if (ChannelView::currentPreviewImage) {
auto pixmap = ChannelView::currentPreviewImage->pixmap();
if (pixmap) {
tooltipWidget->setImage(*pixmap);
}
} else {
tooltipWidget->clearImage();
}
this->update();
// this->updateTimer.start();
@@ -1230,11 +1219,12 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
}
else
{
auto tooltipPreviewImage = TooltipPreviewImage::getInstance();
auto emoteElement = dynamic_cast<const EmoteElement*>(&hoverLayoutElement->getCreator());
if (emoteElement && getSettings()->emotesTooltipPreview.getValue()) {
ChannelView::currentPreviewImage = emoteElement->getEmote()->images.getImage(3.0);
tooltipPreviewImage->setImage(emoteElement->getEmote()->images.getImage(3.0));
} else {
ChannelView::currentPreviewImage = nullptr;
tooltipPreviewImage->setImage(nullptr);
}
tooltipWidget->moveTo(this, event->globalPos());