Don't capture 'this' implicitely
This commit is contained in:
@@ -72,7 +72,7 @@ Controller::Controller(QObject *parent)
|
||||
connect(trayIcon, &TrayIcon::showWindow, this, &Controller::showWindow);
|
||||
QGuiApplication::setQuitOnLastWindowClosed(false);
|
||||
}
|
||||
connect(NeoChatConfig::self(), &NeoChatConfig::SystemTrayChanged, this, [=]() {
|
||||
connect(NeoChatConfig::self(), &NeoChatConfig::SystemTrayChanged, this, [this, trayIcon]() {
|
||||
if (NeoChatConfig::self()->systemTray()) {
|
||||
trayIcon->show();
|
||||
connect(trayIcon, &TrayIcon::showWindow, this, &Controller::showWindow);
|
||||
@@ -84,7 +84,7 @@ Controller::Controller(QObject *parent)
|
||||
});
|
||||
#endif
|
||||
|
||||
QTimer::singleShot(0, this, [=] {
|
||||
QTimer::singleShot(0, this, [this] {
|
||||
invokeLogin();
|
||||
});
|
||||
|
||||
@@ -152,7 +152,7 @@ void Controller::loginWithAccessToken(const QString &serverAddr, const QString &
|
||||
conn->setHomeserver(serverUrl);
|
||||
}
|
||||
|
||||
connect(conn, &Connection::connected, this, [=] {
|
||||
connect(conn, &Connection::connected, this, [this, conn, deviceName] {
|
||||
AccountSettings account(conn->userId());
|
||||
account.setKeepLoggedIn(true);
|
||||
account.setHomeserver(conn->homeserver());
|
||||
@@ -165,7 +165,7 @@ void Controller::loginWithAccessToken(const QString &serverAddr, const QString &
|
||||
addConnection(conn);
|
||||
setActiveConnection(conn);
|
||||
});
|
||||
connect(conn, &Connection::networkError, this, [=](QString error, const QString &, int, int) {
|
||||
connect(conn, &Connection::networkError, this, [this](QString error, const QString &, int, int) {
|
||||
Q_EMIT errorOccured(i18n("Network Error: %1", error));
|
||||
});
|
||||
conn->assumeIdentity(user, token, deviceName);
|
||||
@@ -210,7 +210,7 @@ void Controller::addConnection(Connection *c)
|
||||
|
||||
c->setLazyLoading(true);
|
||||
|
||||
connect(c, &Connection::syncDone, this, [=] {
|
||||
connect(c, &Connection::syncDone, this, [this, c] {
|
||||
setBusy(false);
|
||||
|
||||
Q_EMIT syncDone();
|
||||
@@ -218,11 +218,11 @@ void Controller::addConnection(Connection *c)
|
||||
c->sync(30000);
|
||||
c->saveState();
|
||||
});
|
||||
connect(c, &Connection::loggedOut, this, [=] {
|
||||
connect(c, &Connection::loggedOut, this, [this, c] {
|
||||
dropConnection(c);
|
||||
});
|
||||
|
||||
connect(c, &Connection::requestFailed, this, [=](BaseJob *job) {
|
||||
connect(c, &Connection::requestFailed, this, [this](BaseJob *job) {
|
||||
if (job->error() == BaseJob::UserConsentRequiredError) {
|
||||
Q_EMIT userConsentRequired(job->errorUrl());
|
||||
}
|
||||
@@ -265,7 +265,7 @@ void Controller::invokeLogin()
|
||||
auto accessToken = loadAccessTokenFromKeyChain(account);
|
||||
|
||||
auto connection = new Connection(account.homeserver());
|
||||
connect(connection, &Connection::connected, this, [=] {
|
||||
connect(connection, &Connection::connected, this, [this, connection, id] {
|
||||
connection->loadState();
|
||||
addConnection(connection);
|
||||
if (connection->userId() == id) {
|
||||
@@ -273,7 +273,7 @@ void Controller::invokeLogin()
|
||||
connectSingleShot(connection, &Connection::syncDone, this, &Controller::initiated);
|
||||
}
|
||||
});
|
||||
connect(connection, &Connection::loginError, this, [=](const QString &error, const QString &) {
|
||||
connect(connection, &Connection::loginError, this, [this, connection](const QString &error, const QString &) {
|
||||
if (error == "Unrecognised access token") {
|
||||
Q_EMIT errorOccured(i18n("Login Failed: Access Token invalid or revoked"));
|
||||
logout(connection, false);
|
||||
@@ -283,7 +283,7 @@ void Controller::invokeLogin()
|
||||
}
|
||||
Q_EMIT initiated();
|
||||
});
|
||||
connect(connection, &Connection::networkError, this, [=](const QString &error, const QString &, int, int) {
|
||||
connect(connection, &Connection::networkError, this, [this](const QString &error, const QString &, int, int) {
|
||||
Q_EMIT errorOccured(i18n("Network Error: %1", error));
|
||||
});
|
||||
connection->assumeIdentity(account.userId(), accessToken, account.deviceId());
|
||||
@@ -386,7 +386,7 @@ void Controller::playAudio(const QUrl &localFile)
|
||||
auto player = new QMediaPlayer;
|
||||
player->setMedia(localFile);
|
||||
player->play();
|
||||
connect(player, &QMediaPlayer::stateChanged, [=] {
|
||||
connect(player, &QMediaPlayer::stateChanged, [player] {
|
||||
player->deleteLater();
|
||||
});
|
||||
}
|
||||
@@ -574,7 +574,7 @@ NeochatDeleteDeviceJob::NeochatDeleteDeviceJob(const QString &deviceId, const Om
|
||||
void Controller::createRoom(const QString &name, const QString &topic)
|
||||
{
|
||||
auto createRoomJob = m_connection->createRoom(Connection::PublishRoom, "", name, topic, QStringList());
|
||||
Quotient::CreateRoomJob::connect(createRoomJob, &CreateRoomJob::failure, [=] {
|
||||
Quotient::CreateRoomJob::connect(createRoomJob, &CreateRoomJob::failure, [this, createRoomJob] {
|
||||
Q_EMIT errorOccured(i18n("Room creation failed: \"%1\"", createRoomJob->errorString()));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ void DevicesModel::setName(int index, const QString &name)
|
||||
beginResetModel();
|
||||
m_devices[index].displayName = name;
|
||||
endResetModel();
|
||||
connect(job, &BaseJob::failure, this, [=]() {
|
||||
connect(job, &BaseJob::failure, this, [this, index, oldName]() {
|
||||
beginResetModel();
|
||||
m_devices[index].displayName = oldName;
|
||||
endResetModel();
|
||||
|
||||
@@ -27,7 +27,7 @@ void Login::init()
|
||||
m_supportsPassword = false;
|
||||
m_ssoUrl = QUrl();
|
||||
|
||||
connect(this, &Login::matrixIdChanged, this, [=]() {
|
||||
connect(this, &Login::matrixIdChanged, this, [this]() {
|
||||
setHomeserverReachable(false);
|
||||
|
||||
if (m_matrixId == "@") {
|
||||
@@ -40,7 +40,7 @@ void Login::init()
|
||||
m_connection = new Connection();
|
||||
}
|
||||
m_connection->resolveServer(m_matrixId);
|
||||
connectSingleShot(m_connection, &Connection::loginFlowsChanged, this, [=]() {
|
||||
connectSingleShot(m_connection, &Connection::loginFlowsChanged, this, [this]() {
|
||||
setHomeserverReachable(true);
|
||||
m_testing = false;
|
||||
Q_EMIT testingChanged();
|
||||
@@ -49,7 +49,7 @@ void Login::init()
|
||||
Q_EMIT loginFlowsChanged();
|
||||
});
|
||||
});
|
||||
connect(m_connection, &Connection::connected, this, [=] {
|
||||
connect(m_connection, &Connection::connected, this, [this] {
|
||||
Q_EMIT connected();
|
||||
m_isLoggingIn = false;
|
||||
Q_EMIT isLoggingInChanged();
|
||||
@@ -67,22 +67,22 @@ void Login::init()
|
||||
Controller::instance().setActiveConnection(m_connection);
|
||||
m_connection = nullptr;
|
||||
});
|
||||
connect(m_connection, &Connection::networkError, this, [=](QString error, const QString &, int, int) {
|
||||
connect(m_connection, &Connection::networkError, this, [this](QString error, const QString &, int, int) {
|
||||
Q_EMIT Controller::instance().globalErrorOccured(i18n("Network Error"), std::move(error));
|
||||
m_isLoggingIn = false;
|
||||
Q_EMIT isLoggingInChanged();
|
||||
});
|
||||
connect(m_connection, &Connection::loginError, this, [=](QString error, const QString &) {
|
||||
connect(m_connection, &Connection::loginError, this, [this](QString error, const QString &) {
|
||||
Q_EMIT errorOccured(i18n("Login Failed: %1", error));
|
||||
m_isLoggingIn = false;
|
||||
Q_EMIT isLoggingInChanged();
|
||||
});
|
||||
|
||||
connect(m_connection, &Connection::resolveError, this, [=](QString error) {
|
||||
connect(m_connection, &Connection::resolveError, this, [](QString error) {
|
||||
Q_EMIT Controller::instance().globalErrorOccured(i18n("Network Error"), std::move(error));
|
||||
});
|
||||
|
||||
connectSingleShot(m_connection, &Connection::syncDone, this, [=]() {
|
||||
connectSingleShot(m_connection, &Connection::syncDone, this, [this]() {
|
||||
Q_EMIT Controller::instance().initiated();
|
||||
});
|
||||
}
|
||||
@@ -160,7 +160,7 @@ QUrl Login::ssoUrl() const
|
||||
void Login::loginWithSso()
|
||||
{
|
||||
m_connection->resolveServer(m_matrixId);
|
||||
connectSingleShot(m_connection, &Connection::loginFlowsChanged, this, [=]() {
|
||||
connectSingleShot(m_connection, &Connection::loginFlowsChanged, this, [this]() {
|
||||
SsoSession *session = m_connection->prepareForSso(m_deviceName);
|
||||
m_ssoUrl = session->ssoUrl();
|
||||
});
|
||||
|
||||
@@ -58,12 +58,12 @@ MessageEventModel::MessageEventModel(QObject *parent)
|
||||
qmlRegisterAnonymousType<FileTransferInfo>("org.kde.neochat", 1);
|
||||
qRegisterMetaType<FileTransferInfo>();
|
||||
|
||||
QTimer::singleShot(0, this, [=]() {
|
||||
QTimer::singleShot(0, this, [this]() {
|
||||
if (!m_currentRoom) {
|
||||
return;
|
||||
}
|
||||
m_currentRoom->getPreviousContent(50);
|
||||
connect(this, &QAbstractListModel::rowsInserted, this, [=]() {
|
||||
connect(this, &QAbstractListModel::rowsInserted, this, [this]() {
|
||||
if (m_currentRoom->readMarkerEventId().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
@@ -98,7 +98,7 @@ void MessageEventModel::setRoom(NeoChatRoom *room)
|
||||
lastReadEventId = room->readMarkerEventId();
|
||||
|
||||
using namespace Quotient;
|
||||
connect(m_currentRoom, &Room::aboutToAddNewMessages, this, [=](RoomEventsRange events) {
|
||||
connect(m_currentRoom, &Room::aboutToAddNewMessages, this, [this](RoomEventsRange events) {
|
||||
if (NeoChatConfig::self()->showFancyEffects()) {
|
||||
for (auto &event : events) {
|
||||
RoomMessageEvent *message = dynamic_cast<RoomMessageEvent *>(event.get());
|
||||
@@ -134,13 +134,13 @@ void MessageEventModel::setRoom(NeoChatRoom *room)
|
||||
}
|
||||
beginInsertRows({}, timelineBaseIndex(), timelineBaseIndex() + int(events.size()) - 1);
|
||||
});
|
||||
connect(m_currentRoom, &Room::aboutToAddHistoricalMessages, this, [=](RoomEventsRange events) {
|
||||
connect(m_currentRoom, &Room::aboutToAddHistoricalMessages, this, [this](RoomEventsRange events) {
|
||||
if (rowCount() > 0) {
|
||||
rowBelowInserted = rowCount() - 1; // See #312
|
||||
}
|
||||
beginInsertRows({}, rowCount(), rowCount() + int(events.size()) - 1);
|
||||
});
|
||||
connect(m_currentRoom, &Room::addedMessages, this, [=](int lowest, int biggest) {
|
||||
connect(m_currentRoom, &Room::addedMessages, this, [this](int lowest, int biggest) {
|
||||
endInsertRows();
|
||||
if (!m_lastReadEventIndex.isValid()) {
|
||||
// no read marker, so see if we need to create one.
|
||||
@@ -184,7 +184,7 @@ void MessageEventModel::setRoom(NeoChatRoom *room)
|
||||
beginRemoveRows({}, i, i);
|
||||
});
|
||||
connect(m_currentRoom, &Room::pendingEventDiscarded, this, &MessageEventModel::endRemoveRows);
|
||||
connect(m_currentRoom, &Room::readMarkerMoved, this, [=](const QString &fromEventId, const QString &toEventId) {
|
||||
connect(m_currentRoom, &Room::readMarkerMoved, this, [this](const QString &fromEventId, const QString &toEventId) {
|
||||
Q_UNUSED(fromEventId);
|
||||
moveReadMarker(toEventId);
|
||||
});
|
||||
@@ -203,7 +203,7 @@ void MessageEventModel::setRoom(NeoChatRoom *room)
|
||||
#ifndef QUOTIENT_07
|
||||
connect(m_currentRoom, &Room::fileTransferCancelled, this, &MessageEventModel::refreshEvent);
|
||||
#endif
|
||||
connect(m_currentRoom->connection(), &Connection::ignoredUsersListChanged, this, [=] {
|
||||
connect(m_currentRoom->connection(), &Connection::ignoredUsersListChanged, this, [this] {
|
||||
beginResetModel();
|
||||
endResetModel();
|
||||
});
|
||||
|
||||
@@ -43,7 +43,7 @@ NeoChatRoom::NeoChatRoom(Connection *connection, QString roomId, JoinState joinS
|
||||
{
|
||||
connect(this, &NeoChatRoom::notificationCountChanged, this, &NeoChatRoom::countChanged);
|
||||
connect(this, &NeoChatRoom::highlightCountChanged, this, &NeoChatRoom::countChanged);
|
||||
connect(this, &Room::fileTransferCompleted, this, [=] {
|
||||
connect(this, &Room::fileTransferCompleted, this, [this] {
|
||||
setFileUploadingProgress(0);
|
||||
setHasFileUploading(false);
|
||||
});
|
||||
@@ -52,7 +52,7 @@ NeoChatRoom::NeoChatRoom(Connection *connection, QString roomId, JoinState joinS
|
||||
|
||||
connect(this, &Quotient::Room::eventsHistoryJobChanged, this, &NeoChatRoom::lastActiveTimeChanged);
|
||||
|
||||
connect(this, &Room::joinStateChanged, this, [=](JoinState oldState, JoinState newState) {
|
||||
connect(this, &Room::joinStateChanged, this, [this](JoinState oldState, JoinState newState) {
|
||||
if (oldState == JoinState::Invite && newState != JoinState::Invite) {
|
||||
Q_EMIT isInviteChanged();
|
||||
}
|
||||
@@ -68,19 +68,19 @@ void NeoChatRoom::uploadFile(const QUrl &url, const QString &body)
|
||||
|
||||
QString txnId = postFile(body.isEmpty() ? url.fileName() : body, url, false);
|
||||
setHasFileUploading(true);
|
||||
connect(this, &Room::fileTransferCompleted, [=](const QString &id, const QUrl & /*localFile*/, const QUrl & /*mxcUrl*/) {
|
||||
connect(this, &Room::fileTransferCompleted, [this, txnId](const QString &id, const QUrl & /*localFile*/, const QUrl & /*mxcUrl*/) {
|
||||
if (id == txnId) {
|
||||
setFileUploadingProgress(0);
|
||||
setHasFileUploading(false);
|
||||
}
|
||||
});
|
||||
connect(this, &Room::fileTransferFailed, [=](const QString &id, const QString & /*error*/) {
|
||||
connect(this, &Room::fileTransferFailed, [this, txnId](const QString &id, const QString & /*error*/) {
|
||||
if (id == txnId) {
|
||||
setFileUploadingProgress(0);
|
||||
setHasFileUploading(false);
|
||||
}
|
||||
});
|
||||
connect(this, &Room::fileTransferProgress, [=](const QString &id, qint64 progress, qint64 total) {
|
||||
connect(this, &Room::fileTransferProgress, [this, txnId](const QString &id, qint64 progress, qint64 total) {
|
||||
if (id == txnId) {
|
||||
setFileUploadingProgress(int(float(progress) / float(total) * 100));
|
||||
}
|
||||
|
||||
@@ -115,7 +115,7 @@ void PublicRoomListModel::next(int count)
|
||||
|
||||
job = m_connection->callApi<QueryPublicRoomsJob>(m_server, count, nextBatch, QueryPublicRoomsJob::Filter{m_keyword});
|
||||
|
||||
connect(job, &BaseJob::finished, this, [=] {
|
||||
connect(job, &BaseJob::finished, this, [this] {
|
||||
attempted = true;
|
||||
|
||||
if (job->status() == BaseJob::Success) {
|
||||
|
||||
@@ -101,7 +101,7 @@ void RoomListModel::setConnection(Connection *connection)
|
||||
connect(connection, &Connection::joinedRoom, this, &RoomListModel::updateRoom);
|
||||
connect(connection, &Connection::leftRoom, this, &RoomListModel::updateRoom);
|
||||
connect(connection, &Connection::aboutToDeleteRoom, this, &RoomListModel::deleteRoom);
|
||||
connect(connection, &Connection::directChatsListChanged, this, [=](Quotient::DirectChatsMap additions, Quotient::DirectChatsMap removals) {
|
||||
connect(connection, &Connection::directChatsListChanged, this, [this, connection](Quotient::DirectChatsMap additions, Quotient::DirectChatsMap removals) {
|
||||
auto refreshRooms = [this, &connection](Quotient::DirectChatsMap rooms) {
|
||||
for (const QString &roomID : qAsConst(rooms)) {
|
||||
auto room = connection->room(roomID);
|
||||
@@ -152,29 +152,29 @@ void RoomListModel::doAddRoom(Room *r)
|
||||
|
||||
void RoomListModel::connectRoomSignals(NeoChatRoom *room)
|
||||
{
|
||||
connect(room, &Room::displaynameChanged, this, [=] {
|
||||
connect(room, &Room::displaynameChanged, this, [this, room] {
|
||||
refresh(room);
|
||||
});
|
||||
connect(room, &Room::unreadMessagesChanged, this, [=] {
|
||||
connect(room, &Room::unreadMessagesChanged, this, [this, room] {
|
||||
refresh(room);
|
||||
});
|
||||
connect(room, &Room::notificationCountChanged, this, [=] {
|
||||
connect(room, &Room::notificationCountChanged, this, [this, room] {
|
||||
refresh(room);
|
||||
});
|
||||
connect(room, &Room::avatarChanged, this, [this, room] {
|
||||
refresh(room, {AvatarRole});
|
||||
});
|
||||
connect(room, &Room::tagsChanged, this, [=] {
|
||||
connect(room, &Room::tagsChanged, this, [this, room] {
|
||||
refresh(room);
|
||||
});
|
||||
connect(room, &Room::joinStateChanged, this, [=] {
|
||||
connect(room, &Room::joinStateChanged, this, [this, room] {
|
||||
refresh(room);
|
||||
});
|
||||
connect(room, &Room::addedMessages, this, [=] {
|
||||
connect(room, &Room::addedMessages, this, [this, room] {
|
||||
refresh(room, {LastEventRole});
|
||||
});
|
||||
connect(room, &Room::notificationCountChanged, this, &RoomListModel::handleNotifications);
|
||||
connect(room, &Room::highlightCountChanged, this, [=] {
|
||||
connect(room, &Room::highlightCountChanged, this, [this, room] {
|
||||
if (room->highlightCount() == 0) {
|
||||
return;
|
||||
}
|
||||
@@ -205,7 +205,7 @@ void RoomListModel::handleNotifications()
|
||||
static QStringList oldNotifications;
|
||||
auto job = m_connection->callApi<GetNotificationsJob>();
|
||||
|
||||
connect(job, &BaseJob::success, this, [=]() {
|
||||
connect(job, &BaseJob::success, this, [this, job]() {
|
||||
const auto notifications = job->jsonData()["notifications"].toArray();
|
||||
if (initial) {
|
||||
initial = false;
|
||||
|
||||
@@ -186,7 +186,7 @@ void RoomManager::visitRoom(Room *room, const QString &eventId)
|
||||
void RoomManager::joinRoom(Quotient::Connection *account, const QString &roomAliasOrId, const QStringList &viaServers)
|
||||
{
|
||||
account->joinRoom(QUrl::toPercentEncoding(roomAliasOrId), viaServers);
|
||||
connectSingleShot(account, &Quotient::Connection::newRoom, this, [=](Quotient::Room *room) {
|
||||
connectSingleShot(account, &Quotient::Connection::newRoom, this, [this](Quotient::Room *room) {
|
||||
enterRoom(dynamic_cast<NeoChatRoom *>(room));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ void UserDirectoryListModel::search(int count)
|
||||
|
||||
job = m_connection->callApi<SearchUserDirectoryJob>(m_keyword, count);
|
||||
|
||||
connect(job, &BaseJob::finished, this, [=] {
|
||||
connect(job, &BaseJob::finished, this, [this] {
|
||||
attempted = true;
|
||||
|
||||
if (job->status() == BaseJob::Success) {
|
||||
|
||||
@@ -49,14 +49,14 @@ void UserListModel::setRoom(Quotient::Room *room)
|
||||
}
|
||||
for (User *user : qAsConst(m_users)) {
|
||||
#ifdef QUOTIENT_07
|
||||
connect(user, &User::defaultAvatarChanged, this, [=]() {
|
||||
connect(user, &User::defaultAvatarChanged, this, [this, user]() {
|
||||
avatarChanged(user, m_currentRoom);
|
||||
});
|
||||
#else
|
||||
connect(user, &User::avatarChanged, this, &UserListModel::avatarChanged);
|
||||
#endif
|
||||
}
|
||||
connect(m_currentRoom->connection(), &Connection::loggedOut, this, [=] {
|
||||
connect(m_currentRoom->connection(), &Connection::loggedOut, this, [this] {
|
||||
setRoom(nullptr);
|
||||
});
|
||||
qDebug() << m_users.count() << "user(s) in the room";
|
||||
@@ -154,7 +154,7 @@ void UserListModel::userAdded(Quotient::User *user)
|
||||
m_users.insert(pos, user);
|
||||
endInsertRows();
|
||||
#ifdef QUOTIENT_07
|
||||
connect(user, &User::defaultAvatarChanged, this, [=]() {
|
||||
connect(user, &User::defaultAvatarChanged, this, [this, user]() {
|
||||
avatarChanged(user, m_currentRoom);
|
||||
});
|
||||
#else
|
||||
|
||||
Reference in New Issue
Block a user