Update Settings and Signals version (#3398)
Co-authored-by: zneix <zneix@zneix.eu>
This commit is contained in:
@@ -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