Migrate to C++ 20 & switch to websocketpp develop branch (#4252)

* feat: c++ 20

* fix: c++ 20 deprecations

* fix(msvc): warnings

* chore: add changelog entry

* fix: formatting

* Update websocketpp to the `develop` branch

* Specify other template type in FlagsEnum != operator

* Remove the user of simple template ids in our websocketpp template class

Also standardizes the file a bit by using nested namespaces, using
pragma once

* fix: turn `MAGIC_MESSAGE_SUFFIX` into a `QString`

* hacky unhacky hacky const char hack

Co-authored-by: Rasmus Karlsson <rasmus.karlsson@pajlada.com>
This commit is contained in:
nerix
2022-12-24 12:56:11 +01:00
committed by GitHub
parent 99e038ce5e
commit 86e71c8bd9
31 changed files with 219 additions and 212 deletions
+2 -2
View File
@@ -20,7 +20,7 @@ AccountSwitchWidget::AccountSwitchWidget(QWidget *parent)
this->addItem(userName);
}
app->accounts->twitch.userListUpdated.connect([=]() {
app->accounts->twitch.userListUpdated.connect([=, this]() {
this->blockSignals(true);
this->clear();
@@ -39,7 +39,7 @@ AccountSwitchWidget::AccountSwitchWidget(QWidget *parent)
this->refreshSelection();
QObject::connect(this, &QListWidget::clicked, [=] {
QObject::connect(this, &QListWidget::clicked, [=, this] {
if (!this->selectedItems().isEmpty())
{
QString newUsername = this->currentItem()->text();
+2 -2
View File
@@ -641,13 +641,13 @@ void Window::addMenuBar()
QAction *nextTab = windowMenu->addAction(QString("Select next tab"));
nextTab->setShortcuts({QKeySequence("Meta+Tab")});
connect(nextTab, &QAction::triggered, this, [=] {
connect(nextTab, &QAction::triggered, this, [this] {
this->notebook_->selectNextTab();
});
QAction *prevTab = windowMenu->addAction(QString("Select previous tab"));
prevTab->setShortcuts({QKeySequence("Meta+Shift+Tab")});
connect(prevTab, &QAction::triggered, this, [=] {
connect(prevTab, &QAction::triggered, this, [this] {
this->notebook_->selectPreviousTab();
});
}
+1 -1
View File
@@ -42,7 +42,7 @@ BadgePickerDialog::BadgePickerDialog(QList<DisplayBadge> badges,
this->dropdown_->addItem(item.displayName(), item.badgeName());
}
const auto updateBadge = [=](int index) {
const auto updateBadge = [=, this](int index) {
BadgeOpt badge;
if (index >= 0 && index < badges.size())
{
+9 -8
View File
@@ -94,13 +94,14 @@ ColorPickerDialog::ColorPickerDialog(const QColor &initial, QWidget *parent)
layout.emplace<QHBoxLayout>().emplace<QDialogButtonBox>(this);
{
auto *button_ok = buttons->addButton(QDialogButtonBox::Ok);
QObject::connect(button_ok, &QPushButton::clicked, [=](bool) {
QObject::connect(button_ok, &QPushButton::clicked, [this](bool) {
this->ok();
});
auto *button_cancel = buttons->addButton(QDialogButtonBox::Cancel);
QObject::connect(button_cancel, &QAbstractButton::clicked, [=](bool) {
this->close();
});
QObject::connect(button_cancel, &QAbstractButton::clicked,
[this](bool) {
this->close();
});
}
this->themeChangedEvent();
@@ -226,7 +227,7 @@ void ColorPickerDialog::initRecentColors(LayoutCreator<QWidget> &creator)
grid->addWidget(button, rowInd, columnInd);
QObject::connect(button, &QPushButton::clicked, [=] {
QObject::connect(button, &QPushButton::clicked, [=, this] {
this->selectColor(button->color(), false);
});
@@ -260,7 +261,7 @@ void ColorPickerDialog::initDefaultColors(LayoutCreator<QWidget> &creator)
grid->addWidget(button, rowInd, columnInd);
QObject::connect(button, &QPushButton::clicked, [=] {
QObject::connect(button, &QPushButton::clicked, [=, this] {
this->selectColor(button->color(), false);
});
@@ -299,7 +300,7 @@ void ColorPickerDialog::initColorPicker(LayoutCreator<QWidget> &creator)
QObject::connect(
luminancePicker, &QColorLuminancePicker::newHsv,
[=](int h, int s, int v) {
[this](int h, int s, int v) {
int alpha = this->ui_.picker.spinBoxes[SpinBox::ALPHA]->value();
this->selectColor(QColor::fromHsv(h, s, v, alpha), true);
});
@@ -344,7 +345,7 @@ void ColorPickerDialog::initSpinBoxes(LayoutCreator<QWidget> &creator)
{
QObject::connect(
this->ui_.picker.spinBoxes[i],
QOverload<int>::of(&QSpinBox::valueChanged), [=](int value) {
QOverload<int>::of(&QSpinBox::valueChanged), [=, this](int value) {
this->selectColor(QColor(red->value(), green->value(),
blue->value(), alpha->value()),
false);
+14 -13
View File
@@ -177,16 +177,16 @@ AdvancedLoginWidget::AdvancedLoginWidget()
this->ui_.oauthTokenInput.setEchoMode(QLineEdit::Password);
connect(&this->ui_.userIDInput, &QLineEdit::textChanged, [=]() {
connect(&this->ui_.userIDInput, &QLineEdit::textChanged, [this]() {
this->refreshButtons();
});
connect(&this->ui_.usernameInput, &QLineEdit::textChanged, [=]() {
connect(&this->ui_.usernameInput, &QLineEdit::textChanged, [this]() {
this->refreshButtons();
});
connect(&this->ui_.clientIDInput, &QLineEdit::textChanged, [=]() {
connect(&this->ui_.clientIDInput, &QLineEdit::textChanged, [this]() {
this->refreshButtons();
});
connect(&this->ui_.oauthTokenInput, &QLineEdit::textChanged, [=]() {
connect(&this->ui_.oauthTokenInput, &QLineEdit::textChanged, [this]() {
this->refreshButtons();
});
@@ -201,22 +201,23 @@ AdvancedLoginWidget::AdvancedLoginWidget()
&this->ui_.buttonUpperRow.clearFieldsButton);
connect(&this->ui_.buttonUpperRow.clearFieldsButton, &QPushButton::clicked,
[=]() {
[this]() {
this->ui_.userIDInput.clear();
this->ui_.usernameInput.clear();
this->ui_.clientIDInput.clear();
this->ui_.oauthTokenInput.clear();
});
connect(
&this->ui_.buttonUpperRow.addUserButton, &QPushButton::clicked, [=]() {
QString userID = this->ui_.userIDInput.text();
QString username = this->ui_.usernameInput.text();
QString clientID = this->ui_.clientIDInput.text();
QString oauthToken = this->ui_.oauthTokenInput.text();
connect(&this->ui_.buttonUpperRow.addUserButton, &QPushButton::clicked,
[this]() {
QString userID = this->ui_.userIDInput.text();
QString username = this->ui_.usernameInput.text();
QString clientID = this->ui_.clientIDInput.text();
QString oauthToken = this->ui_.oauthTokenInput.text();
logInWithCredentials(this, userID, username, clientID, oauthToken);
});
logInWithCredentials(this, userID, username, clientID,
oauthToken);
});
}
void AdvancedLoginWidget::refreshButtons()
+5 -4
View File
@@ -223,13 +223,14 @@ SelectChannelDialog::SelectChannelDialog(QWidget *parent)
layout.emplace<QHBoxLayout>().emplace<QDialogButtonBox>(this);
{
auto *button_ok = buttons->addButton(QDialogButtonBox::Ok);
QObject::connect(button_ok, &QPushButton::clicked, [=](bool) {
QObject::connect(button_ok, &QPushButton::clicked, [this](bool) {
this->ok();
});
auto *button_cancel = buttons->addButton(QDialogButtonBox::Cancel);
QObject::connect(button_cancel, &QAbstractButton::clicked, [=](bool) {
this->close();
});
QObject::connect(button_cancel, &QAbstractButton::clicked,
[this](bool) {
this->close();
});
}
this->setMinimumSize(300, 310);
+1 -1
View File
@@ -919,7 +919,7 @@ void UserInfoPopup::loadAvatar(const QUrl &url)
static auto manager = new QNetworkAccessManager();
auto *reply = manager->get(req);
QObject::connect(reply, &QNetworkReply::finished, this, [=] {
QObject::connect(reply, &QNetworkReply::finished, this, [=, this] {
if (reply->error() == QNetworkReply::NoError)
{
const auto data = reply->readAll();
+6 -5
View File
@@ -206,12 +206,13 @@ void ChannelView::initializeLayout()
this->goToBottom_->getLabel().setText("More messages below");
this->goToBottom_->setVisible(false);
QObject::connect(this->goToBottom_, &EffectLabel::leftClicked, this, [=] {
QTimer::singleShot(180, [=] {
this->scrollBar_->scrollToBottom(
getSettings()->enableSmoothScrollingNewMessages.getValue());
QObject::connect(
this->goToBottom_, &EffectLabel::leftClicked, this, [this] {
QTimer::singleShot(180, [this] {
this->scrollBar_->scrollToBottom(
getSettings()->enableSmoothScrollingNewMessages.getValue());
});
});
});
}
void ChannelView::initializeScrollbar()
+2 -2
View File
@@ -89,7 +89,7 @@ NotebookTab::NotebookTab(Notebook *notebook)
this->menu_.addAction(
"Close Tab",
[=]() {
[this]() {
this->notebook_->removePage(this->page);
},
getApp()->hotkeys->getDisplaySequence(HotkeyCategory::Window,
@@ -97,7 +97,7 @@ NotebookTab::NotebookTab(Notebook *notebook)
this->menu_.addAction(
"Popup Tab",
[=]() {
[this]() {
if (auto container = dynamic_cast<SplitContainer *>(this->page))
{
container->popup();
@@ -39,7 +39,7 @@ GeneralPageView::GeneralPageView(QWidget *parent)
{scrollArea, new QSpacerItem(16, 1), navigation}));
QObject::connect(scrollArea->verticalScrollBar(), &QScrollBar::valueChanged,
this, [=] {
this, [this] {
this->updateNavigationHighlighting();
});
}
@@ -74,7 +74,7 @@ TitleLabel *GeneralPageView::addTitle(const QString &title)
navLabel->setCursor(Qt::PointingHandCursor);
this->navigationLayout_->addWidget(navLabel);
QObject::connect(navLabel, &NavigationLabel::leftMouseUp, label, [=] {
QObject::connect(navLabel, &NavigationLabel::leftMouseUp, label, [=, this] {
this->contentScrollArea_->verticalScrollBar()->setValue(label->y());
});
@@ -269,7 +269,7 @@ HighlightingPage::HighlightingPage()
auto selectFile = customSound.emplace<QPushButton>("Change...");
QObject::connect(selectFile.getElement(), &QPushButton::clicked,
this, [=]() mutable {
this, [this]() mutable {
auto fileName = QFileDialog::getOpenFileName(
this, tr("Open Sound"), "",
tr("Audio Files (*.mp3 *.wav)"));
+1 -1
View File
@@ -213,7 +213,7 @@ void ModerationPage::addModerationButtonSettings(
texts->setContentsMargins(0, 0, 0, 15);
texts->setSizeConstraint(QLayout::SetMaximumSize);
const auto valueChanged = [=] {
const auto valueChanged = [=, this] {
const auto index = QObject::sender()->objectName().toInt();
const auto line = this->durationInputs_[index];
+3 -3
View File
@@ -157,7 +157,7 @@ Split::Split(QWidget *parent)
}
});
this->input_->textChanged.connect([=](const QString &newText) {
this->input_->textChanged.connect([this](const QString &newText) {
if (getSettings()->showEmptyInput)
{
// We always show the input regardless of the text, so we can early out here
@@ -754,7 +754,7 @@ void Split::showChangeChannelPopup(const char *dialogTitle, bool empty,
dialog->setAttribute(Qt::WA_DeleteOnClose);
dialog->setWindowTitle(dialogTitle);
dialog->show();
dialog->closed.connect([=] {
dialog->closed.connect([=, this] {
if (dialog->hasSeletedChannel())
{
this->setChannel(dialog->getSelectedChannel());
@@ -1030,7 +1030,7 @@ void Split::showViewerList()
NetworkRequest::twitchRequest("https://tmi.twitch.tv/group/user/" +
this->getChannel()->getName() + "/chatters")
.caller(this)
.onSuccess([=](auto result) -> Outcome {
.onSuccess([=, this](auto result) -> Outcome {
auto obj = result.parseJson();
QJsonObject chattersObj = obj.value("chatters").toObject();
+2 -2
View File
@@ -125,7 +125,7 @@ Split *SplitContainer::appendNewSplit(bool openChannelNameDialog)
if (openChannelNameDialog)
{
split->showChangeChannelPopup("Open channel", true, [=](bool ok) {
split->showChangeChannelPopup("Open channel", true, [=, this](bool ok) {
if (!ok)
{
this->deleteSplit(split);
@@ -1242,7 +1242,7 @@ void SplitContainer::Node::layout(bool addSpacing, float _scale,
0.0001, this->getChildrensTotalFlex(isVertical));
qreal totalSize = std::accumulate(
this->children_.begin(), this->children_.end(), qreal(0),
[=](int val, std::unique_ptr<Node> &node) {
[=, this](int val, std::unique_ptr<Node> &node) {
return val + std::max<qreal>(
this->getSize(isVertical) /
std::max<qreal>(0.0001, totalFlex) *
+9 -8
View File
@@ -137,21 +137,22 @@ void SplitInput::initLayout()
QObject::connect(this->ui_.textEdit, &QTextEdit::textChanged, this,
&SplitInput::onTextChanged);
this->managedConnections_.managedConnect(app->fonts->fontChanged, [=]() {
this->ui_.textEdit->setFont(
app->fonts->getFont(FontStyle::ChatMedium, this->scale()));
this->ui_.replyLabel->setFont(
app->fonts->getFont(FontStyle::ChatMediumBold, this->scale()));
});
this->managedConnections_.managedConnect(
app->fonts->fontChanged, [=, this]() {
this->ui_.textEdit->setFont(
app->fonts->getFont(FontStyle::ChatMedium, this->scale()));
this->ui_.replyLabel->setFont(
app->fonts->getFont(FontStyle::ChatMediumBold, this->scale()));
});
// open emote popup
QObject::connect(this->ui_.emoteButton, &EffectLabel::leftClicked, [=] {
QObject::connect(this->ui_.emoteButton, &EffectLabel::leftClicked, [this] {
this->openEmotePopup();
});
// clear input and remove reply thread
QObject::connect(this->ui_.cancelReplyButton, &EffectLabel::leftClicked,
[=] {
[this] {
this->clearInput();
});