Update settings and signals library version

This commit is contained in:
Rasmus Karlsson
2017-12-17 03:37:46 +01:00
parent c1ac7db24c
commit bb081b710e
16 changed files with 52 additions and 74 deletions
+7 -10
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,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
+1 -1
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()
+2 -8
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();
+2 -5
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;
+5 -11
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();
+1 -4
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;
+4 -4
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)
+8 -6
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, []() {
+2
View File
@@ -80,6 +80,8 @@ private:
void okButtonClicked();
void cancelButtonClicked();
std::vector<pajlada::Signals::ScopedConnection> managedConnections;
};
} // namespace widgets