Chore: Proper Lambda Formatting (#2167)
Co-authored-by: pajlada <rasmus.karlsson@pajlada.com>
This commit is contained in:
@@ -119,8 +119,9 @@ void Button::setMenu(std::unique_ptr<QMenu> menu)
|
||||
new FunctionEventFilter(this, [this](QObject *, QEvent *event) {
|
||||
if (event->type() == QEvent::Hide)
|
||||
{
|
||||
QTimer::singleShot(20, this,
|
||||
[this] { this->menuVisible_ = false; });
|
||||
QTimer::singleShot(20, this, [this] {
|
||||
this->menuVisible_ = false;
|
||||
});
|
||||
}
|
||||
return false;
|
||||
}));
|
||||
@@ -243,7 +244,9 @@ void Button::mousePressEvent(QMouseEvent *event)
|
||||
|
||||
if (this->menu_ && !this->menuVisible_)
|
||||
{
|
||||
QTimer::singleShot(80, this, [this] { this->showMenu(); });
|
||||
QTimer::singleShot(80, this, [this] {
|
||||
this->showMenu();
|
||||
});
|
||||
this->mouseDown_ = false;
|
||||
this->mouseOver_ = false;
|
||||
}
|
||||
|
||||
@@ -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] {
|
||||
|
||||
@@ -16,8 +16,9 @@ DebugPopup::DebugPopup()
|
||||
auto *timer = new QTimer(this);
|
||||
|
||||
timer->setInterval(300);
|
||||
QObject::connect(timer, &QTimer::timeout,
|
||||
[text] { text->setText(DebugCount::getDebugText()); });
|
||||
QObject::connect(timer, &QTimer::timeout, [text] {
|
||||
text->setText(DebugCount::getDebugText());
|
||||
});
|
||||
timer->start();
|
||||
|
||||
text->setFont(QFontDatabase::systemFont(QFontDatabase::FixedFont));
|
||||
|
||||
@@ -36,8 +36,9 @@ EditableModelView::EditableModelView(QAbstractTableModel *model, bool movable)
|
||||
// add
|
||||
QPushButton *add = new QPushButton("Add");
|
||||
buttons->addWidget(add);
|
||||
QObject::connect(add, &QPushButton::clicked,
|
||||
[this] { this->addButtonPressed.invoke(); });
|
||||
QObject::connect(add, &QPushButton::clicked, [this] {
|
||||
this->addButtonPressed.invoke();
|
||||
});
|
||||
|
||||
// remove
|
||||
QPushButton *remove = new QPushButton("Remove");
|
||||
@@ -61,22 +62,25 @@ EditableModelView::EditableModelView(QAbstractTableModel *model, bool movable)
|
||||
// move up
|
||||
QPushButton *moveUp = new QPushButton("Move up");
|
||||
buttons->addWidget(moveUp);
|
||||
QObject::connect(moveUp, &QPushButton::clicked, this,
|
||||
[this] { this->moveRow(-1); });
|
||||
QObject::connect(moveUp, &QPushButton::clicked, this, [this] {
|
||||
this->moveRow(-1);
|
||||
});
|
||||
|
||||
// move down
|
||||
QPushButton *moveDown = new QPushButton("Move down");
|
||||
buttons->addWidget(moveDown);
|
||||
QObject::connect(moveDown, &QPushButton::clicked, this,
|
||||
[this] { this->moveRow(1); });
|
||||
QObject::connect(moveDown, &QPushButton::clicked, this, [this] {
|
||||
this->moveRow(1);
|
||||
});
|
||||
}
|
||||
|
||||
buttons->addStretch();
|
||||
|
||||
QObject::connect(this->model_, &QAbstractTableModel::rowsMoved, this,
|
||||
[this](const QModelIndex &parent, int start, int end,
|
||||
const QModelIndex &destination,
|
||||
int row) { this->selectRow(row); });
|
||||
const QModelIndex &destination, int row) {
|
||||
this->selectRow(row);
|
||||
});
|
||||
|
||||
// add tableview
|
||||
vbox->addWidget(this->tableView_);
|
||||
|
||||
@@ -46,23 +46,30 @@ NotebookTab::NotebookTab(Notebook *notebook)
|
||||
getSettings()->showTabCloseButton.connectSimple(
|
||||
boost::bind(&NotebookTab::hideTabXChanged, this),
|
||||
this->managedConnections_);
|
||||
getSettings()->showTabLive.connect([this](auto, auto) { this->update(); },
|
||||
this->managedConnections_);
|
||||
getSettings()->showTabLive.connect(
|
||||
[this](auto, auto) {
|
||||
this->update();
|
||||
},
|
||||
this->managedConnections_);
|
||||
|
||||
this->setMouseTracking(true);
|
||||
|
||||
this->menu_.addAction("Rename", [this]() { this->showRenameDialog(); });
|
||||
this->menu_.addAction("Rename", [this]() {
|
||||
this->showRenameDialog();
|
||||
});
|
||||
|
||||
this->menu_.addAction("Close",
|
||||
[=]() { this->notebook_->removePage(this->page); });
|
||||
this->menu_.addAction("Close", [=]() {
|
||||
this->notebook_->removePage(this->page);
|
||||
});
|
||||
|
||||
highlightNewMessagesAction_ =
|
||||
new QAction("Enable highlights on new messages", &this->menu_);
|
||||
highlightNewMessagesAction_->setCheckable(true);
|
||||
highlightNewMessagesAction_->setChecked(highlightEnabled_);
|
||||
QObject::connect(
|
||||
highlightNewMessagesAction_, &QAction::triggered,
|
||||
[this](bool checked) { this->highlightEnabled_ = checked; });
|
||||
QObject::connect(highlightNewMessagesAction_, &QAction::triggered,
|
||||
[this](bool checked) {
|
||||
this->highlightEnabled_ = checked;
|
||||
});
|
||||
this->menu_.addAction(highlightNewMessagesAction_);
|
||||
}
|
||||
|
||||
@@ -559,7 +566,7 @@ void NotebookTab::dragEnterEvent(QDragEnterEvent *event)
|
||||
void NotebookTab::mouseMoveEvent(QMouseEvent *event)
|
||||
{
|
||||
if (getSettings()->showTabCloseButton &&
|
||||
this->notebook_->getAllowUserTabManagement()) //
|
||||
this->notebook_->getAllowUserTabManagement())
|
||||
{
|
||||
bool overX = this->getXRect().contains(event->pos());
|
||||
|
||||
@@ -575,7 +582,7 @@ void NotebookTab::mouseMoveEvent(QMouseEvent *event)
|
||||
QPoint relPoint = this->mapToParent(event->pos());
|
||||
|
||||
if (this->mouseDown_ && !this->getDesiredRect().contains(relPoint) &&
|
||||
this->notebook_->getAllowUserTabManagement()) //
|
||||
this->notebook_->getAllowUserTabManagement())
|
||||
{
|
||||
int index;
|
||||
QWidget *clickedPage =
|
||||
|
||||
@@ -21,8 +21,9 @@ ResizingTextEdit::ResizingTextEdit()
|
||||
|
||||
// Whenever the setting for emote completion changes, force a
|
||||
// refresh on the completion model the next time "Tab" is pressed
|
||||
getSettings()->prefixOnlyEmoteCompletion.connect(
|
||||
[this] { this->completionInProgress_ = false; });
|
||||
getSettings()->prefixOnlyEmoteCompletion.connect([this] {
|
||||
this->completionInProgress_ = false;
|
||||
});
|
||||
|
||||
this->setFocusPolicy(Qt::ClickFocus);
|
||||
}
|
||||
|
||||
@@ -109,7 +109,9 @@ void SearchPopup::initLayout()
|
||||
this->searchInput_ = new QLineEdit(this);
|
||||
layout2->addWidget(this->searchInput_);
|
||||
QObject::connect(this->searchInput_, &QLineEdit::returnPressed,
|
||||
[this] { this->search(); });
|
||||
[this] {
|
||||
this->search();
|
||||
});
|
||||
}
|
||||
|
||||
// SEARCH BUTTON
|
||||
@@ -117,8 +119,9 @@ void SearchPopup::initLayout()
|
||||
QPushButton *searchButton = new QPushButton(this);
|
||||
searchButton->setText("Search");
|
||||
layout2->addWidget(searchButton);
|
||||
QObject::connect(searchButton, &QPushButton::clicked,
|
||||
[this] { this->search(); });
|
||||
QObject::connect(searchButton, &QPushButton::clicked, [this] {
|
||||
this->search();
|
||||
});
|
||||
}
|
||||
|
||||
layout1->addLayout(layout2);
|
||||
|
||||
Reference in New Issue
Block a user