From f95998a64bebcb12ffe07fcb6f23cdabff434641 Mon Sep 17 00:00:00 2001 From: Konstantinos Sideris Date: Tue, 20 Feb 2018 17:09:11 +0200 Subject: [PATCH] Be explicit about the captured parameters in lambdas --- include/timeline/TimelineItem.h | 4 +- include/timeline/TimelineView.h | 2 +- src/ChatPage.cc | 122 ++++++++++++++-------------- src/CommunitiesList.cc | 2 +- src/MainWindow.cc | 32 ++++---- src/MatrixClient.cc | 2 +- src/QuickSwitcher.cc | 13 +-- src/RoomInfoListItem.cc | 4 +- src/RoomList.cc | 10 +-- src/SideBarActions.cc | 10 +-- src/TextInputWidget.cc | 4 +- src/TopRoomBar.cc | 12 +-- src/UserInfoWidget.cc | 2 +- src/UserSettingsPage.cc | 12 +-- src/dialogs/CreateRoom.cc | 10 +-- src/dialogs/InviteUsers.cc | 4 +- src/dialogs/JoinRoom.cc | 4 +- src/dialogs/LeaveRoom.cc | 4 +- src/dialogs/Logout.cc | 4 +- src/dialogs/PreviewUploadOverlay.cc | 2 +- src/dialogs/ReadReceipts.cc | 2 +- src/timeline/TimelineItem.cc | 10 +-- src/timeline/TimelineView.cc | 2 +- src/timeline/widgets/AudioItem.cc | 2 +- 24 files changed, 142 insertions(+), 133 deletions(-) diff --git a/include/timeline/TimelineItem.h b/include/timeline/TimelineItem.h index 793b906..a80a42c 100644 --- a/include/timeline/TimelineItem.h +++ b/include/timeline/TimelineItem.h @@ -173,7 +173,7 @@ TimelineItem::setupLocalWidgetLayout(Widget *widget, headerLayout_->addLayout(widgetLayout); messageLayout_->addLayout(headerLayout_, 1); - AvatarProvider::resolve(userid, [=](const QImage &img) { setUserAvatar(img); }); + AvatarProvider::resolve(userid, [this](const QImage &img) { setUserAvatar(img); }); } else { setupSimpleLayout(); @@ -224,7 +224,7 @@ TimelineItem::setupWidgetLayout(Widget *widget, headerLayout_->addLayout(widgetLayout); messageLayout_->addLayout(headerLayout_, 1); - AvatarProvider::resolve(sender, [=](const QImage &img) { setUserAvatar(img); }); + AvatarProvider::resolve(sender, [this](const QImage &img) { setUserAvatar(img); }); } else { setupSimpleLayout(); diff --git a/include/timeline/TimelineView.h b/include/timeline/TimelineView.h index 96d7690..7a492de 100644 --- a/include/timeline/TimelineView.h +++ b/include/timeline/TimelineView.h @@ -134,7 +134,7 @@ private: { item->hide(); scroll_layout_->addWidget(item); - QTimer::singleShot(0, this, [=]() { item->show(); }); + QTimer::singleShot(0, this, [item]() { item->show(); }); }; //! Decides whether or not to show or hide the scroll down button. diff --git a/src/ChatPage.cc b/src/ChatPage.cc index 3bca5cd..a3ae742 100644 --- a/src/ChatPage.cc +++ b/src/ChatPage.cc @@ -141,21 +141,21 @@ ChatPage::ChatPage(QSharedPointer client, typingRefresher_ = new QTimer(this); typingRefresher_->setInterval(TYPING_REFRESH_TIMEOUT); - connect(user_info_widget_, &UserInfoWidget::logout, this, [=]() { + connect(user_info_widget_, &UserInfoWidget::logout, this, [this]() { client_->logout(); emit showOverlayProgressBar(); }); connect(client_.data(), &MatrixClient::loggedOut, this, &ChatPage::logout); - connect(top_bar_, &TopRoomBar::inviteUsers, this, [=](QStringList users) { + connect(top_bar_, &TopRoomBar::inviteUsers, this, [this](QStringList users) { for (int ii = 0; ii < users.size(); ++ii) { - QTimer::singleShot(ii * 1000, this, [=]() { + QTimer::singleShot(ii * 1000, this, [this, &ii, &users]() { client_->inviteUser(current_room_, users.at(ii)); }); } }); - connect(room_list_, &RoomList::roomChanged, this, [=](const QString &roomid) { + connect(room_list_, &RoomList::roomChanged, this, [this](const QString &roomid) { QStringList users; if (!userSettings_->isTypingNotificationsEnabled()) { @@ -178,7 +178,7 @@ ChatPage::ChatPage(QSharedPointer client, connect(room_list_, &RoomList::acceptInvite, client_.data(), &MatrixClient::joinRoom); connect(room_list_, &RoomList::declineInvite, client_.data(), &MatrixClient::leaveRoom); - connect(text_input_, &TextInputWidget::startedTyping, this, [=]() { + connect(text_input_, &TextInputWidget::startedTyping, this, [this]() { if (!userSettings_->isTypingNotificationsEnabled()) return; @@ -186,7 +186,7 @@ ChatPage::ChatPage(QSharedPointer client, client_->sendTypingNotification(current_room_); }); - connect(text_input_, &TextInputWidget::stoppedTyping, this, [=]() { + connect(text_input_, &TextInputWidget::stoppedTyping, this, [this]() { if (!userSettings_->isTypingNotificationsEnabled()) return; @@ -194,7 +194,7 @@ ChatPage::ChatPage(QSharedPointer client, client_->removeTypingNotification(current_room_); }); - connect(typingRefresher_, &QTimer::timeout, this, [=]() { + connect(typingRefresher_, &QTimer::timeout, this, [this]() { if (!userSettings_->isTypingNotificationsEnabled()) return; @@ -229,65 +229,69 @@ ChatPage::ChatPage(QSharedPointer client, connect(text_input_, &TextInputWidget::uploadImage, this, - [=](QSharedPointer data, const QString &fn) { + [this](QSharedPointer data, const QString &fn) { client_->uploadImage(current_room_, fn, data); }); connect(text_input_, &TextInputWidget::uploadFile, this, - [=](QSharedPointer data, const QString &fn) { + [this](QSharedPointer data, const QString &fn) { client_->uploadFile(current_room_, fn, data); }); connect(text_input_, &TextInputWidget::uploadAudio, this, - [=](QSharedPointer data, const QString &fn) { + [this](QSharedPointer data, const QString &fn) { client_->uploadAudio(current_room_, fn, data); }); connect(text_input_, &TextInputWidget::uploadVideo, this, - [=](QSharedPointer data, const QString &fn) { + [this](QSharedPointer data, const QString &fn) { client_->uploadVideo(current_room_, fn, data); }); connect( client_.data(), &MatrixClient::roomCreationFailed, this, &ChatPage::showNotification); connect(client_.data(), &MatrixClient::joinFailed, this, &ChatPage::showNotification); - connect(client_.data(), &MatrixClient::uploadFailed, this, [=](int, const QString &msg) { + connect(client_.data(), &MatrixClient::uploadFailed, this, [this](int, const QString &msg) { text_input_->hideUploadSpinner(); emit showNotification(msg); }); - connect(client_.data(), - &MatrixClient::imageUploaded, - this, - [=](QString roomid, QString filename, QString url, QString mime, uint64_t dsize) { - text_input_->hideUploadSpinner(); - view_manager_->queueImageMessage(roomid, filename, url, mime, dsize); - }); - connect(client_.data(), - &MatrixClient::fileUploaded, - this, - [=](QString roomid, QString filename, QString url, QString mime, uint64_t dsize) { - text_input_->hideUploadSpinner(); - view_manager_->queueFileMessage(roomid, filename, url, mime, dsize); - }); - connect(client_.data(), - &MatrixClient::audioUploaded, - this, - [=](QString roomid, QString filename, QString url, QString mime, uint64_t dsize) { - text_input_->hideUploadSpinner(); - view_manager_->queueAudioMessage(roomid, filename, url, mime, dsize); - }); - connect(client_.data(), - &MatrixClient::videoUploaded, - this, - [=](QString roomid, QString filename, QString url, QString mime, uint64_t dsize) { - text_input_->hideUploadSpinner(); - view_manager_->queueVideoMessage(roomid, filename, url, mime, dsize); - }); + connect( + client_.data(), + &MatrixClient::imageUploaded, + this, + [this](QString roomid, QString filename, QString url, QString mime, uint64_t dsize) { + text_input_->hideUploadSpinner(); + view_manager_->queueImageMessage(roomid, filename, url, mime, dsize); + }); + connect( + client_.data(), + &MatrixClient::fileUploaded, + this, + [this](QString roomid, QString filename, QString url, QString mime, uint64_t dsize) { + text_input_->hideUploadSpinner(); + view_manager_->queueFileMessage(roomid, filename, url, mime, dsize); + }); + connect( + client_.data(), + &MatrixClient::audioUploaded, + this, + [this](QString roomid, QString filename, QString url, QString mime, uint64_t dsize) { + text_input_->hideUploadSpinner(); + view_manager_->queueAudioMessage(roomid, filename, url, mime, dsize); + }); + connect( + client_.data(), + &MatrixClient::videoUploaded, + this, + [this](QString roomid, QString filename, QString url, QString mime, uint64_t dsize) { + text_input_->hideUploadSpinner(); + view_manager_->queueVideoMessage(roomid, filename, url, mime, dsize); + }); connect(room_list_, &RoomList::roomAvatarChanged, this, &ChatPage::updateTopBarAvatar); @@ -309,13 +313,13 @@ ChatPage::ChatPage(QSharedPointer client, connect(client_.data(), &MatrixClient::communityProfileRetrieved, this, - [=](QString communityId, QJsonObject profile) { + [this](QString communityId, QJsonObject profile) { communities_[communityId]->parseProfile(profile); }); connect(client_.data(), &MatrixClient::communityRoomsRetrieved, this, - [=](QString communityId, QJsonObject rooms) { + [this](QString communityId, QJsonObject rooms) { communities_[communityId]->parseRooms(rooms); if (communityId == current_community_) { @@ -328,27 +332,27 @@ ChatPage::ChatPage(QSharedPointer client, } }); - connect(client_.data(), &MatrixClient::joinedRoom, this, [=](const QString &room_id) { + connect(client_.data(), &MatrixClient::joinedRoom, this, [this](const QString &room_id) { emit showNotification("You joined the room."); removeInvite(room_id); }); - connect(client_.data(), &MatrixClient::invitedUser, this, [=](QString, QString user) { + connect(client_.data(), &MatrixClient::invitedUser, this, [this](QString, QString user) { emit showNotification(QString("Invited user %1").arg(user)); }); - connect(client_.data(), &MatrixClient::roomCreated, this, [=](QString room_id) { + connect(client_.data(), &MatrixClient::roomCreated, this, [this](QString room_id) { emit showNotification(QString("Room %1 created").arg(room_id)); }); connect(client_.data(), &MatrixClient::leftRoom, this, &ChatPage::removeRoom); showContentTimer_ = new QTimer(this); showContentTimer_->setSingleShot(true); - connect(showContentTimer_, &QTimer::timeout, this, [=]() { + connect(showContentTimer_, &QTimer::timeout, this, [this]() { consensusTimer_->stop(); emit contentLoaded(); }); consensusTimer_ = new QTimer(this); - connect(consensusTimer_, &QTimer::timeout, this, [=]() { + connect(consensusTimer_, &QTimer::timeout, this, [this]() { if (view_manager_->hasLoaded()) { // Remove the spinner overlay. emit contentLoaded(); @@ -361,7 +365,7 @@ ChatPage::ChatPage(QSharedPointer client, connect(initialSyncTimer_, &QTimer::timeout, this, &ChatPage::retryInitialSync); syncTimeoutTimer_ = new QTimer(this); - connect(syncTimeoutTimer_, &QTimer::timeout, this, [=]() { + connect(syncTimeoutTimer_, &QTimer::timeout, this, [this]() { if (client_->getHomeServer().isEmpty()) { syncTimeoutTimer_->stop(); return; @@ -374,7 +378,7 @@ ChatPage::ChatPage(QSharedPointer client, connect(communitiesList_, &CommunitiesList::communityChanged, this, - [=](const QString &communityId) { + [this](const QString &communityId) { current_community_ = communityId; if (communityId == "world") @@ -577,8 +581,8 @@ ChatPage::updateOwnProfileInfo(const QUrl &avatar_url, const QString &display_na if (avatar_url.isValid()) client_->fetchUserAvatar( avatar_url, - [=](QImage img) { user_info_widget_->setAvatar(img); }, - [=](QString error) { qWarning() << error << ": failed to fetch own avatar"; }); + [this](QImage img) { user_info_widget_->setAvatar(img); }, + [](QString error) { qWarning() << error << ": failed to fetch own avatar"; }); } void @@ -691,24 +695,24 @@ ChatPage::showQuickSwitcher() if (quickSwitcher_.isNull()) { quickSwitcher_ = QSharedPointer( new QuickSwitcher(this), - [=](QuickSwitcher *switcher) { switcher->deleteLater(); }); + [](QuickSwitcher *switcher) { switcher->deleteLater(); }); connect(quickSwitcher_.data(), &QuickSwitcher::roomSelected, room_list_, &RoomList::highlightSelectedRoom); - connect(quickSwitcher_.data(), &QuickSwitcher::closing, this, [=]() { - if (!this->quickSwitcherModal_.isNull()) - this->quickSwitcherModal_->hide(); - this->text_input_->setFocus(Qt::FocusReason::PopupFocusReason); + connect(quickSwitcher_.data(), &QuickSwitcher::closing, this, [this]() { + if (!quickSwitcherModal_.isNull()) + quickSwitcherModal_->hide(); + text_input_->setFocus(Qt::FocusReason::PopupFocusReason); }); } if (quickSwitcherModal_.isNull()) { quickSwitcherModal_ = QSharedPointer( new OverlayModal(MainWindow::instance(), quickSwitcher_.data()), - [=](OverlayModal *modal) { modal->deleteLater(); }); + [](OverlayModal *modal) { modal->deleteLater(); }); quickSwitcherModal_->setColor(QColor(30, 30, 30, 170)); } @@ -934,13 +938,13 @@ ChatPage::showReadReceipts(const QString &event_id) if (receiptsDialog_.isNull()) { receiptsDialog_ = QSharedPointer( new dialogs::ReadReceipts(this), - [=](dialogs::ReadReceipts *dialog) { dialog->deleteLater(); }); + [](dialogs::ReadReceipts *dialog) { dialog->deleteLater(); }); } if (receiptsModal_.isNull()) { receiptsModal_ = QSharedPointer( new OverlayModal(MainWindow::instance(), receiptsDialog_.data()), - [=](OverlayModal *modal) { modal->deleteLater(); }); + [](OverlayModal *modal) { modal->deleteLater(); }); receiptsModal_->setColor(QColor(30, 30, 30, 170)); } diff --git a/src/CommunitiesList.cc b/src/CommunitiesList.cc index 2814a6b..2f54793 100644 --- a/src/CommunitiesList.cc +++ b/src/CommunitiesList.cc @@ -47,7 +47,7 @@ CommunitiesList::CommunitiesList(QSharedPointer client, QWidget *p connect(client_.data(), &MatrixClient::communityProfileRetrieved, this, - [=](QString communityId, QJsonObject profile) { + [this](QString communityId, QJsonObject profile) { client_->fetchCommunityAvatar(communityId, QUrl(profile["avatar_url"].toString())); }); diff --git a/src/MainWindow.cc b/src/MainWindow.cc index 98d758b..56aef00 100644 --- a/src/MainWindow.cc +++ b/src/MainWindow.cc @@ -77,7 +77,8 @@ MainWindow::MainWindow(QWidget *parent) connect(login_page_, SIGNAL(backButtonClicked()), this, SLOT(showWelcomePage())); connect(login_page_, &LoginPage::loggingIn, this, &MainWindow::showOverlayProgressBar); - connect(login_page_, &LoginPage::errorOccured, this, [=]() { removeOverlayProgressBar(); }); + connect( + login_page_, &LoginPage::errorOccured, this, [this]() { removeOverlayProgressBar(); }); connect(register_page_, SIGNAL(backButtonClicked()), this, SLOT(showWelcomePage())); connect(chat_page_, SIGNAL(close()), this, SLOT(showWelcomePage())); @@ -86,12 +87,12 @@ MainWindow::MainWindow(QWidget *parent) connect( chat_page_, SIGNAL(changeWindowTitle(QString)), this, SLOT(setWindowTitle(QString))); connect(chat_page_, SIGNAL(unreadMessages(int)), trayIcon_, SLOT(setUnreadCount(int))); - connect(chat_page_, &ChatPage::showLoginPage, this, [=](const QString &msg) { + connect(chat_page_, &ChatPage::showLoginPage, this, [this](const QString &msg) { login_page_->loginError(msg); showLoginPage(); }); - connect(userSettingsPage_, &UserSettingsPage::moveBack, this, [=]() { + connect(userSettingsPage_, &UserSettingsPage::moveBack, this, [this]() { pageStack_->setCurrentWidget(chat_page_); }); @@ -116,7 +117,7 @@ MainWindow::MainWindow(QWidget *parent) connect(quitShortcut, &QShortcut::activated, this, QApplication::quit); QShortcut *quickSwitchShortcut = new QShortcut(QKeySequence("Ctrl+K"), this); - connect(quickSwitchShortcut, &QShortcut::activated, this, [=]() { + connect(quickSwitchShortcut, &QShortcut::activated, this, [this]() { chat_page_->showQuickSwitcher(); }); @@ -162,7 +163,7 @@ MainWindow::removeOverlayProgressBar() QTimer *timer = new QTimer(this); timer->setSingleShot(true); - connect(timer, &QTimer::timeout, [=]() { + connect(timer, &QTimer::timeout, [this, timer]() { timer->deleteLater(); if (!progressModal_.isNull()) @@ -176,7 +177,7 @@ MainWindow::removeOverlayProgressBar() }); // FIXME: Snackbar doesn't work if it's initialized in the constructor. - QTimer::singleShot(100, this, [=]() { + QTimer::singleShot(100, this, [this]() { snackBar_ = QSharedPointer(new SnackBar(this)); connect(chat_page_, &ChatPage::showNotification, @@ -197,7 +198,7 @@ MainWindow::showChatPage(QString userid, QString homeserver, QString token) showOverlayProgressBar(); - QTimer::singleShot(100, this, [=]() { pageStack_->setCurrentWidget(chat_page_); }); + QTimer::singleShot(100, this, [this]() { pageStack_->setCurrentWidget(chat_page_); }); login_page_->reset(); chat_page_->bootstrap(userid, homeserver, token); @@ -250,12 +251,15 @@ MainWindow::openLeaveRoomDialog(const QString &room_id) leaveRoomDialog_ = QSharedPointer(new dialogs::LeaveRoom(this)); - connect(leaveRoomDialog_.data(), &dialogs::LeaveRoom::closing, this, [=](bool leaving) { - leaveRoomModal_->hide(); + connect(leaveRoomDialog_.data(), + &dialogs::LeaveRoom::closing, + this, + [this, &roomToLeave](bool leaving) { + leaveRoomModal_->hide(); - if (leaving) - client_->leaveRoom(roomToLeave); - }); + if (leaving) + client_->leaveRoom(roomToLeave); + }); leaveRoomModal_ = QSharedPointer(new OverlayModal(this, leaveRoomDialog_.data())); @@ -270,7 +274,7 @@ MainWindow::showOverlayProgressBar() if (spinner_.isNull()) { spinner_ = QSharedPointer( new LoadingIndicator(this), - [=](LoadingIndicator *indicator) { indicator->deleteLater(); }); + [](LoadingIndicator *indicator) { indicator->deleteLater(); }); spinner_->setFixedHeight(100); spinner_->setFixedWidth(100); spinner_->setObjectName("ChatPageLoadSpinner"); @@ -280,7 +284,7 @@ MainWindow::showOverlayProgressBar() if (progressModal_.isNull()) { progressModal_ = QSharedPointer(new OverlayModal(this, spinner_.data()), - [=](OverlayModal *modal) { modal->deleteLater(); }); + [](OverlayModal *modal) { modal->deleteLater(); }); progressModal_->setDismissible(false); progressModal_->show(); } diff --git a/src/MatrixClient.cc b/src/MatrixClient.cc index fae0230..929a070 100644 --- a/src/MatrixClient.cc +++ b/src/MatrixClient.cc @@ -76,7 +76,7 @@ MatrixClient::MatrixClient(QString server, QObject *parent) connect(this, &QNetworkAccessManager::networkAccessibleChanged, this, - [=](NetworkAccessibility status) { + [this](NetworkAccessibility status) { if (status != NetworkAccessibility::Accessible) setNetworkAccessible(NetworkAccessibility::Accessible); }); diff --git a/src/QuickSwitcher.cc b/src/QuickSwitcher.cc index 6cc8250..5fcc577 100644 --- a/src/QuickSwitcher.cc +++ b/src/QuickSwitcher.cc @@ -23,7 +23,8 @@ RoomSearchInput::RoomSearchInput(QWidget *parent) : TextField(parent) -{} +{ +} bool RoomSearchInput::focusNextPrevChild(bool next) @@ -78,7 +79,7 @@ QuickSwitcher::QuickSwitcher(QWidget *parent) topLayout_->addWidget(roomSearch_); connect(completer_, SIGNAL(highlighted(QString)), roomSearch_, SLOT(setText(QString))); - connect(roomSearch_, &QLineEdit::textEdited, this, [=](const QString &prefix) { + connect(roomSearch_, &QLineEdit::textEdited, this, [this](const QString &prefix) { if (prefix.isEmpty()) { completer_->popup()->hide(); selection_ = -1; @@ -96,7 +97,7 @@ QuickSwitcher::QuickSwitcher(QWidget *parent) completer_->complete(); }); - connect(roomSearch_, &RoomSearchInput::selectNextCompletion, this, [=]() { + connect(roomSearch_, &RoomSearchInput::selectNextCompletion, this, [this]() { selection_ += 1; if (!completer_->setCurrentRow(selection_)) { @@ -107,7 +108,7 @@ QuickSwitcher::QuickSwitcher(QWidget *parent) completer_->popup()->setCurrentIndex(completer_->currentIndex()); }); - connect(roomSearch_, &RoomSearchInput::selectPreviousCompletion, this, [=]() { + connect(roomSearch_, &RoomSearchInput::selectPreviousCompletion, this, [this]() { selection_ -= 1; if (!completer_->setCurrentRow(selection_)) { @@ -119,8 +120,8 @@ QuickSwitcher::QuickSwitcher(QWidget *parent) }); connect( - roomSearch_, &RoomSearchInput::hiding, this, [=]() { completer_->popup()->hide(); }); - connect(roomSearch_, &QLineEdit::returnPressed, this, [=]() { + roomSearch_, &RoomSearchInput::hiding, this, [this]() { completer_->popup()->hide(); }); + connect(roomSearch_, &QLineEdit::returnPressed, this, [this]() { emit closing(); QString text(""); diff --git a/src/RoomInfoListItem.cc b/src/RoomInfoListItem.cc index 29d7d33..9d4a16d 100644 --- a/src/RoomInfoListItem.cc +++ b/src/RoomInfoListItem.cc @@ -84,12 +84,12 @@ RoomInfoListItem::RoomInfoListItem(QSharedPointer settings, menu_ = new Menu(this); toggleNotifications_ = new QAction(notificationText(), this); - connect(toggleNotifications_, &QAction::triggered, this, [=]() { + connect(toggleNotifications_, &QAction::triggered, this, [this]() { roomSettings_->toggleNotifications(); }); leaveRoom_ = new QAction(tr("Leave room"), this); - connect(leaveRoom_, &QAction::triggered, this, [=]() { emit leaveRoom(room_id); }); + connect(leaveRoom_, &QAction::triggered, this, [this]() { emit leaveRoom(roomId_); }); menu_->addAction(toggleNotifications_); menu_->addAction(leaveRoom_); diff --git a/src/RoomList.cc b/src/RoomList.cc index 8a6d415..13bc0d4 100644 --- a/src/RoomList.cc +++ b/src/RoomList.cc @@ -62,10 +62,10 @@ RoomList::RoomList(QSharedPointer client, connect(client_.data(), &MatrixClient::roomAvatarRetrieved, this, - [=](const QString &room_id, - const QPixmap &img, - const QString &url, - const QByteArray &data) { + [this](const QString &room_id, + const QPixmap &img, + const QString &url, + const QByteArray &data) { if (!cache_.isNull()) cache_->saveImage(url, data); @@ -86,7 +86,7 @@ RoomList::addRoom(const QSharedPointer &settings, { auto room_item = new RoomInfoListItem(settings, state, room_id, scrollArea_); connect(room_item, &RoomInfoListItem::clicked, this, &RoomList::highlightSelectedRoom); - connect(room_item, &RoomInfoListItem::leaveRoom, this, [=](const QString &room_id) { + connect(room_item, &RoomInfoListItem::leaveRoom, this, [](const QString &room_id) { MainWindow::instance()->openLeaveRoomDialog(room_id); }); diff --git a/src/SideBarActions.cc b/src/SideBarActions.cc index 9c78401..0504f4d 100644 --- a/src/SideBarActions.cc +++ b/src/SideBarActions.cc @@ -34,7 +34,7 @@ SideBarActions::SideBarActions(QWidget *parent) createRoomAction_ = new QAction(tr("Create new room"), this); joinRoomAction_ = new QAction(tr("Join a room"), this); - connect(joinRoomAction_, &QAction::triggered, this, [=]() { + connect(joinRoomAction_, &QAction::triggered, this, [this]() { if (joinRoomDialog_.isNull()) { joinRoomDialog_ = QSharedPointer(new dialogs::JoinRoom(this)); @@ -42,7 +42,7 @@ SideBarActions::SideBarActions(QWidget *parent) connect(joinRoomDialog_.data(), &dialogs::JoinRoom::closing, this, - [=](bool isJoining, const QString &room) { + [this](bool isJoining, const QString &room) { joinRoomModal_->hide(); if (isJoining && !room.isEmpty()) @@ -59,7 +59,7 @@ SideBarActions::SideBarActions(QWidget *parent) joinRoomModal_->show(); }); - connect(createRoomAction_, &QAction::triggered, this, [=]() { + connect(createRoomAction_, &QAction::triggered, this, [this]() { if (createRoomDialog_.isNull()) { createRoomDialog_ = QSharedPointer(new dialogs::CreateRoom(this)); @@ -67,7 +67,7 @@ SideBarActions::SideBarActions(QWidget *parent) connect(createRoomDialog_.data(), &dialogs::CreateRoom::closing, this, - [=](bool isCreating, const mtx::requests::CreateRoom &request) { + [this](bool isCreating, const mtx::requests::CreateRoom &request) { createRoomModal_->hide(); if (isCreating) @@ -93,7 +93,7 @@ SideBarActions::SideBarActions(QWidget *parent) createRoomBtn_->setIconSize( QSize(conf::sidebarActions::iconSize, conf::sidebarActions::iconSize)); - connect(createRoomBtn_, &QPushButton::clicked, this, [=]() { + connect(createRoomBtn_, &QPushButton::clicked, this, [this]() { auto pos = mapToGlobal(createRoomBtn_->pos()); auto padding = conf::sidebarActions::iconSize / 2; diff --git a/src/TextInputWidget.cc b/src/TextInputWidget.cc index 4927d19..c293141 100644 --- a/src/TextInputWidget.cc +++ b/src/TextInputWidget.cc @@ -47,7 +47,7 @@ FilteredTextEdit::FilteredTextEdit(QWidget *parent) connect(document()->documentLayout(), &QAbstractTextDocumentLayout::documentSizeChanged, this, - [=]() { emit heightChanged(document()->size().toSize().height()); }); + [this]() { emit heightChanged(document()->size().toSize().height()); }); working_history_.push_back(""); connect(this, &QTextEdit::textChanged, this, &FilteredTextEdit::textChanged); setAcceptRichText(false); @@ -330,7 +330,7 @@ TextInputWidget::TextInputWidget(QWidget *parent) input_->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); input_->setPlaceholderText(tr("Write a message...")); - connect(input_, &FilteredTextEdit::heightChanged, this, [=](int height) { + connect(input_, &FilteredTextEdit::heightChanged, this, [this](int height) { int textInputHeight = std::min(MAX_TEXTINPUT_HEIGHT, std::max(height, 32)); int widgetHeight = std::min(MAX_TEXTINPUT_HEIGHT, std::max(height, conf::textInput::height)); diff --git a/src/TopRoomBar.cc b/src/TopRoomBar.cc index 5dae10f..d5f8804 100644 --- a/src/TopRoomBar.cc +++ b/src/TopRoomBar.cc @@ -62,7 +62,7 @@ TopRoomBar::TopRoomBar(QWidget *parent) topicLabel_->setTextFormat(Qt::RichText); topicLabel_->setTextInteractionFlags(Qt::TextBrowserInteraction); topicLabel_->setOpenExternalLinks(true); - connect(topicLabel_, &Label::clicked, [=](QMouseEvent *e) { + connect(topicLabel_, &Label::clicked, [this](QMouseEvent *e) { if (e->button() == Qt::LeftButton && !topicLabel_->hasSelectedText()) topicLabel_->setWordWrap(!topicLabel_->wordWrap()); }); @@ -86,12 +86,12 @@ TopRoomBar::TopRoomBar(QWidget *parent) menu_ = new Menu(this); toggleNotifications_ = new QAction(tr("Disable notifications"), this); - connect(toggleNotifications_, &QAction::triggered, this, [=]() { + connect(toggleNotifications_, &QAction::triggered, this, [this]() { roomSettings_->toggleNotifications(); }); inviteUsers_ = new QAction(tr("Invite users"), this); - connect(inviteUsers_, &QAction::triggered, this, [=]() { + connect(inviteUsers_, &QAction::triggered, this, [this]() { if (inviteUsersDialog_.isNull()) { inviteUsersDialog_ = QSharedPointer(new dialogs::InviteUsers(this)); @@ -99,7 +99,7 @@ TopRoomBar::TopRoomBar(QWidget *parent) connect(inviteUsersDialog_.data(), &dialogs::InviteUsers::closing, this, - [=](bool isSending, QStringList invitees) { + [this](bool isSending, QStringList invitees) { inviteUsersModal_->hide(); if (isSending && !invitees.isEmpty()) @@ -117,7 +117,7 @@ TopRoomBar::TopRoomBar(QWidget *parent) }); leaveRoom_ = new QAction(tr("Leave room"), this); - connect(leaveRoom_, &QAction::triggered, this, [=]() { + connect(leaveRoom_, &QAction::triggered, this, []() { MainWindow::instance()->openLeaveRoomDialog(); }); @@ -125,7 +125,7 @@ TopRoomBar::TopRoomBar(QWidget *parent) menu_->addAction(inviteUsers_); menu_->addAction(leaveRoom_); - connect(settingsBtn_, &QPushButton::clicked, this, [=]() { + connect(settingsBtn_, &QPushButton::clicked, this, [this]() { if (roomSettings_.isNull()) return; diff --git a/src/UserInfoWidget.cc b/src/UserInfoWidget.cc index 5125b86..273a609 100644 --- a/src/UserInfoWidget.cc +++ b/src/UserInfoWidget.cc @@ -90,7 +90,7 @@ UserInfoWidget::UserInfoWidget(QWidget *parent) topLayout_->addLayout(buttonLayout_); // Show the confirmation dialog. - connect(logoutButton_, &QPushButton::clicked, this, [=]() { + connect(logoutButton_, &QPushButton::clicked, this, [this]() { if (logoutDialog_.isNull()) { logoutDialog_ = QSharedPointer(new dialogs::Logout(this)); connect(logoutDialog_.data(), diff --git a/src/UserSettingsPage.cc b/src/UserSettingsPage.cc index cff29af..6c966de 100644 --- a/src/UserSettingsPage.cc +++ b/src/UserSettingsPage.cc @@ -204,26 +204,26 @@ UserSettingsPage::UserSettingsPage(QSharedPointer settings, QWidge connect(themeCombo_, static_cast(&QComboBox::activated), - [=](const QString &text) { settings_->setTheme(text.toLower()); }); + [this](const QString &text) { settings_->setTheme(text.toLower()); }); - connect(trayToggle_, &Toggle::toggled, this, [=](bool isDisabled) { + connect(trayToggle_, &Toggle::toggled, this, [this](bool isDisabled) { settings_->setTray(!isDisabled); emit trayOptionChanged(!isDisabled); }); - connect(roomOrderToggle_, &Toggle::toggled, this, [=](bool isDisabled) { + connect(roomOrderToggle_, &Toggle::toggled, this, [this](bool isDisabled) { settings_->setRoomOrdering(!isDisabled); }); - connect(groupViewToggle_, &Toggle::toggled, this, [=](bool isDisabled) { + connect(groupViewToggle_, &Toggle::toggled, this, [this](bool isDisabled) { settings_->setGroupView(!isDisabled); }); - connect(typingNotifications_, &Toggle::toggled, this, [=](bool isDisabled) { + connect(typingNotifications_, &Toggle::toggled, this, [this](bool isDisabled) { settings_->setTypingNotifications(!isDisabled); }); - connect(backBtn_, &QPushButton::clicked, this, [=]() { + connect(backBtn_, &QPushButton::clicked, this, [this]() { settings_->save(); emit moveBack(); }); diff --git a/src/dialogs/CreateRoom.cc b/src/dialogs/CreateRoom.cc index 0bda0d0..8c2cc64 100644 --- a/src/dialogs/CreateRoom.cc +++ b/src/dialogs/CreateRoom.cc @@ -93,7 +93,7 @@ CreateRoom::CreateRoom(QWidget *parent) layout->addLayout(directLayout); layout->addLayout(buttonLayout); - connect(confirmBtn_, &QPushButton::clicked, this, [=]() { + connect(confirmBtn_, &QPushButton::clicked, this, [this]() { request_.name = nameInput_->text().toStdString(); request_.topic = topicInput_->text().toStdString(); request_.room_alias_name = aliasInput_->text().toStdString(); @@ -103,7 +103,7 @@ CreateRoom::CreateRoom(QWidget *parent) clearFields(); }); - connect(cancelBtn_, &QPushButton::clicked, this, [=]() { + connect(cancelBtn_, &QPushButton::clicked, this, [this]() { emit closing(false, request_); clearFields(); @@ -111,7 +111,7 @@ CreateRoom::CreateRoom(QWidget *parent) connect(visibilityCombo_, static_cast(&QComboBox::activated), - [=](const QString &text) { + [this](const QString &text) { if (text == "Private") { request_.visibility = mtx::requests::Visibility::Private; } else { @@ -121,7 +121,7 @@ CreateRoom::CreateRoom(QWidget *parent) connect(presetCombo_, static_cast(&QComboBox::activated), - [=](const QString &text) { + [this](const QString &text) { if (text == "Private Chat") { request_.preset = mtx::requests::Preset::PrivateChat; } else if (text == "Public Chat") { @@ -131,7 +131,7 @@ CreateRoom::CreateRoom(QWidget *parent) } }); - connect(directToggle_, &Toggle::toggled, this, [=](bool isDisabled) { + connect(directToggle_, &Toggle::toggled, this, [this](bool isDisabled) { request_.is_direct = !isDisabled; }); } diff --git a/src/dialogs/InviteUsers.cc b/src/dialogs/InviteUsers.cc index d46ca17..71cfdf2 100644 --- a/src/dialogs/InviteUsers.cc +++ b/src/dialogs/InviteUsers.cc @@ -63,7 +63,7 @@ InviteUsers::InviteUsers(QWidget *parent) layout->addLayout(buttonLayout); connect(inviteeInput_, &TextField::returnPressed, this, &InviteUsers::addUser); - connect(confirmBtn_, &QPushButton::clicked, [=]() { + connect(confirmBtn_, &QPushButton::clicked, [this]() { emit closing(true, invitedUsers()); inviteeInput_->clear(); @@ -71,7 +71,7 @@ InviteUsers::InviteUsers(QWidget *parent) errorLabel_->hide(); }); - connect(cancelBtn_, &QPushButton::clicked, [=]() { + connect(cancelBtn_, &QPushButton::clicked, [this]() { QStringList emptyList; emit closing(false, emptyList); diff --git a/src/dialogs/JoinRoom.cc b/src/dialogs/JoinRoom.cc index 51f7d53..d6e8301 100644 --- a/src/dialogs/JoinRoom.cc +++ b/src/dialogs/JoinRoom.cc @@ -44,11 +44,11 @@ JoinRoom::JoinRoom(QWidget *parent) layout->addLayout(buttonLayout); // TODO: input validation with error messages. - connect(confirmBtn_, &QPushButton::clicked, [=]() { + connect(confirmBtn_, &QPushButton::clicked, [this]() { emit closing(true, roomInput_->text()); roomInput_->clear(); }); - connect(cancelBtn_, &QPushButton::clicked, [=]() { emit closing(false, ""); }); + connect(cancelBtn_, &QPushButton::clicked, [this]() { emit closing(false, ""); }); } void diff --git a/src/dialogs/LeaveRoom.cc b/src/dialogs/LeaveRoom.cc index 6a8447d..508353c 100644 --- a/src/dialogs/LeaveRoom.cc +++ b/src/dialogs/LeaveRoom.cc @@ -42,8 +42,8 @@ LeaveRoom::LeaveRoom(QWidget *parent) layout->addWidget(label); layout->addLayout(buttonLayout); - connect(confirmBtn_, &QPushButton::clicked, [=]() { emit closing(true); }); - connect(cancelBtn_, &QPushButton::clicked, [=]() { emit closing(false); }); + connect(confirmBtn_, &QPushButton::clicked, [this]() { emit closing(true); }); + connect(cancelBtn_, &QPushButton::clicked, [this]() { emit closing(false); }); } void diff --git a/src/dialogs/Logout.cc b/src/dialogs/Logout.cc index f4752b0..99913b0 100644 --- a/src/dialogs/Logout.cc +++ b/src/dialogs/Logout.cc @@ -60,8 +60,8 @@ Logout::Logout(QWidget *parent) layout->addWidget(label); layout->addLayout(buttonLayout); - connect(confirmBtn_, &QPushButton::clicked, [=]() { emit closing(true); }); - connect(cancelBtn_, &QPushButton::clicked, [=]() { emit closing(false); }); + connect(confirmBtn_, &QPushButton::clicked, [this]() { emit closing(true); }); + connect(cancelBtn_, &QPushButton::clicked, [this]() { emit closing(false); }); } void diff --git a/src/dialogs/PreviewUploadOverlay.cc b/src/dialogs/PreviewUploadOverlay.cc index c535609..3c44e91 100644 --- a/src/dialogs/PreviewUploadOverlay.cc +++ b/src/dialogs/PreviewUploadOverlay.cc @@ -51,7 +51,7 @@ PreviewUploadOverlay::PreviewUploadOverlay(QWidget *parent) vlayout->addWidget(&fileName_); vlayout->addLayout(hlayout); - connect(&upload_, &QPushButton::clicked, [&]() { + connect(&upload_, &QPushButton::clicked, [this]() { emit confirmUpload(data_, mediaType_, fileName_.text()); close(); }); diff --git a/src/dialogs/ReadReceipts.cc b/src/dialogs/ReadReceipts.cc index be79c7a..3615d62 100644 --- a/src/dialogs/ReadReceipts.cc +++ b/src/dialogs/ReadReceipts.cc @@ -51,7 +51,7 @@ ReceiptItem::ReceiptItem(QWidget *parent, const QString &user_id, uint64_t times topLayout_->addWidget(avatar_); topLayout_->addLayout(textLayout_, 1); - AvatarProvider::resolve(user_id, [=](const QImage &img) { avatar_->setImage(img); }); + AvatarProvider::resolve(user_id, [this](const QImage &img) { avatar_->setImage(img); }); } QString diff --git a/src/timeline/TimelineItem.cc b/src/timeline/TimelineItem.cc index 7756ba4..02f2247 100644 --- a/src/timeline/TimelineItem.cc +++ b/src/timeline/TimelineItem.cc @@ -47,7 +47,7 @@ TimelineItem::init() receiptsMenu_ = new QMenu(this); showReadReceipts_ = new QAction("Read receipts", this); receiptsMenu_->addAction(showReadReceipts_); - connect(showReadReceipts_, &QAction::triggered, this, [=]() { + connect(showReadReceipts_, &QAction::triggered, this, [this]() { if (!event_id_.isEmpty()) ChatPage::instance()->showReadReceipts(event_id_); }); @@ -111,7 +111,7 @@ TimelineItem::TimelineItem(mtx::events::MessageType ty, messageLayout_->addLayout(headerLayout_, 1); - AvatarProvider::resolve(userid, [=](const QImage &img) { setUserAvatar(img); }); + AvatarProvider::resolve(userid, [this](const QImage &img) { setUserAvatar(img); }); } else { generateBody(body); setupSimpleLayout(); @@ -243,7 +243,7 @@ TimelineItem::TimelineItem(const mtx::events::RoomEventaddLayout(headerLayout_, 1); - AvatarProvider::resolve(sender, [=](const QImage &img) { setUserAvatar(img); }); + AvatarProvider::resolve(sender, [this](const QImage &img) { setUserAvatar(img); }); } else { generateBody(body); setupSimpleLayout(); @@ -290,7 +290,7 @@ TimelineItem::TimelineItem(const mtx::events::RoomEvent messageLayout_->addLayout(headerLayout_, 1); - AvatarProvider::resolve(sender, [=](const QImage &img) { setUserAvatar(img); }); + AvatarProvider::resolve(sender, [this](const QImage &img) { setUserAvatar(img); }); } else { generateBody(emoteMsg); setupSimpleLayout(); @@ -342,7 +342,7 @@ TimelineItem::TimelineItem(const mtx::events::RoomEvent messageLayout_->addLayout(headerLayout_, 1); - AvatarProvider::resolve(sender, [=](const QImage &img) { setUserAvatar(img); }); + AvatarProvider::resolve(sender, [this](const QImage &img) { setUserAvatar(img); }); } else { generateBody(body); setupSimpleLayout(); diff --git a/src/timeline/TimelineView.cc b/src/timeline/TimelineView.cc index 82f22d1..999d608 100644 --- a/src/timeline/TimelineView.cc +++ b/src/timeline/TimelineView.cc @@ -369,7 +369,7 @@ TimelineView::init() scrollDownBtn_->setForegroundColor(QColor("black")); scrollDownBtn_->hide(); - connect(scrollDownBtn_, &QPushButton::clicked, this, [=]() { + connect(scrollDownBtn_, &QPushButton::clicked, this, [this]() { const int max = scroll_area_->verticalScrollBar()->maximum(); scroll_area_->verticalScrollBar()->setValue(max); }); diff --git a/src/timeline/widgets/AudioItem.cc b/src/timeline/widgets/AudioItem.cc index 6054d70..f171e78 100644 --- a/src/timeline/widgets/AudioItem.cc +++ b/src/timeline/widgets/AudioItem.cc @@ -65,7 +65,7 @@ AudioItem::init() player_->setNotifyInterval(1000); connect(client_.data(), &MatrixClient::fileDownloaded, this, &AudioItem::fileDownloaded); - connect(player_, &QMediaPlayer::stateChanged, this, [=](QMediaPlayer::State state) { + connect(player_, &QMediaPlayer::stateChanged, this, [this](QMediaPlayer::State state) { if (state == QMediaPlayer::StoppedState) { state_ = AudioState::Play; player_->setMedia(QUrl(url_));