diff --git a/lib/settings b/lib/settings index d3faa9b39..a8c167976 160000 --- a/lib/settings +++ b/lib/settings @@ -1 +1 @@ -Subproject commit d3faa9b3996e0871473b0e2b1821c93a50821f40 +Subproject commit a8c167976e907d8caa19f921d7a4984c6658a2a9 diff --git a/lib/signals b/lib/signals index 2c9c92b97..fcce2886e 160000 --- a/lib/signals +++ b/lib/signals @@ -1 +1 @@ -Subproject commit 2c9c92b971f4a1313eeb4d9daf8ea59565d3c691 +Subproject commit fcce2886e5443e88bc70228b1929d8c0e1bb641a diff --git a/src/accountmanager.cpp b/src/accountmanager.cpp index 04ec59a24..61f2105d6 100644 --- a/src/accountmanager.cpp +++ b/src/accountmanager.cpp @@ -77,7 +77,7 @@ AccountManager::AccountManager() { this->Twitch.anonymousUser.reset(new twitch::TwitchUser("justinfan64537", "", "")); - this->Twitch.currentUsername.getValueChangedSignal().connect([this](const auto &newValue) { + this->Twitch.currentUsername.connect([this](const auto &newValue, auto) { QString newUsername(QString::fromStdString(newValue)); auto user = this->Twitch.findUserByUsername(newUsername); if (user) { diff --git a/src/colorscheme.cpp b/src/colorscheme.cpp index 338f544f4..24c1c2b61 100644 --- a/src/colorscheme.cpp +++ b/src/colorscheme.cpp @@ -34,13 +34,8 @@ ColorScheme::ColorScheme(WindowManager &windowManager) { this->update(); - this->themeName.getValueChangedSignal().connect([=](const auto &) { - this->update(); // - }); - - this->themeHue.getValueChangedSignal().connect([=](const auto &) { - this->update(); // - }); + this->themeName.connectSimple([this](auto) { this->update(); }); + this->themeHue.connectSimple([this](auto) { this->update(); }); this->updated.connect([&windowManager] { windowManager.repaintVisibleChatWidgets(); // @@ -140,10 +135,10 @@ void ColorScheme::normalizeColor(QColor &color) } if (color.lightnessF() < 0.6f && color.hueF() > 0.54444 && color.hueF() < 0.83333) { - color.setHslF(color.hueF(), color.saturationF(), - color.lightnessF() + - sin((color.hueF() - 0.54444) / (0.8333 - 0.54444) * 3.14159) * - color.saturationF() * 0.2); + color.setHslF( + color.hueF(), color.saturationF(), + color.lightnessF() + sin((color.hueF() - 0.54444) / (0.8333 - 0.54444) * 3.14159) * + color.saturationF() * 0.2); } } } diff --git a/src/emotemanager.cpp b/src/emotemanager.cpp index 9ff7690b9..7c9827800 100644 --- a/src/emotemanager.cpp +++ b/src/emotemanager.cpp @@ -26,7 +26,7 @@ EmoteManager::EmoteManager() pajlada::Settings::Setting roomID( "/accounts/current/roomID", "", pajlada::Settings::SettingOption::DoNotWriteToJSON); - roomID.getValueChangedSignal().connect([this](const std::string &roomID) { + roomID.getValueChangedSignal().connect([this](const std::string &roomID, auto) { this->refreshTwitchEmotes(roomID); // }); } diff --git a/src/fontmanager.cpp b/src/fontmanager.cpp index 29f02ad95..5129ac4cc 100644 --- a/src/fontmanager.cpp +++ b/src/fontmanager.cpp @@ -9,12 +9,12 @@ FontManager::FontManager() , currentFontSize("/appearance/currentFontSize", 14) , currentFont(this->currentFontFamily.getValue().c_str(), currentFontSize.getValue()) { - this->currentFontFamily.getValueChangedSignal().connect([this](const std::string &newValue) { + this->currentFontFamily.connect([this](const std::string &newValue, auto) { this->incGeneration(); - this->currentFont.setFamily(newValue.c_str()); // + this->currentFont.setFamily(newValue.c_str()); this->fontChanged.invoke(); }); - this->currentFontSize.getValueChangedSignal().connect([this](const int &newValue) { + this->currentFontSize.connect([this](const int &newValue, auto) { this->incGeneration(); this->currentFont.setSize(newValue); this->fontChanged.invoke(); diff --git a/src/settingsmanager.cpp b/src/settingsmanager.cpp index f0ea616c3..5d89d6fd6 100644 --- a/src/settingsmanager.cpp +++ b/src/settingsmanager.cpp @@ -20,31 +20,31 @@ SettingsManager::SettingsManager() QMap>()) , highlightUserBlacklist(this->settingsItems, "highlightUserBlacklist", "") { - this->showTimestamps.getValueChangedSignal().connect([this](const auto &) { + this->showTimestamps.connectSimple([this](auto) { this->updateWordTypeMask(); // }); - this->showTimestampSeconds.getValueChangedSignal().connect([this](const auto &) { + this->showTimestampSeconds.connectSimple([this](auto) { this->updateWordTypeMask(); // }); - this->showBadges.getValueChangedSignal().connect([this](const auto &) { + this->showBadges.connectSimple([this](auto) { this->updateWordTypeMask(); // }); - this->enableBttvEmotes.getValueChangedSignal().connect([this](const auto &) { + this->enableBttvEmotes.connectSimple([this](auto) { this->updateWordTypeMask(); // }); - this->enableEmojis.getValueChangedSignal().connect([this](const auto &) { + this->enableEmojis.connectSimple([this](auto) { this->updateWordTypeMask(); // }); - this->enableFfzEmotes.getValueChangedSignal().connect([this](const auto &) { + this->enableFfzEmotes.connectSimple([this](auto) { this->updateWordTypeMask(); // }); - this->enableTwitchEmotes.getValueChangedSignal().connect([this](const auto &) { + this->enableTwitchEmotes.connectSimple([this](auto) { this->updateWordTypeMask(); // }); } diff --git a/src/widgets/helper/channelview.cpp b/src/widgets/helper/channelview.cpp index bd8c66133..833236461 100644 --- a/src/widgets/helper/channelview.cpp +++ b/src/widgets/helper/channelview.cpp @@ -61,9 +61,9 @@ ChannelView::ChannelView(BaseWidget *parent) this->goToBottom->getLabel().setText("Jump to bottom"); this->goToBottom->setVisible(false); - this->fontChangedConnection = FontManager::getInstance().fontChanged.connect([this] { + this->managedConnections.emplace_back(FontManager::getInstance().fontChanged.connect([this] { this->layoutMessages(); // - }); + })); connect(goToBottom, &RippleEffectLabel::clicked, this, [this] { QTimer::singleShot(180, [this] { this->scrollBar.scrollToBottom(); }); }); @@ -83,7 +83,6 @@ ChannelView::~ChannelView() { QObject::disconnect(&SettingsManager::getInstance(), &SettingsManager::wordTypeMaskChanged, this, &ChannelView::wordTypeMaskChanged); - FontManager::getInstance().fontChanged.disconnect(this->fontChangedConnection); } void ChannelView::queueUpdate() @@ -246,9 +245,8 @@ QString ChannelView::getSelectedText() if (first) { first = false; - bool isSingleWord = - isSingleMessage && - this->selection.max.charIndex - charIndex < part.getCharacterLength(); + bool isSingleWord = isSingleMessage && this->selection.max.charIndex - charIndex < + part.getCharacterLength(); if (isSingleWord) { // return single word @@ -525,10 +523,9 @@ void ChannelView::updateMessageBuffer(messages::MessageRef *messageRef, QPixmap // this->selectionMax.messageIndex >= messageIndex) { // painter.fillRect(buffer->rect(), QColor(24, 55, 25)); //} else { - painter.fillRect(buffer->rect(), - (messageRef->getMessage()->getCanHighlightTab()) - ? this->colorScheme.ChatBackgroundHighlighted - : this->colorScheme.ChatBackground); + painter.fillRect(buffer->rect(), (messageRef->getMessage()->getCanHighlightTab()) + ? this->colorScheme.ChatBackgroundHighlighted + : this->colorScheme.ChatBackground); //} // draw selection diff --git a/src/widgets/helper/channelview.hpp b/src/widgets/helper/channelview.hpp index 7d5addc06..86e4de721 100644 --- a/src/widgets/helper/channelview.hpp +++ b/src/widgets/helper/channelview.hpp @@ -163,7 +163,7 @@ private: boost::signals2::connection repaintGifsConnection; boost::signals2::connection layoutConnection; - pajlada::Signals::NoArgSignal::Connection fontChangedConnection; + std::vector managedConnections; private slots: void wordTypeMaskChanged() diff --git a/src/widgets/helper/notebooktab.cpp b/src/widgets/helper/notebooktab.cpp index 8b37ed30c..0328c4caa 100644 --- a/src/widgets/helper/notebooktab.cpp +++ b/src/widgets/helper/notebooktab.cpp @@ -22,8 +22,8 @@ NotebookTab::NotebookTab(Notebook *_notebook) this->positionChangedAnimation.setEasingCurve(QEasingCurve(QEasingCurve::InCubic)); - this->hideXConnection = SettingsManager::getInstance().hideTabX.getValueChangedSignal().connect( - boost::bind(&NotebookTab::hideTabXChanged, this, _1)); + SettingsManager::getInstance().hideTabX.connect( + boost::bind(&NotebookTab::hideTabXChanged, this, _1), this->managedConnections); this->setMouseTracking(true); @@ -60,12 +60,6 @@ NotebookTab::NotebookTab(Notebook *_notebook) }); } -NotebookTab::~NotebookTab() -{ - SettingsManager::getInstance().hideTabX.getValueChangedSignal().disconnect( - this->hideXConnection); -} - void NotebookTab::calcSize() { float scale = getDpiMultiplier(); diff --git a/src/widgets/helper/notebooktab.hpp b/src/widgets/helper/notebooktab.hpp index ce189460b..37eb8a050 100644 --- a/src/widgets/helper/notebooktab.hpp +++ b/src/widgets/helper/notebooktab.hpp @@ -5,9 +5,7 @@ #include #include #include -#include -#include -#include +#include namespace chatterino { @@ -26,7 +24,6 @@ public: enum HighlightStyle { HighlightNone, HighlightHighlighted, HighlightNewMessage }; explicit NotebookTab(Notebook *_notebook); - ~NotebookTab(); void calcSize(); @@ -58,7 +55,7 @@ protected: void mouseMoveEvent(QMouseEvent *event) override; private: - pajlada::Signals::Signal::Connection hideXConnection; + std::vector managedConnections; QPropertyAnimation positionChangedAnimation; bool positionChangedAnimationRunning = false; diff --git a/src/widgets/helper/splitinput.cpp b/src/widgets/helper/splitinput.cpp index d4e5f3526..72698eaa2 100644 --- a/src/widgets/helper/splitinput.cpp +++ b/src/widgets/helper/splitinput.cpp @@ -30,9 +30,9 @@ SplitInput::SplitInput(Split *_chatWidget) auto &fontManager = FontManager::getInstance(); this->textInput.setFont(fontManager.getFont(FontManager::Type::Medium)); - fontManager.fontChanged.connect([this, &fontManager]() { + this->managedConnections.emplace_back(fontManager.fontChanged.connect([this, &fontManager]() { this->textInput.setFont(fontManager.getFont(FontManager::Type::Medium)); - }); + })); this->editContainer.addWidget(&this->textInput); this->editContainer.setMargin(4); @@ -177,9 +177,9 @@ SplitInput::SplitInput(Split *_chatWidget) } }); - this->textLengthVisibleChangedConnection = - SettingsManager::getInstance().showMessageLength.getValueChangedSignal().connect( - [this](const bool &value) { this->textLengthLabel.setHidden(!value); }); + SettingsManager::getInstance().showMessageLength.connect( + [this](const bool &value, auto) { this->textLengthLabel.setHidden(!value); }, + this->managedConnections); QObject::connect(&this->textInput, &QTextEdit::copyAvailable, [this](bool available) { if (available) { @@ -188,12 +188,6 @@ SplitInput::SplitInput(Split *_chatWidget) }); } -SplitInput::~SplitInput() -{ - SettingsManager::getInstance().showMessageLength.getValueChangedSignal().disconnect( - this->textLengthVisibleChangedConnection); -} - void SplitInput::clearSelection() { QTextCursor c = this->textInput.textCursor(); diff --git a/src/widgets/helper/splitinput.hpp b/src/widgets/helper/splitinput.hpp index 985b70685..67ba30835 100644 --- a/src/widgets/helper/splitinput.hpp +++ b/src/widgets/helper/splitinput.hpp @@ -13,8 +13,6 @@ #include #include -#include - namespace chatterino { namespace widgets { @@ -26,7 +24,6 @@ class SplitInput : public BaseWidget public: SplitInput(Split *_chatWidget); - ~SplitInput(); void clearSelection(); @@ -40,7 +37,7 @@ private: Split *const chatWidget; EmotePopup *emotePopup = nullptr; - pajlada::Signals::Signal::Connection textLengthVisibleChangedConnection; + std::vector managedConnections; QHBoxLayout hbox; QVBoxLayout vbox; QHBoxLayout editContainer; diff --git a/src/widgets/notebook.cpp b/src/widgets/notebook.cpp index ba7d2e6bd..b29eb8c4a 100644 --- a/src/widgets/notebook.cpp +++ b/src/widgets/notebook.cpp @@ -36,10 +36,10 @@ Notebook::Notebook(ChannelManager &_channelManager, Window *parent, bool _showBu this->userButton.move(24, 0); this->userButton.icon = NotebookButton::IconUser; - SettingsManager::getInstance().hidePreferencesButton.getValueChangedSignal().connect( - [this](const bool &) { this->performLayout(); }); - SettingsManager::getInstance().hideUserButton.getValueChangedSignal().connect( - [this](const bool &) { this->performLayout(); }); + auto &settingsManager = SettingsManager::getInstance(); + + settingsManager.hidePreferencesButton.connectSimple([this](auto) { this->performLayout(); }); + settingsManager.hideUserButton.connectSimple([this](auto) { this->performLayout(); }); } SplitContainer *Notebook::addPage(bool select) diff --git a/src/widgets/settingsdialog.cpp b/src/widgets/settingsdialog.cpp index 997d312ad..d59c481ea 100644 --- a/src/widgets/settingsdialog.cpp +++ b/src/widgets/settingsdialog.cpp @@ -181,15 +181,17 @@ QVBoxLayout *SettingsDialog::createAppearanceTab() { auto &fontManager = FontManager::getInstance(); - fontManager.currentFontFamily.getValueChangedSignal().connect( - [fontFamilyLabel](const std::string &newValue) { + fontManager.currentFontFamily.connect( + [fontFamilyLabel](const std::string &newValue, auto) { fontFamilyLabel->setText(QString::fromStdString(newValue)); // - }); + }, + this->managedConnections); - fontManager.currentFontSize.getValueChangedSignal().connect( - [fontSizeLabel](const int &newValue) { + fontManager.currentFontSize.connect( + [fontSizeLabel](const int &newValue, auto) { fontSizeLabel->setText(QString(QString::number(newValue))); // - }); + }, + this->managedConnections); } fontButton->connect(fontButton, &QPushButton::clicked, []() { diff --git a/src/widgets/settingsdialog.hpp b/src/widgets/settingsdialog.hpp index d593ab64e..ce3c918b0 100644 --- a/src/widgets/settingsdialog.hpp +++ b/src/widgets/settingsdialog.hpp @@ -80,6 +80,8 @@ private: void okButtonClicked(); void cancelButtonClicked(); + + std::vector managedConnections; }; } // namespace widgets