Update Settings and Signals version (#3398)
Co-authored-by: zneix <zneix@zneix.eu>
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -134,7 +134,6 @@ private:
|
||||
#endif
|
||||
|
||||
pajlada::Signals::SignalHolder connections_;
|
||||
std::vector<pajlada::Signals::ScopedConnection> managedConnections_;
|
||||
|
||||
friend class BaseWidget;
|
||||
};
|
||||
|
||||
@@ -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] {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -83,7 +83,7 @@ LastRunCrashDialog::LastRunCrashDialog()
|
||||
// };
|
||||
|
||||
// updateUpdateLabel();
|
||||
// this->managedConnect(updateManager.statusUpdated,
|
||||
// this->signalHolder_.managedConnect(updateManager.statusUpdated,
|
||||
// [updateUpdateLabel](auto) mutable {
|
||||
// postToThread([updateUpdateLabel]() mutable { updateUpdateLabel();
|
||||
// });
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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,26 +595,25 @@ 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_ =
|
||||
std::make_unique<pajlada::Signals::ScopedConnection>(
|
||||
this->channel_->messageAppended.connect([this, hasMessages](
|
||||
auto message, auto) {
|
||||
if (!checkMessageUserName(this->userName_, message))
|
||||
return;
|
||||
|
||||
this->refreshConnection_ = this->channel_->messageAppended.connect(
|
||||
[this, hasMessages](auto message, auto) {
|
||||
if (!checkMessageUserName(this->userName_, message))
|
||||
return;
|
||||
|
||||
if (hasMessages)
|
||||
{
|
||||
// display message in ChannelView
|
||||
this->ui_.latestMessages->channel()->addMessage(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
// The ChannelView is currently hidden, so manually refresh
|
||||
// and display the latest messages
|
||||
this->updateLatestMessages();
|
||||
}
|
||||
});
|
||||
if (hasMessages)
|
||||
{
|
||||
// display message in ChannelView
|
||||
this->ui_.latestMessages->channel()->addMessage(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
// The ChannelView is currently hidden, so manually refresh
|
||||
// and display the latest messages
|
||||
this->updateLatestMessages();
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
void UserInfoPopup::updateUserData()
|
||||
|
||||
@@ -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_;
|
||||
|
||||
|
||||
@@ -184,34 +184,35 @@ void ChannelView::initializeScrollbar()
|
||||
|
||||
void ChannelView::initializeSignals()
|
||||
{
|
||||
this->connections_.push_back(
|
||||
getApp()->windows->wordFlagsChanged.connect([this] {
|
||||
this->queueLayout();
|
||||
this->update();
|
||||
}));
|
||||
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->queueUpdate();
|
||||
}));
|
||||
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,87 +598,87 @@ 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](MessagePtr &message,
|
||||
boost::optional<MessageFlags> overridingFlags) {
|
||||
if (this->shouldIncludeMessage(message))
|
||||
this->channelConnections_.managedConnect(
|
||||
underlyingChannel->messageAppended,
|
||||
[this](MessagePtr &message,
|
||||
boost::optional<MessageFlags> overridingFlags) {
|
||||
if (this->shouldIncludeMessage(message))
|
||||
{
|
||||
if (this->channel_->lastDate_ != QDate::currentDate())
|
||||
{
|
||||
if (this->channel_->lastDate_ != QDate::currentDate())
|
||||
{
|
||||
this->channel_->lastDate_ = QDate::currentDate();
|
||||
auto msg = makeSystemMessage(
|
||||
QLocale().toString(QDate::currentDate(),
|
||||
QLocale::LongFormat),
|
||||
QTime(0, 0));
|
||||
this->channel_->addMessage(msg);
|
||||
}
|
||||
// When the message was received in the underlyingChannel,
|
||||
// logging will be handled. Prevent duplications.
|
||||
if (overridingFlags)
|
||||
{
|
||||
overridingFlags.get().set(MessageFlag::DoNotLog);
|
||||
}
|
||||
else
|
||||
{
|
||||
overridingFlags = MessageFlags(message->flags);
|
||||
overridingFlags.get().set(MessageFlag::DoNotLog);
|
||||
}
|
||||
|
||||
this->channel_->addMessage(message, overridingFlags);
|
||||
this->channel_->lastDate_ = QDate::currentDate();
|
||||
auto msg = makeSystemMessage(
|
||||
QLocale().toString(QDate::currentDate(),
|
||||
QLocale::LongFormat),
|
||||
QTime(0, 0));
|
||||
this->channel_->addMessage(msg);
|
||||
}
|
||||
// When the message was received in the underlyingChannel,
|
||||
// logging will be handled. Prevent duplications.
|
||||
if (overridingFlags)
|
||||
{
|
||||
overridingFlags.get().set(MessageFlag::DoNotLog);
|
||||
}
|
||||
else
|
||||
{
|
||||
overridingFlags = MessageFlags(message->flags);
|
||||
overridingFlags.get().set(MessageFlag::DoNotLog);
|
||||
}
|
||||
}));
|
||||
|
||||
this->channelConnections_.push_back(
|
||||
underlyingChannel->messagesAddedAtStart.connect(
|
||||
[this](std::vector<MessagePtr> &messages) {
|
||||
std::vector<MessagePtr> filtered;
|
||||
std::copy_if(messages.begin(), messages.end(),
|
||||
std::back_inserter(filtered),
|
||||
[this](MessagePtr msg) {
|
||||
return this->shouldIncludeMessage(msg);
|
||||
});
|
||||
this->channel_->addMessage(message, overridingFlags);
|
||||
}
|
||||
});
|
||||
|
||||
if (!filtered.empty())
|
||||
this->channel_->addMessagesAtStart(filtered);
|
||||
}));
|
||||
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) {
|
||||
return this->shouldIncludeMessage(msg);
|
||||
});
|
||||
|
||||
this->channelConnections_.push_back(
|
||||
underlyingChannel->messageReplaced.connect(
|
||||
[this](size_t index, MessagePtr replacement) {
|
||||
if (this->shouldIncludeMessage(replacement))
|
||||
this->channel_->replaceMessage(index, replacement);
|
||||
}));
|
||||
if (!filtered.empty())
|
||||
this->channel_->addMessagesAtStart(filtered);
|
||||
});
|
||||
|
||||
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](std::vector<MessagePtr> &messages) {
|
||||
this->messageAddedAtStart(messages);
|
||||
}));
|
||||
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->messageRemoveFromStart(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->liveStatusChanged.invoke();
|
||||
}));
|
||||
this->channelConnections_.managedConnect(
|
||||
tc->liveStatusChanged, [this]() {
|
||||
this->liveStatusChanged.invoke();
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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_;
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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),
|
||||
|
||||
@@ -15,8 +15,7 @@ public:
|
||||
NotificationPage();
|
||||
|
||||
private:
|
||||
QComboBox *createToastReactionComboBox(
|
||||
std::vector<pajlada::Signals::ScopedConnection> managedConnections);
|
||||
QComboBox *createToastReactionComboBox();
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -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) {
|
||||
w->setValue(value);
|
||||
});
|
||||
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);
|
||||
|
||||
@@ -75,7 +75,7 @@ public:
|
||||
protected:
|
||||
SettingsDialogTab *tab_;
|
||||
pajlada::Signals::NoArgSignal onCancel_;
|
||||
std::vector<pajlada::Signals::ScopedConnection> managedConnections_;
|
||||
pajlada::Signals::SignalHolder managedConnections_;
|
||||
};
|
||||
|
||||
} // namespace chatterino
|
||||
|
||||
@@ -175,7 +175,7 @@ Split::Split(QWidget *parent)
|
||||
this->input_->show();
|
||||
}
|
||||
},
|
||||
this->managedConnections_);
|
||||
this->signalHolder_);
|
||||
|
||||
this->header_->updateModerationModeIcon();
|
||||
this->overlay_->hide();
|
||||
@@ -183,29 +183,29 @@ Split::Split(QWidget *parent)
|
||||
this->setSizePolicy(QSizePolicy::MinimumExpanding,
|
||||
QSizePolicy::MinimumExpanding);
|
||||
|
||||
this->managedConnect(modifierStatusChanged, [this](Qt::KeyboardModifiers
|
||||
status) {
|
||||
if ((status ==
|
||||
showSplitOverlayModifiers /*|| status == showAddSplitRegions*/) &&
|
||||
this->isMouseOver_)
|
||||
{
|
||||
this->overlay_->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->overlay_->hide();
|
||||
}
|
||||
this->signalHolder_.managedConnect(
|
||||
modifierStatusChanged, [this](Qt::KeyboardModifiers status) {
|
||||
if ((status ==
|
||||
showSplitOverlayModifiers /*|| status == showAddSplitRegions*/) &&
|
||||
this->isMouseOver_)
|
||||
{
|
||||
this->overlay_->show();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->overlay_->hide();
|
||||
}
|
||||
|
||||
if (getSettings()->pauseChatModifier.getEnum() != Qt::NoModifier &&
|
||||
status == getSettings()->pauseChatModifier.getEnum())
|
||||
{
|
||||
this->view_->pause(PauseReason::KeyboardModifier);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->view_->unpause(PauseReason::KeyboardModifier);
|
||||
}
|
||||
});
|
||||
if (getSettings()->pauseChatModifier.getEnum() != Qt::NoModifier &&
|
||||
status == getSettings()->pauseChatModifier.getEnum())
|
||||
{
|
||||
this->view_->pause(PauseReason::KeyboardModifier);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->view_->unpause(PauseReason::KeyboardModifier);
|
||||
}
|
||||
});
|
||||
|
||||
this->input_->ui_.textEdit->focused.connect([this] {
|
||||
this->focused.invoke();
|
||||
@@ -250,12 +250,13 @@ Split::Split(QWidget *parent)
|
||||
[this](const bool &val) {
|
||||
this->setAcceptDrops(val);
|
||||
},
|
||||
this->managedConnections_);
|
||||
this->signalHolder_);
|
||||
this->addShortcuts();
|
||||
this->managedConnect(getApp()->hotkeys->onItemsUpdated, [this]() {
|
||||
this->clearShortcuts();
|
||||
this->addShortcuts();
|
||||
});
|
||||
this->signalHolder_.managedConnect(getApp()->hotkeys->onItemsUpdated,
|
||||
[this]() {
|
||||
this->clearShortcuts();
|
||||
this->addShortcuts();
|
||||
});
|
||||
}
|
||||
|
||||
void Split::addShortcuts()
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -41,39 +41,40 @@ SplitContainer::SplitContainer(Notebook *parent)
|
||||
{
|
||||
this->refreshTabTitle();
|
||||
|
||||
this->managedConnect(Split::modifierStatusChanged, [this](auto modifiers) {
|
||||
this->layout();
|
||||
this->signalHolder_.managedConnect(
|
||||
Split::modifierStatusChanged, [this](auto modifiers) {
|
||||
this->layout();
|
||||
|
||||
if (modifiers == showResizeHandlesModifiers)
|
||||
{
|
||||
for (auto &handle : this->resizeHandles_)
|
||||
if (modifiers == showResizeHandlesModifiers)
|
||||
{
|
||||
handle->show();
|
||||
handle->raise();
|
||||
for (auto &handle : this->resizeHandles_)
|
||||
{
|
||||
handle->show();
|
||||
handle->raise();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto &handle : this->resizeHandles_)
|
||||
else
|
||||
{
|
||||
handle->hide();
|
||||
for (auto &handle : this->resizeHandles_)
|
||||
{
|
||||
handle->hide();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (modifiers == showSplitOverlayModifiers)
|
||||
{
|
||||
this->setCursor(Qt::PointingHandCursor);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->unsetCursor();
|
||||
}
|
||||
});
|
||||
if (modifiers == showSplitOverlayModifiers)
|
||||
{
|
||||
this->setCursor(Qt::PointingHandCursor);
|
||||
}
|
||||
else
|
||||
{
|
||||
this->unsetCursor();
|
||||
}
|
||||
});
|
||||
|
||||
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();
|
||||
});
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
@@ -204,9 +204,10 @@ SplitHeader::SplitHeader(Split *_split)
|
||||
this->handleChannelChanged();
|
||||
});
|
||||
|
||||
this->managedConnect(getApp()->accounts->twitch.currentUserChanged, [this] {
|
||||
this->updateModerationModeIcon();
|
||||
});
|
||||
this->managedConnections_.managedConnect(
|
||||
getApp()->accounts->twitch.currentUserChanged, [this] {
|
||||
this->updateModerationModeIcon();
|
||||
});
|
||||
|
||||
auto _ = [this](const auto &, const auto &) {
|
||||
this->updateChannelText();
|
||||
@@ -302,19 +303,19 @@ void SplitHeader::initializeLayout()
|
||||
});
|
||||
|
||||
// update moderation button when items changed
|
||||
this->managedConnect(getSettings()->moderationActions.delayedItemsChanged,
|
||||
[this] {
|
||||
if (getSettings()->moderationActions.empty())
|
||||
{
|
||||
if (this->split_->getModerationMode())
|
||||
this->split_->setModerationMode(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this->split_->getModerationMode())
|
||||
this->split_->setModerationMode(true);
|
||||
}
|
||||
});
|
||||
this->managedConnections_.managedConnect(
|
||||
getSettings()->moderationActions.delayedItemsChanged, [this] {
|
||||
if (getSettings()->moderationActions.empty())
|
||||
{
|
||||
if (this->split_->getModerationMode())
|
||||
this->split_->setModerationMode(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this->split_->getModerationMode())
|
||||
this->split_->setModerationMode(true);
|
||||
}
|
||||
});
|
||||
|
||||
getSettings()->customURIScheme.connect(
|
||||
[this] {
|
||||
@@ -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();
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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, [=] {
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user