2019-07-23 22:18:36 +02:00
|
|
|
#pragma once
|
|
|
|
|
2022-12-29 16:07:46 +01:00
|
|
|
#include "messages/Image.hpp"
|
2019-07-23 22:18:36 +02:00
|
|
|
#include "widgets/BaseWindow.hpp"
|
|
|
|
|
2022-12-29 16:07:46 +01:00
|
|
|
#include <pajlada/signals/signalholder.hpp>
|
2019-07-23 22:18:36 +02:00
|
|
|
#include <QLabel>
|
|
|
|
#include <QWidget>
|
|
|
|
|
2019-10-07 15:46:08 +02:00
|
|
|
namespace chatterino {
|
2019-07-23 22:18:36 +02:00
|
|
|
|
|
|
|
class TooltipWidget : public BaseWindow
|
|
|
|
{
|
|
|
|
Q_OBJECT
|
|
|
|
|
|
|
|
public:
|
2019-10-07 22:42:34 +02:00
|
|
|
static TooltipWidget *instance();
|
2019-07-23 22:18:36 +02:00
|
|
|
|
|
|
|
TooltipWidget(BaseWidget *parent = nullptr);
|
2022-12-29 16:07:46 +01:00
|
|
|
~TooltipWidget() override = default;
|
2019-07-23 22:18:36 +02:00
|
|
|
|
|
|
|
void setText(QString text);
|
|
|
|
void setWordWrap(bool wrap);
|
|
|
|
void clearImage();
|
2022-12-29 16:07:46 +01:00
|
|
|
void setImage(ImagePtr image);
|
|
|
|
void setImageScale(int w, int h);
|
2019-07-23 22:18:36 +02:00
|
|
|
|
|
|
|
protected:
|
2022-12-29 16:07:46 +01:00
|
|
|
void showEvent(QShowEvent *) override;
|
|
|
|
void hideEvent(QHideEvent *) override;
|
2019-07-23 22:18:36 +02:00
|
|
|
void changeEvent(QEvent *) override;
|
|
|
|
void leaveEvent(QEvent *) override;
|
|
|
|
void themeChangedEvent() override;
|
|
|
|
void scaleChangedEvent(float) override;
|
2019-08-21 02:37:10 +02:00
|
|
|
void paintEvent(QPaintEvent *) override;
|
2019-07-23 22:18:36 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
void updateFont();
|
|
|
|
|
2022-12-29 16:07:46 +01:00
|
|
|
// 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;
|
2019-07-23 22:18:36 +02:00
|
|
|
QLabel *displayImage_;
|
|
|
|
QLabel *displayText_;
|
2022-12-29 16:07:46 +01:00
|
|
|
pajlada::Signals::SignalHolder connections_;
|
2019-07-23 22:18:36 +02:00
|
|
|
};
|
|
|
|
|
2019-10-07 15:46:08 +02:00
|
|
|
} // namespace chatterino
|