mirror of
https://github.com/Chatterino/chatterino2.git
synced 2024-11-13 19:49:51 +01:00
fixed emotes popup emotes
This commit is contained in:
parent
56a7b05103
commit
d33adff5c9
|
@ -168,7 +168,8 @@ SOURCES += \
|
||||||
src/widgets/settingspages/ignoremessagespage.cpp \
|
src/widgets/settingspages/ignoremessagespage.cpp \
|
||||||
src/widgets/settingspages/specialchannelspage.cpp \
|
src/widgets/settingspages/specialchannelspage.cpp \
|
||||||
src/widgets/settingspages/keyboardsettingspage.cpp \
|
src/widgets/settingspages/keyboardsettingspage.cpp \
|
||||||
src/widgets/helper/titlebarbutton.cpp
|
src/widgets/helper/titlebarbutton.cpp \
|
||||||
|
src/widgets/helper/label.cpp
|
||||||
|
|
||||||
HEADERS += \
|
HEADERS += \
|
||||||
src/precompiled_header.hpp \
|
src/precompiled_header.hpp \
|
||||||
|
@ -277,7 +278,8 @@ HEADERS += \
|
||||||
src/widgets/settingspages/specialchannelspage.hpp \
|
src/widgets/settingspages/specialchannelspage.hpp \
|
||||||
src/widgets/settingspages/keyboardsettings.hpp \
|
src/widgets/settingspages/keyboardsettings.hpp \
|
||||||
src/widgets/settingspages/keyboardsettingspage.hpp \
|
src/widgets/settingspages/keyboardsettingspage.hpp \
|
||||||
src/widgets/helper/titlebarbutton.hpp
|
src/widgets/helper/titlebarbutton.hpp \
|
||||||
|
src/widgets/helper/label.hpp
|
||||||
|
|
||||||
RESOURCES += \
|
RESOURCES += \
|
||||||
resources/resources.qrc
|
resources/resources.qrc
|
||||||
|
|
|
@ -78,7 +78,6 @@ EmoteElement::EmoteElement(const util::EmoteData &_data, MessageElement::Flags f
|
||||||
{
|
{
|
||||||
if (_data.isValid()) {
|
if (_data.isValid()) {
|
||||||
this->setTooltip(data.image1x->getTooltip());
|
this->setTooltip(data.image1x->getTooltip());
|
||||||
qDebug() << "valid xDDDDDDDDD" << _data.image1x->getName();
|
|
||||||
this->textElement = new TextElement(_data.image1x->getName(), MessageElement::Misc);
|
this->textElement = new TextElement(_data.image1x->getName(), MessageElement::Misc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -93,7 +92,7 @@ EmoteElement::~EmoteElement()
|
||||||
void EmoteElement::addToContainer(MessageLayoutContainer &container, MessageElement::Flags _flags)
|
void EmoteElement::addToContainer(MessageLayoutContainer &container, MessageElement::Flags _flags)
|
||||||
{
|
{
|
||||||
if (_flags & this->getFlags()) {
|
if (_flags & this->getFlags()) {
|
||||||
if (_flags & this->getFlags() & MessageElement::EmoteImages) {
|
if (_flags & MessageElement::EmoteImages) {
|
||||||
if (!this->data.isValid()) {
|
if (!this->data.isValid()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,10 +246,10 @@ void IrcManager::privateMessageReceived(Communi::IrcPrivateMessage *message)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
auto xd = message->content();
|
// auto xd = message->content();
|
||||||
auto xd2 = message->toData();
|
// auto xd2 = message->toData();
|
||||||
|
|
||||||
debug::Log("HEHE: {}", xd2.toStdString());
|
// debug::Log("HEHE: {}", xd2.toStdString());
|
||||||
|
|
||||||
messages::MessageParseArgs args;
|
messages::MessageParseArgs args;
|
||||||
|
|
||||||
|
|
|
@ -59,24 +59,23 @@ void ThemeManager::actuallyUpdate(double hue, double multiplier)
|
||||||
QColor themeColor = QColor::fromHslF(hue, 0.5, 0.5);
|
QColor themeColor = QColor::fromHslF(hue, 0.5, 0.5);
|
||||||
QColor themeColorNoSat = QColor::fromHslF(hue, 0, 0.5);
|
QColor themeColorNoSat = QColor::fromHslF(hue, 0, 0.5);
|
||||||
|
|
||||||
//#ifdef USEWINSDK
|
qreal sat = 0.1;
|
||||||
// isLightTabs = isLight;
|
// 0.05;
|
||||||
// QColor tabFg = isLight ? "#000" : "#fff";
|
|
||||||
// this->windowBg = isLight ? "#fff" : "#444";
|
|
||||||
|
|
||||||
//#else
|
|
||||||
isLightTabs = true;
|
|
||||||
QColor tabFg = isLightTabs ? "#000" : "#fff";
|
|
||||||
this->windowBg = "#fff";
|
|
||||||
|
|
||||||
//#endif
|
|
||||||
|
|
||||||
qreal sat = 0.05;
|
|
||||||
|
|
||||||
auto getColor = [multiplier](double h, double s, double l, double a = 1.0) {
|
auto getColor = [multiplier](double h, double s, double l, double a = 1.0) {
|
||||||
return QColor::fromHslF(h, s, ((l - 0.5) * multiplier) + 0.5, a);
|
return QColor::fromHslF(h, s, ((l - 0.5) * multiplier) + 0.5, a);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//#ifdef USEWINSDK
|
||||||
|
// isLightTabs = isLight;
|
||||||
|
// QColor tabFg = isLight ? "#000" : "#fff";
|
||||||
|
// this->windowBg = isLight ? "#fff" : getColor(0, sat, 0.9);
|
||||||
|
//#else
|
||||||
|
isLightTabs = true;
|
||||||
|
QColor tabFg = isLightTabs ? "#000" : "#fff";
|
||||||
|
this->windowBg = "#fff";
|
||||||
|
//#endif
|
||||||
|
|
||||||
// Ubuntu style
|
// Ubuntu style
|
||||||
// TODO: add setting for this
|
// TODO: add setting for this
|
||||||
// TabText = QColor(210, 210, 210);
|
// TabText = QColor(210, 210, 210);
|
||||||
|
|
|
@ -457,7 +457,7 @@ bool TwitchMessageBuilder::tryAppendEmote(QString &emoteString)
|
||||||
singletons::EmoteManager &emoteManager = singletons::EmoteManager::getInstance();
|
singletons::EmoteManager &emoteManager = singletons::EmoteManager::getInstance();
|
||||||
util::EmoteData emoteData;
|
util::EmoteData emoteData;
|
||||||
|
|
||||||
auto appendEmote = [=](MessageElement::Flags flags) {
|
auto appendEmote = [&](MessageElement::Flags flags) {
|
||||||
this->emplace<EmoteElement>(emoteData, flags);
|
this->emplace<EmoteElement>(emoteData, flags);
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
|
|
|
@ -247,7 +247,6 @@ bool BaseWindow::nativeEvent(const QByteArray &eventType, void *message, long *r
|
||||||
|
|
||||||
switch (msg->message) {
|
switch (msg->message) {
|
||||||
case WM_DPICHANGED: {
|
case WM_DPICHANGED: {
|
||||||
qDebug() << "dpi changed";
|
|
||||||
int dpi = HIWORD(msg->wParam);
|
int dpi = HIWORD(msg->wParam);
|
||||||
|
|
||||||
float oldScale = this->scale;
|
float oldScale = this->scale;
|
||||||
|
@ -349,8 +348,6 @@ bool BaseWindow::nativeEvent(const QByteArray &eventType, void *message, long *r
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
qDebug() << *result;
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return QWidget::nativeEvent(eventType, message, result);
|
return QWidget::nativeEvent(eventType, message, result);
|
||||||
|
|
|
@ -18,6 +18,11 @@ EmotePopup::EmotePopup(singletons::ThemeManager &themeManager)
|
||||||
this->viewEmotes = new ChannelView();
|
this->viewEmotes = new ChannelView();
|
||||||
this->viewEmojis = new ChannelView();
|
this->viewEmojis = new ChannelView();
|
||||||
|
|
||||||
|
this->viewEmotes->setOverrideFlags((MessageElement::Flags)(
|
||||||
|
MessageElement::Default | MessageElement::AlwaysShow | MessageElement::EmoteImages));
|
||||||
|
this->viewEmojis->setOverrideFlags((MessageElement::Flags)(
|
||||||
|
MessageElement::Default | MessageElement::AlwaysShow | MessageElement::EmoteImages));
|
||||||
|
|
||||||
this->viewEmotes->setEnableScrollingToBottom(false);
|
this->viewEmotes->setEnableScrollingToBottom(false);
|
||||||
this->viewEmojis->setEnableScrollingToBottom(false);
|
this->viewEmojis->setEnableScrollingToBottom(false);
|
||||||
|
|
||||||
|
@ -62,7 +67,7 @@ void EmotePopup::loadChannel(ChannelPtr _channel)
|
||||||
builder2.getMessage()->addFlags(Message::DisableCompactEmotes);
|
builder2.getMessage()->addFlags(Message::DisableCompactEmotes);
|
||||||
|
|
||||||
map.each([&](const QString &key, const util::EmoteData &value) {
|
map.each([&](const QString &key, const util::EmoteData &value) {
|
||||||
builder2.appendElement((new EmoteElement(value, MessageElement::Flags::AlwaysShow)) //
|
builder2.appendElement((new EmoteElement(value, MessageElement::Flags::AlwaysShow))
|
||||||
->setLink(Link(Link::InsertText, key)));
|
->setLink(Link(Link::InsertText, key)));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -101,7 +106,7 @@ void EmotePopup::loadEmojis()
|
||||||
builder.getMessage()->addFlags(Message::DisableCompactEmotes);
|
builder.getMessage()->addFlags(Message::DisableCompactEmotes);
|
||||||
|
|
||||||
emojis.each([this, &builder](const QString &key, const util::EmoteData &value) {
|
emojis.each([this, &builder](const QString &key, const util::EmoteData &value) {
|
||||||
builder.appendElement((new EmoteElement(value, MessageElement::Flags::AlwaysShow)) //
|
builder.appendElement((new EmoteElement(value, MessageElement::Flags::AlwaysShow))
|
||||||
->setLink(Link(Link::Type::InsertText, key)));
|
->setLink(Link(Link::Type::InsertText, key)));
|
||||||
});
|
});
|
||||||
emojiChannel->addMessage(builder.getMessage());
|
emojiChannel->addMessage(builder.getMessage());
|
||||||
|
|
|
@ -291,6 +291,16 @@ bool ChannelView::getEnableScrollingToBottom() const
|
||||||
return this->enableScrollingToBottom;
|
return this->enableScrollingToBottom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ChannelView::setOverrideFlags(boost::optional<messages::MessageElement::Flags> value)
|
||||||
|
{
|
||||||
|
this->overrideFlags = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
const boost::optional<messages::MessageElement::Flags> &ChannelView::getOverrideFlags() const
|
||||||
|
{
|
||||||
|
return this->overrideFlags;
|
||||||
|
}
|
||||||
|
|
||||||
messages::LimitedQueueSnapshot<MessageLayoutPtr> ChannelView::getMessagesSnapshot()
|
messages::LimitedQueueSnapshot<MessageLayoutPtr> ChannelView::getMessagesSnapshot()
|
||||||
{
|
{
|
||||||
if (!this->paused) {
|
if (!this->paused) {
|
||||||
|
@ -338,7 +348,6 @@ void ChannelView::setChannel(ChannelPtr newChannel)
|
||||||
newChannel->messagesAddedAtStart.connect([this](std::vector<MessagePtr> &messages) {
|
newChannel->messagesAddedAtStart.connect([this](std::vector<MessagePtr> &messages) {
|
||||||
std::vector<MessageLayoutPtr> messageRefs;
|
std::vector<MessageLayoutPtr> messageRefs;
|
||||||
messageRefs.resize(messages.size());
|
messageRefs.resize(messages.size());
|
||||||
qDebug() << messages.size();
|
|
||||||
for (size_t i = 0; i < messages.size(); i++) {
|
for (size_t i = 0; i < messages.size(); i++) {
|
||||||
messageRefs.at(i) = MessageLayoutPtr(new MessageLayout(messages.at(i)));
|
messageRefs.at(i) = MessageLayoutPtr(new MessageLayout(messages.at(i)));
|
||||||
}
|
}
|
||||||
|
@ -455,6 +464,10 @@ void ChannelView::setSelection(const SelectionItem &start, const SelectionItem &
|
||||||
|
|
||||||
messages::MessageElement::Flags ChannelView::getFlags() const
|
messages::MessageElement::Flags ChannelView::getFlags() const
|
||||||
{
|
{
|
||||||
|
if (this->overrideFlags) {
|
||||||
|
return this->overrideFlags.get();
|
||||||
|
}
|
||||||
|
|
||||||
MessageElement::Flags flags = singletons::SettingManager::getInstance().getWordFlags();
|
MessageElement::Flags flags = singletons::SettingManager::getInstance().getWordFlags();
|
||||||
|
|
||||||
Split *split = dynamic_cast<Split *>(this->parentWidget());
|
Split *split = dynamic_cast<Split *>(this->parentWidget());
|
||||||
|
|
|
@ -38,6 +38,8 @@ public:
|
||||||
void clearSelection();
|
void clearSelection();
|
||||||
void setEnableScrollingToBottom(bool);
|
void setEnableScrollingToBottom(bool);
|
||||||
bool getEnableScrollingToBottom() const;
|
bool getEnableScrollingToBottom() const;
|
||||||
|
void setOverrideFlags(boost::optional<messages::MessageElement::Flags> value);
|
||||||
|
const boost::optional<messages::MessageElement::Flags> &getOverrideFlags() const;
|
||||||
void pause(int msecTimeout);
|
void pause(int msecTimeout);
|
||||||
void updateLastReadMessage();
|
void updateLastReadMessage();
|
||||||
|
|
||||||
|
@ -80,6 +82,7 @@ private:
|
||||||
bool messageWasAdded = false;
|
bool messageWasAdded = false;
|
||||||
bool paused = false;
|
bool paused = false;
|
||||||
QTimer pauseTimeout;
|
QTimer pauseTimeout;
|
||||||
|
boost::optional<messages::MessageElement::Flags> overrideFlags;
|
||||||
messages::MessageLayoutPtr lastReadMessage;
|
messages::MessageLayoutPtr lastReadMessage;
|
||||||
|
|
||||||
messages::LimitedQueueSnapshot<messages::MessageLayoutPtr> snapshot;
|
messages::LimitedQueueSnapshot<messages::MessageLayoutPtr> snapshot;
|
||||||
|
|
78
src/widgets/helper/label.cpp
Normal file
78
src/widgets/helper/label.cpp
Normal file
|
@ -0,0 +1,78 @@
|
||||||
|
#include "label.hpp"
|
||||||
|
#include "singletons/fontmanager.hpp"
|
||||||
|
|
||||||
|
#include <QPainter>
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
namespace widgets {
|
||||||
|
Label::Label(BaseWidget *parent)
|
||||||
|
: BaseWidget(parent)
|
||||||
|
{
|
||||||
|
singletons::FontManager::getInstance().fontChanged.connect(
|
||||||
|
[this]() { this->scaleChangedEvent(this->getScale()); });
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString &Label::getText() const
|
||||||
|
{
|
||||||
|
return this->text;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Label::setText(const QString &value)
|
||||||
|
{
|
||||||
|
this->text = value;
|
||||||
|
this->scaleChangedEvent(this->getScale());
|
||||||
|
}
|
||||||
|
|
||||||
|
FontStyle Label::getFontStyle() const
|
||||||
|
{
|
||||||
|
return this->fontStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Label::setFontStyle(FontStyle style)
|
||||||
|
{
|
||||||
|
this->fontStyle = style;
|
||||||
|
this->scaleChangedEvent(this->getScale());
|
||||||
|
}
|
||||||
|
|
||||||
|
void Label::scaleChangedEvent(float scale)
|
||||||
|
{
|
||||||
|
QFontMetrics metrics =
|
||||||
|
singletons::FontManager::getInstance().getFontMetrics(this->fontStyle, scale);
|
||||||
|
|
||||||
|
this->preferedSize = QSize(metrics.width(this->text), metrics.height());
|
||||||
|
|
||||||
|
this->updateGeometry();
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize Label::sizeHint() const
|
||||||
|
{
|
||||||
|
return this->preferedSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
QSize Label::minimumSizeHint() const
|
||||||
|
{
|
||||||
|
return this->preferedSize;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Label::paintEvent(QPaintEvent *)
|
||||||
|
{
|
||||||
|
QPainter painter(this);
|
||||||
|
painter.setFont(singletons::FontManager::getInstance().getFont(
|
||||||
|
this->fontStyle, this->getScale() / painter.device()->devicePixelRatioF()));
|
||||||
|
|
||||||
|
int width = singletons::FontManager::getInstance()
|
||||||
|
.getFontMetrics(this->fontStyle, this->getScale())
|
||||||
|
.width(this->text);
|
||||||
|
|
||||||
|
int flags = Qt::TextSingleLine;
|
||||||
|
|
||||||
|
if (this->width() < width) {
|
||||||
|
flags |= Qt::AlignLeft | Qt::AlignVCenter;
|
||||||
|
} else {
|
||||||
|
flags |= Qt::AlignCenter;
|
||||||
|
}
|
||||||
|
|
||||||
|
painter.drawText(this->rect(), flags, this->text);
|
||||||
|
}
|
||||||
|
} // namespace widgets
|
||||||
|
} // namespace chatterino
|
33
src/widgets/helper/label.hpp
Normal file
33
src/widgets/helper/label.hpp
Normal file
|
@ -0,0 +1,33 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include "singletons/fontmanager.hpp"
|
||||||
|
#include "widgets/basewidget.hpp"
|
||||||
|
|
||||||
|
namespace chatterino {
|
||||||
|
namespace widgets {
|
||||||
|
|
||||||
|
class Label : public BaseWidget
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
Label(BaseWidget *parent);
|
||||||
|
|
||||||
|
const QString &getText() const;
|
||||||
|
void setText(const QString &text);
|
||||||
|
|
||||||
|
FontStyle getFontStyle() const;
|
||||||
|
void setFontStyle(FontStyle style);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
virtual void scaleChangedEvent(float scale) override;
|
||||||
|
virtual void paintEvent(QPaintEvent *event) override;
|
||||||
|
|
||||||
|
virtual QSize sizeHint() const override;
|
||||||
|
virtual QSize minimumSizeHint() const override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
QSize preferedSize;
|
||||||
|
QString text;
|
||||||
|
FontStyle fontStyle = FontStyle::Medium;
|
||||||
|
};
|
||||||
|
} // namespace widgets
|
||||||
|
} // namespace chatterino
|
|
@ -4,6 +4,7 @@
|
||||||
#include "twitch/twitchchannel.hpp"
|
#include "twitch/twitchchannel.hpp"
|
||||||
#include "util/layoutcreator.hpp"
|
#include "util/layoutcreator.hpp"
|
||||||
#include "util/urlfetch.hpp"
|
#include "util/urlfetch.hpp"
|
||||||
|
#include "widgets/helper/label.hpp"
|
||||||
#include "widgets/split.hpp"
|
#include "widgets/split.hpp"
|
||||||
#include "widgets/splitcontainer.hpp"
|
#include "widgets/splitcontainer.hpp"
|
||||||
#include "widgets/tooltipwidget.hpp"
|
#include "widgets/tooltipwidget.hpp"
|
||||||
|
@ -47,7 +48,9 @@ SplitHeader::SplitHeader(Split *_split)
|
||||||
layout->addStretch(1);
|
layout->addStretch(1);
|
||||||
|
|
||||||
// channel name label
|
// channel name label
|
||||||
|
// auto title = layout.emplace<Label>(this).assign(&this->titleLabel);
|
||||||
auto title = layout.emplace<SignalLabel>().assign(&this->titleLabel);
|
auto title = layout.emplace<SignalLabel>().assign(&this->titleLabel);
|
||||||
|
title->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Preferred);
|
||||||
title->setMouseTracking(true);
|
title->setMouseTracking(true);
|
||||||
QObject::connect(this->titleLabel, &SignalLabel::mouseDoubleClick, this,
|
QObject::connect(this->titleLabel, &SignalLabel::mouseDoubleClick, this,
|
||||||
&SplitHeader::mouseDoubleClickEvent);
|
&SplitHeader::mouseDoubleClickEvent);
|
||||||
|
@ -141,6 +144,8 @@ void SplitHeader::scaleChangedEvent(float scale)
|
||||||
this->setFixedHeight(w);
|
this->setFixedHeight(w);
|
||||||
this->dropdownButton->setFixedWidth(w);
|
this->dropdownButton->setFixedWidth(w);
|
||||||
this->moderationButton->setFixedWidth(w);
|
this->moderationButton->setFixedWidth(w);
|
||||||
|
// this->titleLabel->setFont(
|
||||||
|
// singletons::FontManager::getInstance().getFont(FontStyle::Medium, scale));
|
||||||
}
|
}
|
||||||
|
|
||||||
void SplitHeader::updateChannelText()
|
void SplitHeader::updateChannelText()
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "widgets/basewidget.hpp"
|
#include "widgets/basewidget.hpp"
|
||||||
|
#include "widgets/helper/label.hpp"
|
||||||
#include "widgets/helper/rippleeffectlabel.hpp"
|
#include "widgets/helper/rippleeffectlabel.hpp"
|
||||||
#include "widgets/helper/signallabel.hpp"
|
#include "widgets/helper/signallabel.hpp"
|
||||||
|
|
||||||
|
@ -52,6 +53,7 @@ private:
|
||||||
boost::signals2::connection onlineStatusChangedConnection;
|
boost::signals2::connection onlineStatusChangedConnection;
|
||||||
|
|
||||||
RippleEffectButton *dropdownButton;
|
RippleEffectButton *dropdownButton;
|
||||||
|
// Label *titleLabel;
|
||||||
SignalLabel *titleLabel;
|
SignalLabel *titleLabel;
|
||||||
RippleEffectButton *moderationButton;
|
RippleEffectButton *moderationButton;
|
||||||
|
|
||||||
|
|
|
@ -248,7 +248,6 @@ void Split::layoutMessages()
|
||||||
|
|
||||||
void Split::updateGifEmotes()
|
void Split::updateGifEmotes()
|
||||||
{
|
{
|
||||||
qDebug() << "this shouldn't even exist";
|
|
||||||
this->view.queueUpdate();
|
this->view.queueUpdate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue