Skip to content

Commit

Permalink
Merge branch 'Chatterino:master' into fix/channel-points-crash
Browse files Browse the repository at this point in the history
  • Loading branch information
iProdigy authored Nov 5, 2023
2 parents 9d0626e + 7d145e3 commit 8e4b4f6
Show file tree
Hide file tree
Showing 8 changed files with 73 additions and 31 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unversioned

- Major: Allow use of Twitch follower emotes in other channels if subscribed. (#4922)
- Minor: Migrate to the new Get Channel Followers Helix endpoint, fixing follower count not showing up in usercards. (#4809)
- Minor: The account switcher is now styled to match your theme. (#4817)
- Minor: Add an invisible resize handle to the bottom of frameless user info popups and reply thread popups. (#4795)
Expand All @@ -24,6 +25,8 @@
- Bugfix: Fixed the input completion popup from disappearing when clicking on it on Windows and macOS. (#4876)
- Bugfix: Fixed double-click text selection moving its position with each new message. (#4898)
- Bugfix: Fixed an issue where notifications on Windows would contain no or an old avatar. (#4899)
- Bugfix: Fixed headers of tables in the settings switching to bold text when selected. (#4913)
- Bugfix: Fixed tooltips appearing too large and/or away from the cursor. (#4920)
- Bugfix: Fixed a crash when clicking `More messages below` button in a usercard and closing it quickly. (#4933)
- Bugfix: Fixed occasional crash for channel point redemptions with text input. (#4942)
- Dev: Change clang-format from v14 to v16. (#4929)
Expand Down
38 changes: 34 additions & 4 deletions src/providers/twitch/TwitchAccount.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -264,11 +264,32 @@ void TwitchAccount::loadUserstateEmotes(std::weak_ptr<Channel> weakChannel)
[this, weakChannel](QJsonArray emoteSetArray) {
auto emoteData = this->emotes_.access();
auto localEmoteData = this->localEmotes_.access();
for (auto emoteSet_ : emoteSetArray)

std::unordered_set<QString> subscriberChannelIDs;
std::vector<IvrEmoteSet> ivrEmoteSets;
ivrEmoteSets.reserve(emoteSetArray.size());

for (auto emoteSet : emoteSetArray)
{
auto emoteSet = std::make_shared<EmoteSet>();
IvrEmoteSet ivrEmoteSet(emoteSet.toObject());
if (!ivrEmoteSet.tier.isNull())
{
subscriberChannelIDs.insert(ivrEmoteSet.channelId);
}
ivrEmoteSets.emplace_back(ivrEmoteSet);
}

for (const auto &emoteSet : emoteData->emoteSets)
{
if (emoteSet->subscriber)
{
subscriberChannelIDs.insert(emoteSet->channelID);
}
}

IvrEmoteSet ivrEmoteSet(emoteSet_.toObject());
for (const auto &ivrEmoteSet : ivrEmoteSets)
{
auto emoteSet = std::make_shared<EmoteSet>();

QString setKey = ivrEmoteSet.setId;
emoteSet->key = setKey;
Expand All @@ -285,8 +306,15 @@ void TwitchAccount::loadUserstateEmotes(std::weak_ptr<Channel> weakChannel)
continue;
}

emoteSet->channelID = ivrEmoteSet.channelId;
emoteSet->channelName = ivrEmoteSet.login;
emoteSet->text = ivrEmoteSet.displayName;
emoteSet->subscriber = !ivrEmoteSet.tier.isNull();

// NOTE: If a user does not have a subscriber emote set, but a follower emote set, this logic will be wrong
// However, that's not a realistic problem.
bool haveSubscriberSetForChannel =
subscriberChannelIDs.contains(ivrEmoteSet.channelId);

for (const auto &emoteObj : ivrEmoteSet.emotes)
{
Expand All @@ -302,7 +330,9 @@ void TwitchAccount::loadUserstateEmotes(std::weak_ptr<Channel> weakChannel)
getApp()->emotes->twitch.getOrCreateEmote(id, code);

// Follower emotes can be only used in their origin channel
if (ivrEmote.emoteType == "FOLLOWER")
// unless the user is subscribed, then they can be used anywhere.
if (ivrEmote.emoteType == "FOLLOWER" &&
!haveSubscriberSetForChannel)
{
emoteSet->local = true;

Expand Down
2 changes: 2 additions & 0 deletions src/providers/twitch/TwitchAccount.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ class TwitchAccount : public Account
struct EmoteSet {
QString key;
QString channelName;
QString channelID;
QString text;
bool subscriber{false};
bool local{false};
std::vector<TwitchEmote> emotes;
};
Expand Down
6 changes: 0 additions & 6 deletions src/singletons/WindowManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,6 @@ WindowManager::WindowManager()
QObject::connect(this->saveTimer, &QTimer::timeout, [] {
getApp()->windows->save();
});

this->miscUpdateTimer_.start(100);

QObject::connect(&this->miscUpdateTimer_, &QTimer::timeout, [this] {
this->miscUpdate.invoke();
});
}

WindowManager::~WindowManager() = default;
Expand Down
5 changes: 0 additions & 5 deletions src/singletons/WindowManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,6 @@ class WindowManager final : public Singleton

pajlada::Signals::NoArgSignal wordFlagsChanged;

// This signal fires every 100ms and can be used to trigger random things that require a recheck.
// It is currently being used by the "Tooltip Preview Image" system to recheck if an image is ready to be rendered.
pajlada::Signals::NoArgSignal miscUpdate;

pajlada::Signals::Signal<Split *> selectSplit;
pajlada::Signals::Signal<SplitContainer *> selectSplitContainer;
pajlada::Signals::Signal<const MessagePtr &> scrollToMessageSignal;
Expand Down Expand Up @@ -159,7 +155,6 @@ class WindowManager final : public Singleton
pajlada::SettingListener wordFlagsListener_;

QTimer *saveTimer;
QTimer miscUpdateTimer_;

friend class Window; // this is for selectedWindow_
};
Expand Down
5 changes: 5 additions & 0 deletions src/widgets/TooltipEntryWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,11 @@ bool TooltipEntryWidget::refreshPixmap()
this->displayImage_->setPixmap(pixmap->scaled(this->customImgWidth_,
this->customImgHeight_,
Qt::KeepAspectRatio));
if (this->displayImage_->size() !=
QSize{this->customImgWidth_, this->customImgHeight_})
{
this->adjustSize();
}
}
else
{
Expand Down
44 changes: 28 additions & 16 deletions src/widgets/TooltipWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,35 +37,46 @@ TooltipWidget::TooltipWidget(BaseWidget *parent)
});
this->updateFont();

auto windows = getApp()->windows;
auto *windows = getApp()->windows;
this->connections_.managedConnect(windows->gifRepaintRequested, [this] {
if (!this->isVisible())
{
return;
}

for (int i = 0; i < this->visibleEntries_; ++i)
{
auto entry = this->entryAt(i);
auto *entry = this->entryAt(i);
if (entry && entry->animated())
{
entry->refreshPixmap();
}
}
});

this->connections_.managedConnect(windows->miscUpdate, [this] {
bool needSizeAdjustment = false;
for (int i = 0; i < this->visibleEntries_; ++i)
{
auto entry = this->entryAt(i);
if (entry->hasImage() && entry->attemptRefresh())
this->connections_.managedConnect(
windows->layoutRequested, [this](auto *chan) {
if (chan != nullptr || !this->isVisible())
{
bool successfullyUpdated = entry->refreshPixmap();
needSizeAdjustment |= successfullyUpdated;
return;
}
}

if (needSizeAdjustment)
{
this->adjustSize();
}
});
bool needSizeAdjustment = false;
for (int i = 0; i < this->visibleEntries_; ++i)
{
auto *entry = this->entryAt(i);
if (entry->hasImage() && entry->attemptRefresh())
{
bool successfullyUpdated = entry->refreshPixmap();
needSizeAdjustment |= successfullyUpdated;
}
}

if (needSizeAdjustment)
{
this->adjustSize();
}
});
}

void TooltipWidget::setOne(const TooltipEntry &entry, TooltipStyle style)
Expand Down Expand Up @@ -101,6 +112,7 @@ void TooltipWidget::set(const std::vector<TooltipEntry> &entries,
entryWidget->setImageScale(entry.customWidth, entry.customHeight);
}
}
this->adjustSize();
}

void TooltipWidget::setVisibleEntries(int n)
Expand Down
1 change: 1 addition & 0 deletions src/widgets/helper/EditableModelView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ EditableModelView::EditableModelView(QAbstractTableModel *model, bool movable)
this->tableView_->setDragDropOverwriteMode(false);
this->tableView_->setDefaultDropAction(Qt::DropAction::MoveAction);
this->tableView_->verticalHeader()->setVisible(false);
this->tableView_->horizontalHeader()->setSectionsClickable(false);

// create layout
QVBoxLayout *vbox = new QVBoxLayout(this);
Expand Down

0 comments on commit 8e4b4f6

Please sign in to comment.