Chore: Proper Lambda Formatting (#2167)

Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
Leon Richardt
2020-11-08 12:02:19 +01:00
committed by GitHub
parent fbd5df53d8
commit 0eed45ae67
71 changed files with 712 additions and 415 deletions
+50 -34
View File
@@ -71,9 +71,10 @@ namespace {
auto addImageLink = [&](const ImagePtr &image, char scale) {
if (!image->isEmpty())
{
copyMenu->addAction(
QString(scale) + "x link",
[url = image->url()] { crossPlatformCopy(url.string); });
copyMenu->addAction(QString(scale) + "x link",
[url = image->url()] {
crossPlatformCopy(url.string);
});
openMenu->addAction(
QString(scale) + "x link", [url = image->url()] {
QDesktopServices::openUrl(QUrl(url.string));
@@ -90,13 +91,14 @@ namespace {
copyMenu->addSeparator();
openMenu->addSeparator();
copyMenu->addAction(
"Copy " + name + " emote link",
[url = emote.homePage] { crossPlatformCopy(url.string); });
openMenu->addAction(
"Open " + name + " emote link", [url = emote.homePage] {
QDesktopServices::openUrl(QUrl(url.string)); //
});
copyMenu->addAction("Copy " + name + " emote link",
[url = emote.homePage] {
crossPlatformCopy(url.string);
});
openMenu->addAction("Open " + name + " emote link",
[url = emote.homePage] {
QDesktopServices::openUrl(QUrl(url.string));
});
};
if (creatorFlags.has(MessageElementFlag::BttvEmote))
@@ -134,8 +136,9 @@ ChannelView::ChannelView(BaseWidget *parent)
});
auto shortcut = new QShortcut(QKeySequence::StandardKey::Copy, this);
QObject::connect(shortcut, &QShortcut::activated,
[this] { crossPlatformCopy(this->getSelectedText()); });
QObject::connect(shortcut, &QShortcut::activated, [this] {
crossPlatformCopy(this->getSelectedText());
});
this->clickTimer_ = new QTimer(this);
this->clickTimer_->setSingleShot(true);
@@ -181,10 +184,14 @@ void ChannelView::initializeSignals()
}));
getSettings()->showLastMessageIndicator.connect(
[this](auto, auto) { this->update(); }, this->connections_);
[this](auto, auto) {
this->update();
},
this->connections_);
connections_.push_back(getApp()->windows->gifRepaintRequested.connect(
[&] { this->queueUpdate(); }));
connections_.push_back(getApp()->windows->gifRepaintRequested.connect([&] {
this->queueUpdate();
}));
connections_.push_back(
getApp()->windows->layoutRequested.connect([&](Channel *channel) {
@@ -195,8 +202,9 @@ void ChannelView::initializeSignals()
}
}));
connections_.push_back(
getApp()->fonts->fontChanged.connect([this] { this->queueLayout(); }));
connections_.push_back(getApp()->fonts->fontChanged.connect([this] {
this->queueLayout();
}));
}
bool ChannelView::pausable() const
@@ -272,7 +280,9 @@ void ChannelView::updatePauses()
this->queueLayout();
}
else if (std::any_of(this->pauses_.begin(), this->pauses_.end(),
[](auto &&value) { return !value.second; }))
[](auto &&value) {
return !value.second;
}))
{
/// Some of the pauses are infinite
this->pauseEnd_ = boost::none;
@@ -282,9 +292,10 @@ void ChannelView::updatePauses()
{
/// Get the maximum pause
auto pauseEnd =
std::max_element(
this->pauses_.begin(), this->pauses_.end(),
[](auto &&a, auto &&b) { return a.second > b.second; })
std::max_element(this->pauses_.begin(), this->pauses_.end(),
[](auto &&a, auto &&b) {
return a.second > b.second;
})
->second.get();
if (pauseEnd != this->pauseEnd_)
@@ -605,11 +616,11 @@ void ChannelView::setChannel(ChannelPtr underlyingChannel)
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);
});
std::copy_if(messages.begin(), messages.end(),
std::back_inserter(filtered),
[this](MessagePtr msg) {
return this->shouldIncludeMessage(msg);
});
if (!filtered.empty())
this->channel_->addMessagesAtStart(filtered);
@@ -689,7 +700,7 @@ void ChannelView::setChannel(ChannelPtr underlyingChannel)
if (auto tc = dynamic_cast<TwitchChannel *>(underlyingChannel.get()))
{
this->connections_.push_back(tc->liveStatusChanged.connect([this]() {
this->liveStatusChanged.invoke(); //
this->liveStatusChanged.invoke();
}));
}
}
@@ -1813,15 +1824,19 @@ void ChannelView::addContextMenuItems(
QString url = hoveredElement->getLink().value;
// open link
menu->addAction("Open link",
[url] { QDesktopServices::openUrl(QUrl(url)); });
menu->addAction("Open link", [url] {
QDesktopServices::openUrl(QUrl(url));
});
// open link default
if (supportsIncognitoLinks())
{
menu->addAction("Open link incognito",
[url] { openLinkIncognito(url); });
menu->addAction("Open link incognito", [url] {
openLinkIncognito(url);
});
}
menu->addAction("Copy link", [url] { crossPlatformCopy(url); });
menu->addAction("Copy link", [url] {
crossPlatformCopy(url);
});
menu->addSeparator();
}
@@ -1829,8 +1844,9 @@ void ChannelView::addContextMenuItems(
// Copy actions
if (!this->selection_.isEmpty())
{
menu->addAction("Copy selection",
[this] { crossPlatformCopy(this->getSelectedText()); });
menu->addAction("Copy selection", [this] {
crossPlatformCopy(this->getSelectedText());
});
}
menu->addAction("Copy message", [layout] {