This commit is contained in:
2017-12-17 03:46:46 +01:00
commit 1fb0ca649a
16 changed files with 52 additions and 74 deletions

@ -1 +1 @@
Subproject commit d3faa9b3996e0871473b0e2b1821c93a50821f40
Subproject commit a8c167976e907d8caa19f921d7a4984c6658a2a9

@ -1 +1 @@
Subproject commit 2c9c92b971f4a1313eeb4d9daf8ea59565d3c691
Subproject commit fcce2886e5443e88bc70228b1929d8c0e1bb641a

View file

@ -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) {

View file

@ -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,9 +135,9 @@ 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.setHslF(
color.hueF(), color.saturationF(),
color.lightnessF() + sin((color.hueF() - 0.54444) / (0.8333 - 0.54444) * 3.14159) *
color.saturationF() * 0.2);
}
}

View file

@ -27,7 +27,7 @@ EmoteManager::EmoteManager()
pajlada::Settings::Setting<std::string> 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); //
});
}

View file

@ -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();

View file

@ -20,31 +20,31 @@ SettingsManager::SettingsManager()
QMap<QString, QPair<bool, bool>>())
, 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(); //
});
}

View file

@ -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,8 +523,7 @@ 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())
painter.fillRect(buffer->rect(), (messageRef->getMessage()->getCanHighlightTab())
? this->colorScheme.ChatBackgroundHighlighted
: this->colorScheme.ChatBackground);
//}

View file

@ -163,7 +163,7 @@ private:
boost::signals2::connection repaintGifsConnection;
boost::signals2::connection layoutConnection;
pajlada::Signals::NoArgSignal::Connection fontChangedConnection;
std::vector<pajlada::Signals::ScopedConnection> managedConnections;
private slots:
void wordTypeMaskChanged()

View file

@ -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();

View file

@ -5,9 +5,7 @@
#include <QMenu>
#include <QPropertyAnimation>
#include <boost/property_tree/ptree.hpp>
#include <boost/signals2.hpp>
#include <boost/signals2/connection.hpp>
#include <pajlada/signals/signal.hpp>
#include <pajlada/signals/connection.hpp>
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<const bool &>::Connection hideXConnection;
std::vector<pajlada::Signals::ScopedConnection> managedConnections;
QPropertyAnimation positionChangedAnimation;
bool positionChangedAnimationRunning = false;

View file

@ -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();

View file

@ -13,8 +13,6 @@
#include <QVBoxLayout>
#include <QWidget>
#include <boost/signals2.hpp>
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<const bool &>::Connection textLengthVisibleChangedConnection;
std::vector<pajlada::Signals::ScopedConnection> managedConnections;
QHBoxLayout hbox;
QVBoxLayout vbox;
QHBoxLayout editContainer;

View file

@ -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)

View file

@ -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, []() {

View file

@ -80,6 +80,8 @@ private:
void okButtonClicked();
void cancelButtonClicked();
std::vector<pajlada::Signals::ScopedConnection> managedConnections;
};
} // namespace widgets