diff --git a/src/core/toxcall.cpp b/src/core/toxcall.cpp index e384d4d08..0e87506ca 100644 --- a/src/core/toxcall.cpp +++ b/src/core/toxcall.cpp @@ -139,7 +139,7 @@ ToxFriendCall::ToxFriendCall(uint32_t FriendNum, bool VideoEnabled, CoreAV& av, qDebug() << "Audio input connection not working"; } - audioSinkInvalid = sink->connectTo_invalidated([this]() { this->onAudioSinkInvalidated(); }); + audioSinkInvalid = sink->connectTo_invalidated(this, [this]() { this->onAudioSinkInvalidated(); }); // register video if (videoEnabled) { @@ -183,7 +183,7 @@ void ToxFriendCall::onAudioSinkInvalidated() { auto newSink = audio.makeSink(); - audioSinkInvalid = newSink->connectTo_invalidated([this]() { this->onAudioSinkInvalidated(); }); + audioSinkInvalid = newSink->connectTo_invalidated(this, [this]() { this->onAudioSinkInvalidated(); }); sink = std::move(newSink); } @@ -269,7 +269,7 @@ void ToxGroupCall::removePeer(ToxPk peerId) void ToxGroupCall::addPeer(ToxPk peerId) { std::unique_ptr newSink = audio.makeSink(); - QMetaObject::Connection con = newSink->connectTo_invalidated([this, peerId]() { this->onAudioSinkInvalidated(peerId); }); + QMetaObject::Connection con = newSink->connectTo_invalidated(this, [this, peerId]() { this->onAudioSinkInvalidated(peerId); }); peers.emplace(peerId, std::move(newSink)); sinkInvalid.insert({peerId, con}); diff --git a/src/model/about/aboutfriend.cpp b/src/model/about/aboutfriend.cpp index 13165605b..a07b51a48 100644 --- a/src/model/about/aboutfriend.cpp +++ b/src/model/about/aboutfriend.cpp @@ -28,17 +28,17 @@ AboutFriend::AboutFriend(const Friend* f, IFriendSettings* const s) : f{f} , settings{s} { - s->connectTo_contactNoteChanged([=](const ToxPk& pk, const QString& note) { + s->connectTo_contactNoteChanged(this, [=](const ToxPk& pk, const QString& note) { emit noteChanged(note); }); - s->connectTo_autoAcceptCallChanged( + s->connectTo_autoAcceptCallChanged(this, [=](const ToxPk& pk, IFriendSettings::AutoAcceptCallFlags flag) { emit autoAcceptCallChanged(flag); }); - s->connectTo_autoAcceptDirChanged([=](const ToxPk& pk, const QString& dir) { + s->connectTo_autoAcceptDirChanged(this, [=](const ToxPk& pk, const QString& dir) { emit autoAcceptDirChanged(dir); }); - s->connectTo_autoGroupInviteChanged([=](const ToxPk& pk, bool enable) { + s->connectTo_autoGroupInviteChanged(this, [=](const ToxPk& pk, bool enable) { emit autoGroupInviteChanged(enable); }); } diff --git a/src/model/interface.h b/src/model/interface.h index b9d122385..2e8ef2f36 100644 --- a/src/model/interface.h +++ b/src/model/interface.h @@ -50,7 +50,7 @@ */ #define DECLARE_SIGNAL(name, ...) \ using Slot_##name = std::function; \ - virtual QMetaObject::Connection connectTo_##name(Slot_##name slot) const = 0 + virtual QMetaObject::Connection connectTo_##name(QObject *receiver, Slot_##name slot) const = 0 /** * @def DECLARE_SIGNAL @@ -58,7 +58,7 @@ */ #define DECLARE_SIGNAL(name, ...) \ using Slot_##name = std::function; \ - virtual QMetaObject::Connection connectTo_##name(Slot_##name slot) const = 0 + virtual QMetaObject::Connection connectTo_##name(QObject *receiver, Slot_##name slot) const = 0 /** * @def SIGNAL_IMPL @@ -67,8 +67,8 @@ #define SIGNAL_IMPL(classname, name, ...) \ using Slot_##name = std::function; \ Q_SIGNAL void name(__VA_ARGS__); \ - QMetaObject::Connection connectTo_##name(Slot_##name slot) const override { \ - connect(this, &classname::name, slot); \ + QMetaObject::Connection connectTo_##name(QObject *receiver, Slot_##name slot) const override { \ + return connect(this, &classname::name, receiver, slot); \ } #endif // INTERFACE_H diff --git a/src/widget/about/aboutfriendform.cpp b/src/widget/about/aboutfriendform.cpp index 323242caf..7ce24550b 100644 --- a/src/widget/about/aboutfriendform.cpp +++ b/src/widget/about/aboutfriendform.cpp @@ -41,7 +41,7 @@ AboutFriendForm::AboutFriendForm(std::unique_ptr _about, QWidget* connect(ui->autogroupinvite, &QCheckBox::clicked, this, &AboutFriendForm::onAutoGroupInvite); connect(ui->selectSaveDir, &QPushButton::clicked, this, &AboutFriendForm::onSelectDirClicked); connect(ui->removeHistory, &QPushButton::clicked, this, &AboutFriendForm::onRemoveHistoryClicked); - about->connectTo_autoAcceptDirChanged([=](const QString& dir){ onAutoAcceptDirChanged(dir); }); + about->connectTo_autoAcceptDirChanged(this, [=](const QString& dir){ onAutoAcceptDirChanged(dir); }); const QString dir = about->getAutoAcceptDir(); ui->autoacceptfile->setChecked(!dir.isEmpty()); diff --git a/src/widget/form/profileform.cpp b/src/widget/form/profileform.cpp index 9b75b084c..b68a9d03f 100644 --- a/src/widget/form/profileform.cpp +++ b/src/widget/form/profileform.cpp @@ -147,7 +147,7 @@ ProfileForm::ProfileForm(IProfileInfo* profileInfo, QWidget* parent) connect(bodyUI->toxIdLabel, &CroppingLabel::clicked, this, &ProfileForm::copyIdClicked); connect(toxId, &ClickableTE::clicked, this, &ProfileForm::copyIdClicked); - connect(profileInfo, &IProfileInfo::idChanged, this, &ProfileForm::setToxId); + profileInfo->connectTo_idChanged(this, [=](const ToxId& id) { setToxId(id); }); connect(bodyUI->userName, &QLineEdit::editingFinished, this, &ProfileForm::onUserNameEdited); connect(bodyUI->statusMessage, &QLineEdit::editingFinished, this, &ProfileForm::onStatusMessageEdited); @@ -166,9 +166,11 @@ ProfileForm::ProfileForm(IProfileInfo* profileInfo, QWidget* parent) connect(bodyUI->saveQr, &QPushButton::clicked, this, &ProfileForm::onSaveQrClicked); connect(bodyUI->copyQr, &QPushButton::clicked, this, &ProfileForm::onCopyQrClicked); - connect(profileInfo, &IProfileInfo::usernameChanged, this, + profileInfo->connectTo_usernameChanged( + this, [=](const QString& val) { bodyUI->userName->setText(val); }); - connect(profileInfo, &IProfileInfo::statusMessageChanged, this, + profileInfo->connectTo_statusMessageChanged( + this, [=](const QString& val) { bodyUI->statusMessage->setText(val); }); for (QComboBox* cb : findChildren()) { diff --git a/src/widget/widget.cpp b/src/widget/widget.cpp index 8770ab4dd..a48ac5cfe 100644 --- a/src/widget/widget.cpp +++ b/src/widget/widget.cpp @@ -1020,8 +1020,7 @@ void Widget::playNotificationSound(IAudioSink::Sound sound, bool loop) } } - connect(audioNotification.get(), &IAudioSink::finishedPlaying, this, - &Widget::cleanupNotificationSound); + audioNotification->connectTo_finishedPlaying(this, [this](){ cleanupNotificationSound(); }); audioNotification->playMono16Sound(sound);