mirror-chatterino2/src/widgets/TooltipWidget.hpp
kornes 11fdd7ed74
ref: merge TooltipPreviewImage and TooltipWidget (#4268)
* merge TooltipPreviewImage and TooltipWidget

* changelog

* add empty line before return

* fix signalholder include

* add changelog for bugfix

* fix custom scaling issue

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
2022-12-29 16:07:46 +01:00

55 lines
1.3 KiB
C++

#pragma once
#include "messages/Image.hpp"
#include "widgets/BaseWindow.hpp"
#include <pajlada/signals/signalholder.hpp>
#include <QLabel>
#include <QWidget>
namespace chatterino {
class TooltipWidget : public BaseWindow
{
Q_OBJECT
public:
static TooltipWidget *instance();
TooltipWidget(BaseWidget *parent = nullptr);
~TooltipWidget() override = default;
void setText(QString text);
void setWordWrap(bool wrap);
void clearImage();
void setImage(ImagePtr image);
void setImageScale(int w, int h);
protected:
void showEvent(QShowEvent *) override;
void hideEvent(QHideEvent *) override;
void changeEvent(QEvent *) override;
void leaveEvent(QEvent *) override;
void themeChangedEvent() override;
void scaleChangedEvent(float) override;
void paintEvent(QPaintEvent *) override;
private:
void updateFont();
// used by WindowManager::gifRepaintRequested signal to progress frames when tooltip image is animated
bool refreshPixmap();
// set to true when tooltip image did not finish loading yet (pixmapOrLoad returned false)
bool attemptRefresh{false};
ImagePtr image_ = nullptr;
int customImgWidth = 0;
int customImgHeight = 0;
QLabel *displayImage_;
QLabel *displayText_;
pajlada::Signals::SignalHolder connections_;
};
} // namespace chatterino