mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-21 22:24:07 +01:00
made the code actually compile
This commit is contained in:
parent
9d8edc4ae0
commit
fc758846f6
6 changed files with 60 additions and 30 deletions
|
@ -1 +1 @@
|
||||||
Subproject commit 89f767a5ed2ea5724a4bf5b6170365e5d069634a
|
Subproject commit 2fa3adf42da988dc2a34b9b625654aa08e906d4f
|
|
@ -2,6 +2,7 @@
|
||||||
#include "debug/log.hpp"
|
#include "debug/log.hpp"
|
||||||
#include "singletons/emotemanager.hpp"
|
#include "singletons/emotemanager.hpp"
|
||||||
#include "singletons/ircmanager.hpp"
|
#include "singletons/ircmanager.hpp"
|
||||||
|
#include "singletons/settingsmanager.hpp"
|
||||||
#include "twitch/twitchmessagebuilder.hpp"
|
#include "twitch/twitchmessagebuilder.hpp"
|
||||||
#include "util/urlfetch.hpp"
|
#include "util/urlfetch.hpp"
|
||||||
|
|
||||||
|
|
|
@ -170,7 +170,7 @@ MessagePtr TwitchMessageBuilder::parse()
|
||||||
textColor = MessageColor(MessageColor::Link);
|
textColor = MessageColor(MessageColor::Link);
|
||||||
}
|
}
|
||||||
|
|
||||||
this->emplace<TextElement>(string, textColor) //
|
this->emplace<TextElement>(string, MessageElement::Text, textColor) //
|
||||||
->setLink(link);
|
->setLink(link);
|
||||||
} else { // is emoji
|
} else { // is emoji
|
||||||
this->emplace<EmoteElement>(emoteData, EmoteElement::EmojiAll);
|
this->emplace<EmoteElement>(emoteData, EmoteElement::EmojiAll);
|
||||||
|
|
|
@ -150,12 +150,12 @@ void BaseWindow::addTitleBarButton(const QString &text)
|
||||||
|
|
||||||
void BaseWindow::changeEvent(QEvent *)
|
void BaseWindow::changeEvent(QEvent *)
|
||||||
{
|
{
|
||||||
TooltipWidget::getInstance()->hide();
|
// TooltipWidget::getInstance()->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
void BaseWindow::leaveEvent(QEvent *)
|
void BaseWindow::leaveEvent(QEvent *)
|
||||||
{
|
{
|
||||||
TooltipWidget::getInstance()->hide();
|
// TooltipWidget::getInstance()->hide();
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef USEWINSDK
|
#ifdef USEWINSDK
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#include "singletons/fontmanager.hpp"
|
#include "singletons/fontmanager.hpp"
|
||||||
#include "singletons/thememanager.hpp"
|
#include "singletons/thememanager.hpp"
|
||||||
|
|
||||||
|
#include <QDebug>
|
||||||
#include <QDesktopWidget>
|
#include <QDesktopWidget>
|
||||||
#include <QStyle>
|
#include <QStyle>
|
||||||
#include <QVBoxLayout>
|
#include <QVBoxLayout>
|
||||||
|
@ -13,33 +14,40 @@ TooltipWidget::TooltipWidget(BaseWidget *parent)
|
||||||
: BaseWindow(parent)
|
: BaseWindow(parent)
|
||||||
, displayText(new QLabel())
|
, displayText(new QLabel())
|
||||||
{
|
{
|
||||||
QColor black(0, 0, 0);
|
this->setStyleSheet("color: #fff; background: #000");
|
||||||
QColor white(255, 255, 255);
|
|
||||||
|
|
||||||
QPalette palette;
|
|
||||||
palette.setColor(QPalette::WindowText, white);
|
|
||||||
palette.setColor(QPalette::Background, black);
|
|
||||||
this->setPalette(palette);
|
|
||||||
this->displayText->setStyleSheet("color: #ffffff");
|
|
||||||
this->setWindowOpacity(0.8);
|
this->setWindowOpacity(0.8);
|
||||||
this->setFont(singletons::FontManager::getInstance().getFont(
|
this->updateFont();
|
||||||
singletons::FontManager::Type::MediumSmall, this->getDpiMultiplier()));
|
|
||||||
|
|
||||||
this->setAttribute(Qt::WA_ShowWithoutActivating);
|
this->setAttribute(Qt::WA_ShowWithoutActivating);
|
||||||
this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint |
|
this->setWindowFlags(Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint |
|
||||||
Qt::X11BypassWindowManagerHint);
|
Qt::X11BypassWindowManagerHint | Qt::BypassWindowManagerHint |
|
||||||
|
Qt::SubWindow);
|
||||||
|
|
||||||
displayText->setAlignment(Qt::AlignHCenter);
|
displayText->setAlignment(Qt::AlignHCenter);
|
||||||
displayText->setText("lmao xD");
|
displayText->setText("tooltip text");
|
||||||
auto layout = new QVBoxLayout();
|
auto layout = new QVBoxLayout();
|
||||||
layout->setContentsMargins(10, 5, 10, 5);
|
layout->setContentsMargins(10, 5, 10, 5);
|
||||||
layout->addWidget(displayText);
|
layout->addWidget(displayText);
|
||||||
this->setLayout(layout);
|
this->setLayout(layout);
|
||||||
|
|
||||||
singletons::FontManager::getInstance().fontChanged.connect([this] {
|
this->fontChangedConnection =
|
||||||
this->setFont(singletons::FontManager::getInstance().getFont(
|
singletons::FontManager::getInstance().fontChanged.connect([this] { this->updateFont(); });
|
||||||
singletons::FontManager::Type::MediumSmall, this->getDpiMultiplier()));
|
}
|
||||||
});
|
|
||||||
|
TooltipWidget::~TooltipWidget()
|
||||||
|
{
|
||||||
|
this->fontChangedConnection.disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TooltipWidget::dpiMultiplierChanged(float, float)
|
||||||
|
{
|
||||||
|
this->updateFont();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TooltipWidget::updateFont()
|
||||||
|
{
|
||||||
|
this->setFont(singletons::FontManager::getInstance().getFont(
|
||||||
|
singletons::FontManager::Type::MediumSmall, this->getDpiMultiplier()));
|
||||||
}
|
}
|
||||||
|
|
||||||
void TooltipWidget::setText(QString text)
|
void TooltipWidget::setText(QString text)
|
||||||
|
@ -51,7 +59,9 @@ void TooltipWidget::moveTo(QWidget *parent, QPoint point)
|
||||||
{
|
{
|
||||||
point.rx() += 16;
|
point.rx() += 16;
|
||||||
point.ry() += 16;
|
point.ry() += 16;
|
||||||
|
|
||||||
this->move(point);
|
this->move(point);
|
||||||
|
this->moveIntoDesktopRect(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
void TooltipWidget::resizeEvent(QResizeEvent *)
|
void TooltipWidget::resizeEvent(QResizeEvent *)
|
||||||
|
@ -64,22 +74,34 @@ void TooltipWidget::moveIntoDesktopRect(QWidget *parent)
|
||||||
QDesktopWidget *desktop = QApplication::desktop();
|
QDesktopWidget *desktop = QApplication::desktop();
|
||||||
|
|
||||||
QRect s = desktop->screenGeometry(parent);
|
QRect s = desktop->screenGeometry(parent);
|
||||||
QRect w = this->geometry();
|
QPoint p = this->pos();
|
||||||
|
|
||||||
if (w.left() < s.left()) {
|
if (p.x() < s.left()) {
|
||||||
w.moveLeft(s.left());
|
p.setX(s.left());
|
||||||
}
|
}
|
||||||
if (w.right() < s.right()) {
|
if (p.y() < s.top()) {
|
||||||
w.moveRight(s.right());
|
p.setY(s.top());
|
||||||
}
|
}
|
||||||
if (w.top() < s.top()) {
|
if (p.x() + this->width() > s.right()) {
|
||||||
w.moveTop(s.top());
|
p.setX(s.right() - this->width());
|
||||||
}
|
}
|
||||||
if (w.bottom() < s.bottom()) {
|
if (p.y() + this->height() > s.bottom()) {
|
||||||
w.moveBottom(s.bottom());
|
p.setY(s.bottom() - this->height());
|
||||||
}
|
}
|
||||||
|
|
||||||
this->setGeometry(w);
|
if (p != this->pos()) {
|
||||||
|
this->move(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TooltipWidget::changeEvent(QEvent *)
|
||||||
|
{
|
||||||
|
// clear parents event
|
||||||
|
}
|
||||||
|
|
||||||
|
void TooltipWidget::leaveEvent(QEvent *)
|
||||||
|
{
|
||||||
|
// clear parents event
|
||||||
}
|
}
|
||||||
} // namespace widgets
|
} // namespace widgets
|
||||||
} // namespace chatterino
|
} // namespace chatterino
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
|
|
||||||
#include <QLabel>
|
#include <QLabel>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
|
#include <pajlada/signals/signal.hpp>
|
||||||
|
|
||||||
namespace chatterino {
|
namespace chatterino {
|
||||||
namespace widgets {
|
namespace widgets {
|
||||||
|
@ -12,6 +13,7 @@ class TooltipWidget : public BaseWindow
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
TooltipWidget(BaseWidget *parent = nullptr);
|
TooltipWidget(BaseWidget *parent = nullptr);
|
||||||
|
~TooltipWidget();
|
||||||
|
|
||||||
void setText(QString text);
|
void setText(QString text);
|
||||||
void moveTo(QWidget *widget, QPoint point);
|
void moveTo(QWidget *widget, QPoint point);
|
||||||
|
@ -27,11 +29,16 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void resizeEvent(QResizeEvent *) override;
|
virtual void resizeEvent(QResizeEvent *) override;
|
||||||
|
virtual void changeEvent(QEvent *) override;
|
||||||
|
virtual void leaveEvent(QEvent *) override;
|
||||||
|
virtual void dpiMultiplierChanged(float, float) override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QLabel *displayText;
|
QLabel *displayText;
|
||||||
|
pajlada::Signals::Connection fontChangedConnection;
|
||||||
|
|
||||||
void moveIntoDesktopRect(QWidget *parent);
|
void moveIntoDesktopRect(QWidget *parent);
|
||||||
|
void updateFont();
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace widgets
|
} // namespace widgets
|
||||||
|
|
Loading…
Reference in a new issue