Update Settings and Signals version (#3398)

Co-authored-by: zneix <zneix@zneix.eu>
This commit is contained in:
pajlada 2021-12-19 15:57:56 +01:00 committed by GitHub
parent 60ff82f2de
commit 51ece94f58
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
39 changed files with 282 additions and 268 deletions

View file

@ -65,6 +65,7 @@
- Bugfix: Fixed Chatterino attempting to send empty messages (#3355)
- Bugfix: Fixed IRC highlights not triggering sounds or alerts properly. (#3368)
- Bugfix: Fixed IRC /kick command crashing if parameters were malformed. (#3382)
- Bugfix: Fixed crash that would occur if the user tries to modify the currently connected IRC connection. (#3398)
- Bugfix: Fixed a crash that could occur on certain Linux systems when toggling the Always on Top flag. (#3385)
- Bugfix: Fixed zero-width emotes sometimes wrapping lines incorrectly. (#3389)
- Bugfix: Fixed using special chars in Windows username breaking the storage of custom commands (#3397)

@ -1 +1 @@
Subproject commit 7cf8431d644332107a51a46c1e3de70e64692f0c
Subproject commit 04792d853c7f83c9d7ab4df00279442a658d3be3

@ -1 +1 @@
Subproject commit baf5bb04bd13b090e405e0447c89a811f7e23ddc
Subproject commit 25e4ec3b8d6ea94a5e65a26e7cfcbbce3b87c5d6

View file

@ -222,13 +222,10 @@ TextLayoutElement::TextLayoutElement(MessageElement &_creator, QString &_text,
void TextLayoutElement::listenToLinkChanges()
{
this->managedConnections_.emplace_back(
static_cast<TextElement &>(this->getCreator())
.linkChanged.connect([this]() {
// log("Old link: {}", this->getCreator().getLink().value);
// log("This link: {}", this->getLink().value);
this->managedConnections_.managedConnect(
static_cast<TextElement &>(this->getCreator()).linkChanged, [this]() {
this->setLink(this->getCreator().getLink());
}));
});
}
void TextLayoutElement::addCopyTextToString(QString &str, int from,

View file

@ -11,6 +11,8 @@
#include "messages/MessageColor.hpp"
#include "messages/MessageElement.hpp"
#include <pajlada/signals/signalholder.hpp>
class QPainter;
namespace chatterino {
@ -114,7 +116,7 @@ protected:
FontStyle style_;
float scale_;
std::vector<pajlada::Signals::ScopedConnection> managedConnections_;
pajlada::Signals::SignalHolder managedConnections_;
};
// TEXT ICON

View file

@ -47,7 +47,8 @@ AbstractIrcServer::AbstractIrcServer()
&Communi::IrcConnection::connected, this, [this] {
this->onWriteConnected(this->writeConnection_.get());
});
this->writeConnection_->connectionLost.connect([this](bool timeout) {
this->connections_.managedConnect(
this->writeConnection_->connectionLost, [this](bool timeout) {
qCDebug(chatterinoIrc)
<< "Write connection reconnect requested. Timeout:" << timeout;
this->writeConnection_->smartReconnect.invoke();
@ -75,7 +76,8 @@ AbstractIrcServer::AbstractIrcServer()
&Communi::IrcConnection::disconnected, this, [this] {
this->onDisconnected();
});
this->readConnection_->connectionLost.connect([this](bool timeout) {
this->connections_.managedConnect(
this->readConnection_->connectionLost, [this](bool timeout) {
qCDebug(chatterinoIrc)
<< "Read connection reconnect requested. Timeout:" << timeout;
if (timeout)
@ -217,8 +219,7 @@ ChannelPtr AbstractIrcServer::getOrAddChannel(const QString &dirtyChannelName)
}
this->channels.insert(channelName, chan);
this->connections_.emplace_back(
chan->destroyed.connect([this, channelName] {
this->connections_.managedConnect(chan->destroyed, [this, channelName] {
// fourtf: issues when the server itself is destroyed
qCDebug(chatterinoIrc) << "[AbstractIrcServer::addChannel]"
@ -229,7 +230,7 @@ ChannelPtr AbstractIrcServer::getOrAddChannel(const QString &dirtyChannelName)
{
this->readConnection_->sendRaw("PART #" + channelName);
}
}));
});
// join IRC channel
{

View file

@ -117,6 +117,12 @@ IrcConnection::IrcConnection(QObject *parent)
});
}
IrcConnection::~IrcConnection()
{
// Prematurely disconnect all QObject connections
this->disconnect();
}
void IrcConnection::open()
{
this->expectConnectionLoss_ = false;

View file

@ -13,6 +13,7 @@ class IrcConnection : public Communi::IrcConnection
{
public:
IrcConnection(QObject *parent = nullptr);
~IrcConnection() override;
// Signal to notify that we're unexpectedly no longer connected, either due
// to a connection error or if we think we've timed out. It's up to the

View file

@ -158,12 +158,14 @@ TwitchChannel::TwitchChannel(const QString &name)
{
qCDebug(chatterinoTwitch) << "[TwitchChannel" << name << "] Opened";
this->managedConnect(getApp()->accounts->twitch.currentUserChanged, [=] {
this->signalHolder_.managedConnect(
getApp()->accounts->twitch.currentUserChanged, [=] {
this->setMod(false);
});
// pubsub
this->managedConnect(getApp()->accounts->twitch.currentUserChanged, [=] {
this->signalHolder_.managedConnect(
getApp()->accounts->twitch.currentUserChanged, [=] {
this->refreshPubsub();
});
this->refreshPubsub();

View file

@ -35,9 +35,7 @@ class BttvEmotes;
class TwitchIrcServer;
class TwitchChannel : public Channel,
public ChannelChatters,
pajlada::Signals::SignalHolder
class TwitchChannel : public Channel, public ChannelChatters
{
public:
struct StreamStatus {
@ -184,6 +182,8 @@ private:
QElapsedTimer clipCreationTimer_;
bool isClipCreationInProgress{false};
pajlada::Signals::SignalHolder signalHolder_;
friend class TwitchIrcServer;
friend class TwitchMessageBuilder;
friend class IrcMessageHandler;

View file

@ -16,19 +16,19 @@ TooltipPreviewImage::TooltipPreviewImage()
{
auto windows = getApp()->windows;
this->connections_.push_back(windows->gifRepaintRequested.connect([&] {
this->connections_.managedConnect(windows->gifRepaintRequested, [&] {
if (this->image_ && this->image_->animated())
{
this->refreshTooltipWidgetPixmap();
}
}));
});
this->connections_.push_back(windows->miscUpdate.connect([&] {
this->connections_.managedConnect(windows->miscUpdate, [&] {
if (this->attemptRefresh)
{
this->refreshTooltipWidgetPixmap();
}
}));
});
}
void TooltipPreviewImage::setImage(ImagePtr image)

View file

@ -2,6 +2,8 @@
#include "messages/Image.hpp"
#include <pajlada/signals/signalholder.hpp>
namespace chatterino {
class TooltipPreviewImage
@ -21,7 +23,7 @@ private:
int imageWidth_ = 0;
int imageHeight_ = 0;
std::vector<pajlada::Signals::ScopedConnection> connections_;
pajlada::Signals::SignalHolder connections_;
// attemptRefresh is set to true in case we want to preview an image that has not loaded yet (if pixmapOrLoad fails)
bool attemptRefresh{false};

View file

@ -5,6 +5,7 @@
#include "common/FlagsEnum.hpp"
#include "common/Singleton.hpp"
#include "common/WindowDescriptors.hpp"
#include "pajlada/settings/settinglistener.hpp"
#include "widgets/splits/SplitContainer.hpp"

View file

@ -229,7 +229,7 @@ void BaseWindow::init()
0, 0, 0,
SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);
},
this->managedConnections_);
this->connections_);
});
}
#else
@ -245,7 +245,7 @@ void BaseWindow::init()
this->show();
}
},
this->managedConnections_);
this->connections_);
}
#endif
}

View file

@ -134,7 +134,6 @@ private:
#endif
pajlada::Signals::SignalHolder connections_;
std::vector<pajlada::Signals::ScopedConnection> managedConnections_;
friend class BaseWidget;
};

View file

@ -759,7 +759,7 @@ void SplitNotebook::addCustomButtons()
[settingsBtn](bool hide, auto) {
settingsBtn->setVisible(!hide);
},
this->connections_);
this->signalHolder_);
settingsBtn->setIcon(NotebookButton::Settings);
@ -774,7 +774,7 @@ void SplitNotebook::addCustomButtons()
[userBtn](bool hide, auto) {
userBtn->setVisible(!hide);
},
this->connections_);
this->signalHolder_);
userBtn->setIcon(NotebookButton::User);
QObject::connect(userBtn, &NotebookButton::leftClicked, [this, userBtn] {

View file

@ -101,7 +101,7 @@ private:
NotebookTabDirection tabDirection_ = NotebookTabDirection::Horizontal;
};
class SplitNotebook : public Notebook, pajlada::Signals::SignalHolder
class SplitNotebook : public Notebook
{
public:
SplitNotebook(Window *parent);
@ -117,8 +117,6 @@ private:
void addCustomButtons();
pajlada::Signals::SignalHolder signalHolder_;
std::vector<pajlada::Signals::ScopedConnection> connections_;
};
} // namespace chatterino

View file

@ -83,7 +83,7 @@ LastRunCrashDialog::LastRunCrashDialog()
// };
// updateUpdateLabel();
// this->managedConnect(updateManager.statusUpdated,
// this->signalHolder_.managedConnect(updateManager.statusUpdated,
// [updateUpdateLabel](auto) mutable {
// postToThread([updateUpdateLabel]() mutable { updateUpdateLabel();
// });

View file

@ -5,10 +5,13 @@
namespace chatterino {
class LastRunCrashDialog : public QDialog, pajlada::Signals::SignalHolder
class LastRunCrashDialog : public QDialog
{
public:
LastRunCrashDialog();
private:
pajlada::Signals::SignalHolder signalHolder_;
};
} // namespace chatterino

View file

@ -430,12 +430,6 @@ UserInfoPopup::UserInfoPopup(bool closeAutomatically, QWidget *parent)
this->setSizePolicy(QSizePolicy::Ignored, QSizePolicy::Policy::Ignored);
}
// remove once https://github.com/pajlada/signals/pull/10 gets merged
UserInfoPopup::~UserInfoPopup()
{
this->refreshConnection_.disconnect();
}
void UserInfoPopup::themeChangedEvent()
{
BaseWindow::themeChangedEvent();
@ -601,11 +595,10 @@ void UserInfoPopup::updateLatestMessages()
// shrink dialog in case ChannelView goes from visible to hidden
this->adjustSize();
this->refreshConnection_
.disconnect(); // remove once https://github.com/pajlada/signals/pull/10 gets merged
this->refreshConnection_ = this->channel_->messageAppended.connect(
[this, hasMessages](auto message, auto) {
this->refreshConnection_ =
std::make_unique<pajlada::Signals::ScopedConnection>(
this->channel_->messageAppended.connect([this, hasMessages](
auto message, auto) {
if (!checkMessageUserName(this->userName_, message))
return;
@ -620,7 +613,7 @@ void UserInfoPopup::updateLatestMessages()
// and display the latest messages
this->updateLatestMessages();
}
});
}));
}
void UserInfoPopup::updateUserData()

View file

@ -3,6 +3,7 @@
#include "widgets/BaseWindow.hpp"
#include "widgets/helper/ChannelView.hpp"
#include <pajlada/signals/scoped-connection.hpp>
#include <pajlada/signals/signal.hpp>
class QCheckBox;
@ -19,7 +20,6 @@ class UserInfoPopup final : public BaseWindow
public:
UserInfoPopup(bool closeAutomatically, QWidget *parent);
~UserInfoPopup();
void setData(const QString &name, const ChannelPtr &channel);
@ -43,8 +43,7 @@ private:
pajlada::Signals::NoArgSignal userStateChanged_;
// replace with ScopedConnection once https://github.com/pajlada/signals/pull/10 gets merged
pajlada::Signals::Connection refreshConnection_;
std::unique_ptr<pajlada::Signals::ScopedConnection> refreshConnection_;
std::shared_ptr<bool> hack_;

View file

@ -184,34 +184,35 @@ void ChannelView::initializeScrollbar()
void ChannelView::initializeSignals()
{
this->connections_.push_back(
getApp()->windows->wordFlagsChanged.connect([this] {
this->signalHolder_.managedConnect(getApp()->windows->wordFlagsChanged,
[this] {
this->queueLayout();
this->update();
}));
});
getSettings()->showLastMessageIndicator.connect(
[this](auto, auto) {
this->update();
},
this->connections_);
this);
connections_.push_back(getApp()->windows->gifRepaintRequested.connect([&] {
this->signalHolder_.managedConnect(getApp()->windows->gifRepaintRequested,
[&] {
this->queueUpdate();
}));
});
connections_.push_back(
getApp()->windows->layoutRequested.connect([&](Channel *channel) {
this->signalHolder_.managedConnect(
getApp()->windows->layoutRequested, [&](Channel *channel) {
if (this->isVisible() &&
(channel == nullptr || this->channel_.get() == channel))
{
this->queueLayout();
}
}));
});
connections_.push_back(getApp()->fonts->fontChanged.connect([this] {
this->signalHolder_.managedConnect(getApp()->fonts->fontChanged, [this] {
this->queueLayout();
}));
});
}
bool ChannelView::pausable() const
@ -597,8 +598,8 @@ void ChannelView::setChannel(ChannelPtr underlyingChannel)
// Use a proxy channel to keep filtered messages past the time they are removed from their origin channel
//
this->channelConnections_.push_back(
underlyingChannel->messageAppended.connect(
this->channelConnections_.managedConnect(
underlyingChannel->messageAppended,
[this](MessagePtr &message,
boost::optional<MessageFlags> overridingFlags) {
if (this->shouldIncludeMessage(message))
@ -626,58 +627,58 @@ void ChannelView::setChannel(ChannelPtr underlyingChannel)
this->channel_->addMessage(message, overridingFlags);
}
}));
});
this->channelConnections_.push_back(
underlyingChannel->messagesAddedAtStart.connect(
this->channelConnections_.managedConnect(
underlyingChannel->messagesAddedAtStart,
[this](std::vector<MessagePtr> &messages) {
std::vector<MessagePtr> filtered;
std::copy_if(messages.begin(), messages.end(),
std::back_inserter(filtered),
[this](MessagePtr msg) {
std::back_inserter(filtered), [this](MessagePtr msg) {
return this->shouldIncludeMessage(msg);
});
if (!filtered.empty())
this->channel_->addMessagesAtStart(filtered);
}));
});
this->channelConnections_.push_back(
underlyingChannel->messageReplaced.connect(
this->channelConnections_.managedConnect(
underlyingChannel->messageReplaced,
[this](size_t index, MessagePtr replacement) {
if (this->shouldIncludeMessage(replacement))
this->channel_->replaceMessage(index, replacement);
}));
});
//
// Standard channel connections
//
// on new message
this->channelConnections_.push_back(this->channel_->messageAppended.connect(
this->channelConnections_.managedConnect(
this->channel_->messageAppended,
[this](MessagePtr &message,
boost::optional<MessageFlags> overridingFlags) {
this->messageAppended(message, std::move(overridingFlags));
}));
});
this->channelConnections_.push_back(
this->channel_->messagesAddedAtStart.connect(
this->channelConnections_.managedConnect(
this->channel_->messagesAddedAtStart,
[this](std::vector<MessagePtr> &messages) {
this->messageAddedAtStart(messages);
}));
});
// on message removed
this->channelConnections_.push_back(
this->channel_->messageRemovedFromStart.connect(
[this](MessagePtr &message) {
this->channelConnections_.managedConnect(
this->channel_->messageRemovedFromStart, [this](MessagePtr &message) {
this->messageRemoveFromStart(message);
}));
});
// on message replaced
this->channelConnections_.push_back(this->channel_->messageReplaced.connect(
this->channelConnections_.managedConnect(
this->channel_->messageReplaced,
[this](size_t index, MessagePtr replacement) {
this->messageReplaced(index, replacement);
}));
});
auto snapshot = underlyingChannel->getMessageSnapshot();
@ -715,9 +716,10 @@ void ChannelView::setChannel(ChannelPtr underlyingChannel)
// Notifications
if (auto tc = dynamic_cast<TwitchChannel *>(underlyingChannel.get()))
{
this->connections_.push_back(tc->liveStatusChanged.connect([this]() {
this->channelConnections_.managedConnect(
tc->liveStatusChanged, [this]() {
this->liveStatusChanged.invoke();
}));
});
}
}

View file

@ -238,8 +238,10 @@ private:
LimitedQueue<MessageLayoutPtr> messages_;
std::vector<pajlada::Signals::ScopedConnection> connections_;
std::vector<pajlada::Signals::ScopedConnection> channelConnections_;
pajlada::Signals::SignalHolder signalHolder_;
// channelConnections_ will be cleared when the underlying channel of the channelview changes
pajlada::Signals::SignalHolder channelConnections_;
std::unordered_set<std::shared_ptr<MessageLayout>> messagesOnScreen_;

View file

@ -7,7 +7,7 @@
#include <QMenu>
#include <QPropertyAnimation>
#include <pajlada/settings/setting.hpp>
#include <pajlada/signals/connection.hpp>
#include <pajlada/signals/signalholder.hpp>
namespace chatterino {
@ -105,7 +105,7 @@ private:
QMenu menu_;
std::vector<pajlada::Signals::ScopedConnection> managedConnections_;
pajlada::Signals::SignalHolder managedConnections_;
};
} // namespace chatterino

View file

@ -2,6 +2,7 @@
#include <QDebug>
#include <boost/variant.hpp>
#include <pajlada/signals/signalholder.hpp>
#include "Application.hpp"
#include "common/ChatterinoSetting.hpp"
#include "singletons/WindowManager.hpp"
@ -218,7 +219,7 @@ private:
QVBoxLayout *navigationLayout_;
std::vector<Group> groups_;
std::vector<pajlada::Signals::ScopedConnection> managedConnections_;
pajlada::Signals::SignalHolder managedConnections_;
};
} // namespace chatterino

View file

@ -55,9 +55,7 @@ NotificationPage::NotificationPage()
// implementation of custom combobox done
// because addComboBox only can handle strings-settings
// int setting for the ToastReaction is desired
openIn
.append(this->createToastReactionComboBox(
this->managedConnections_))
openIn.append(this->createToastReactionComboBox())
->setSizePolicy(QSizePolicy::Maximum,
QSizePolicy::Preferred);
}
@ -118,8 +116,7 @@ NotificationPage::NotificationPage()
}
}
}
QComboBox *NotificationPage::createToastReactionComboBox(
std::vector<pajlada::Signals::ScopedConnection> managedConnections)
QComboBox *NotificationPage::createToastReactionComboBox()
{
QComboBox *toastReactionOptions = new QComboBox();
@ -135,7 +132,7 @@ QComboBox *NotificationPage::createToastReactionComboBox(
[toastReactionOptions](const int &index, auto) {
toastReactionOptions->setCurrentIndex(index);
},
managedConnections);
this->managedConnections_);
QObject::connect(toastReactionOptions,
QOverload<int>::of(&QComboBox::currentIndexChanged),

View file

@ -15,8 +15,7 @@ public:
NotificationPage();
private:
QComboBox *createToastReactionComboBox(
std::vector<pajlada::Signals::ScopedConnection> managedConnections);
QComboBox *createToastReactionComboBox();
};
} // namespace chatterino

View file

@ -157,9 +157,11 @@ QSpinBox *SettingsPage::createSpinBox(pajlada::Settings::Setting<int> &setting,
w->setMinimum(min);
w->setMaximum(max);
setting.connect([w](const int &value, auto) {
setting.connect(
[w](const int &value, auto) {
w->setValue(value);
});
},
this->managedConnections_);
QObject::connect(w, QOverload<int>::of(&QSpinBox::valueChanged),
[&setting](int value) {
setting.setValue(value);

View file

@ -75,7 +75,7 @@ public:
protected:
SettingsDialogTab *tab_;
pajlada::Signals::NoArgSignal onCancel_;
std::vector<pajlada::Signals::ScopedConnection> managedConnections_;
pajlada::Signals::SignalHolder managedConnections_;
};
} // namespace chatterino

View file

@ -175,7 +175,7 @@ Split::Split(QWidget *parent)
this->input_->show();
}
},
this->managedConnections_);
this->signalHolder_);
this->header_->updateModerationModeIcon();
this->overlay_->hide();
@ -183,8 +183,8 @@ Split::Split(QWidget *parent)
this->setSizePolicy(QSizePolicy::MinimumExpanding,
QSizePolicy::MinimumExpanding);
this->managedConnect(modifierStatusChanged, [this](Qt::KeyboardModifiers
status) {
this->signalHolder_.managedConnect(
modifierStatusChanged, [this](Qt::KeyboardModifiers status) {
if ((status ==
showSplitOverlayModifiers /*|| status == showAddSplitRegions*/) &&
this->isMouseOver_)
@ -250,9 +250,10 @@ Split::Split(QWidget *parent)
[this](const bool &val) {
this->setAcceptDrops(val);
},
this->managedConnections_);
this->signalHolder_);
this->addShortcuts();
this->managedConnect(getApp()->hotkeys->onItemsUpdated, [this]() {
this->signalHolder_.managedConnect(getApp()->hotkeys->onItemsUpdated,
[this]() {
this->clearShortcuts();
this->addShortcuts();
});

View file

@ -31,7 +31,7 @@ class SelectChannelDialog;
// - Responsible for rendering and handling user text input
//
// Each sub-element has a reference to the parent Chat Widget
class Split : public BaseWidget, pajlada::Signals::SignalHolder
class Split : public BaseWidget
{
friend class SplitInput;
@ -152,8 +152,6 @@ private:
pajlada::Signals::Connection indirectChannelChangedConnection_;
pajlada::Signals::SignalHolder signalHolder_;
std::vector<pajlada::Signals::ScopedConnection> managedConnections_;
public slots:
void addSibling();
void deleteFromContainer();

View file

@ -41,7 +41,8 @@ SplitContainer::SplitContainer(Notebook *parent)
{
this->refreshTabTitle();
this->managedConnect(Split::modifierStatusChanged, [this](auto modifiers) {
this->signalHolder_.managedConnect(
Split::modifierStatusChanged, [this](auto modifiers) {
this->layout();
if (modifiers == showResizeHandlesModifiers)
@ -73,7 +74,7 @@ SplitContainer::SplitContainer(Notebook *parent)
this->setCursor(Qt::PointingHandCursor);
this->setAcceptDrops(true);
this->managedConnect(this->overlay_.dragEnded, [this]() {
this->signalHolder_.managedConnect(this->overlay_.dragEnded, [this]() {
this->isDragging_ = false;
this->layout();
});

View file

@ -29,7 +29,7 @@ class Notebook;
// inside but it doesn't expose any of it publicly.
//
class SplitContainer final : public BaseWidget, pajlada::Signals::SignalHolder
class SplitContainer final : public BaseWidget
{
Q_OBJECT
@ -260,6 +260,8 @@ private:
std::unordered_map<Split *, pajlada::Signals::SignalHolder>
connectionsPerSplit_;
pajlada::Signals::SignalHolder signalHolder_;
bool isDragging_ = false;
};

View file

@ -204,7 +204,8 @@ SplitHeader::SplitHeader(Split *_split)
this->handleChannelChanged();
});
this->managedConnect(getApp()->accounts->twitch.currentUserChanged, [this] {
this->managedConnections_.managedConnect(
getApp()->accounts->twitch.currentUserChanged, [this] {
this->updateModerationModeIcon();
});
@ -302,8 +303,8 @@ void SplitHeader::initializeLayout()
});
// update moderation button when items changed
this->managedConnect(getSettings()->moderationActions.delayedItemsChanged,
[this] {
this->managedConnections_.managedConnect(
getSettings()->moderationActions.delayedItemsChanged, [this] {
if (getSettings()->moderationActions.empty())
{
if (this->split_->getModerationMode())
@ -519,7 +520,8 @@ std::unique_ptr<QMenu> SplitHeader::createChatModeMenu()
menu->addAction(setR9k);
menu->addAction(setFollowers);
this->managedConnections_.push_back(this->modeUpdateRequested_.connect(
this->managedConnections_.managedConnect(
this->modeUpdateRequested_,
[this, setSub, setEmote, setSlow, setR9k, setFollowers]() {
auto twitchChannel =
dynamic_cast<TwitchChannel *>(this->split_->getChannel().get());
@ -536,7 +538,7 @@ std::unique_ptr<QMenu> SplitHeader::createChatModeMenu()
setEmote->setChecked(roomModes->emoteOnly);
setSub->setChecked(roomModes->submode);
setFollowers->setChecked(roomModes->followerOnly != -1);
}));
});
auto toggle = [this](const QString &command, QAction *action) mutable {
this->split_->getChannel().get()->sendMessage(
@ -652,10 +654,10 @@ void SplitHeader::handleChannelChanged()
auto channel = this->split_->getChannel();
if (auto twitchChannel = dynamic_cast<TwitchChannel *>(channel.get()))
{
this->channelConnections_.emplace_back(
twitchChannel->liveStatusChanged.connect([this]() {
this->channelConnections_.managedConnect(
twitchChannel->liveStatusChanged, [this]() {
this->updateChannelText();
}));
});
}
}

View file

@ -19,7 +19,7 @@ class EffectLabel;
class Label;
class Split;
class SplitHeader final : public BaseWidget, pajlada::Signals::SignalHolder
class SplitHeader final : public BaseWidget
{
Q_OBJECT
@ -81,8 +81,8 @@ private:
// signals
pajlada::Signals::NoArgSignal modeUpdateRequested_;
std::vector<pajlada::Signals::ScopedConnection> managedConnections_;
std::vector<pajlada::Signals::ScopedConnection> channelConnections_;
pajlada::Signals::SignalHolder managedConnections_;
pajlada::Signals::SignalHolder channelConnections_;
public slots:
void reloadChannelEmotes();

View file

@ -99,10 +99,10 @@ void SplitInput::initLayout()
QObject::connect(this->ui_.textEdit, &QTextEdit::textChanged, this,
&SplitInput::onTextChanged);
this->managedConnections_.push_back(app->fonts->fontChanged.connect([=]() {
this->managedConnections_.managedConnect(app->fonts->fontChanged, [=]() {
this->ui_.textEdit->setFont(
app->fonts->getFont(FontStyle::ChatMedium, this->scale()));
}));
});
// open emote popup
QObject::connect(this->ui_.emoteButton, &EffectLabel::leftClicked, [=] {

View file

@ -69,7 +69,7 @@ private:
QHBoxLayout *hbox;
} ui_;
std::vector<pajlada::Signals::ScopedConnection> managedConnections_;
pajlada::Signals::SignalHolder managedConnections_;
QStringList prevMsg_;
QString currMsg_;
int prevIndex_ = 0;

View file

@ -75,7 +75,7 @@ SplitOverlay::SplitOverlay(Split *parent)
up->setCursor(Qt::PointingHandCursor);
down->setCursor(Qt::PointingHandCursor);
this->managedConnect(this->scaleChanged, [=](float _scale) {
this->signalHolder_.managedConnect(this->scaleChanged, [=](float _scale) {
int a = int(_scale * 30);
QSize size(a, a);

View file

@ -10,7 +10,7 @@ namespace chatterino {
class Split;
class SplitOverlay : public BaseWidget, pajlada::Signals::SignalHolder
class SplitOverlay : public BaseWidget
{
public:
explicit SplitOverlay(Split *parent = nullptr);
@ -52,6 +52,8 @@ private:
QPushButton *right_;
QPushButton *down_;
pajlada::Signals::SignalHolder signalHolder_;
friend class ButtonEventFilter;
};