2017-12-23 22:17:38 +01:00
|
|
|
#include "tooltipwidget.hpp"
|
2017-12-31 00:50:07 +01:00
|
|
|
#include "singletons/thememanager.hpp"
|
|
|
|
#include "singletons/fontmanager.hpp"
|
2017-12-23 22:17:38 +01:00
|
|
|
|
|
|
|
#include <QStyle>
|
|
|
|
#include <QVBoxLayout>
|
|
|
|
|
|
|
|
namespace chatterino {
|
|
|
|
namespace widgets {
|
|
|
|
|
|
|
|
TooltipWidget::TooltipWidget(BaseWidget *parent)
|
|
|
|
: BaseWidget(parent)
|
|
|
|
, displayText(new QLabel())
|
|
|
|
{
|
2017-12-23 23:24:35 +01:00
|
|
|
QColor black(0, 0, 0);
|
|
|
|
QColor white(255, 255, 255);
|
2017-12-23 22:17:38 +01:00
|
|
|
|
|
|
|
QPalette palette;
|
2017-12-23 23:24:35 +01:00
|
|
|
palette.setColor(QPalette::WindowText, white);
|
|
|
|
palette.setColor(QPalette::Background, black);
|
2017-12-23 22:17:38 +01:00
|
|
|
this->setPalette(palette);
|
2018-01-07 23:47:08 +01:00
|
|
|
this->displayText->setStyleSheet("color: #ffffff");
|
2017-12-23 22:17:38 +01:00
|
|
|
this->setWindowOpacity(0.8);
|
2017-12-31 22:58:35 +01:00
|
|
|
this->setFont(singletons::FontManager::getInstance().getFont(singletons::FontManager::Type::MediumSmall,
|
2017-12-23 23:24:35 +01:00
|
|
|
this->getDpiMultiplier()));
|
2017-12-23 22:17:38 +01:00
|
|
|
|
|
|
|
this->setAttribute(Qt::WA_ShowWithoutActivating);
|
|
|
|
this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
|
|
|
|
|
|
|
|
displayText->setAlignment(Qt::AlignHCenter);
|
2018-01-07 23:47:08 +01:00
|
|
|
displayText->setText("lmao xD");
|
2017-12-23 22:17:38 +01:00
|
|
|
auto layout = new QVBoxLayout();
|
2017-12-23 23:24:35 +01:00
|
|
|
layout->setContentsMargins(10, 5, 10, 5);
|
2017-12-23 22:17:38 +01:00
|
|
|
layout->addWidget(displayText);
|
|
|
|
this->setLayout(layout);
|
|
|
|
|
2017-12-31 22:58:35 +01:00
|
|
|
singletons::FontManager::getInstance().fontChanged.connect([this] {
|
|
|
|
this->setFont(singletons::FontManager::getInstance().getFont(singletons::FontManager::Type::MediumSmall,
|
2017-12-23 23:24:35 +01:00
|
|
|
this->getDpiMultiplier()));
|
2017-12-23 22:17:38 +01:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
void TooltipWidget::setText(QString text)
|
|
|
|
{
|
|
|
|
this->displayText->setText(text);
|
|
|
|
}
|
|
|
|
|
|
|
|
void TooltipWidget::moveTo(QPoint point)
|
|
|
|
{
|
|
|
|
point.rx() += 16;
|
|
|
|
point.ry() += 16;
|
|
|
|
this->move(point);
|
|
|
|
}
|
|
|
|
|
|
|
|
} // namespace widgets
|
|
|
|
} // namespace chatterino
|