REFAC(client): Use regular signal to notify about channel switchtes in TalkingUI

This commit is contained in:
Robert Adam 2025-10-19 18:25:10 +02:00
parent fad4dfbc77
commit 620beaaa10
3 changed files with 12 additions and 13 deletions

View File

@ -388,12 +388,6 @@ void MainWindow::msgUserState(const MumbleProto::UserState &msg) {
if (channel != oldChannel) {
pmModel->moveUser(pDst, channel);
if (Global::get().talkingUI) {
// Pass the pointer as QObject in order to avoid having to register ClientUser as a QMetaType
QMetaObject::invokeMethod(Global::get().talkingUI, "on_channelChanged", Qt::QueuedConnection,
Q_ARG(QObject *, pDst));
}
if (pSelf) {
if (pDst == pSelf) {
Global::get().mw->updateChatBar();

View File

@ -32,9 +32,11 @@
#include <algorithm>
#include <cassert>
#include <optional>
TalkingUI::TalkingUI(QWidget *parent) : QWidget(parent), m_containers(), m_currentSelection(nullptr) {
setupUI();
QObject::connect(Global::get().mw->pmModel, &UserModel::userMoved, this, &TalkingUI::on_channelChanged);
}
int TalkingUI::findContainer(int associatedChannelID, ContainerType type) const {
@ -730,11 +732,12 @@ void TalkingUI::on_serverDisconnected() {
updateUI();
}
void TalkingUI::on_channelChanged(QObject *obj) {
// According to this function's doc, the passed object must be of type ClientUser
ClientUser *user = static_cast< ClientUser * >(obj);
void TalkingUI::on_channelChanged(unsigned int sessionID, const std::optional< unsigned int > &,
unsigned int newChannelID) {
ClientUser *user = ClientUser::get(sessionID);
const Channel *channel = Channel::get(newChannelID);
if (!user) {
if (!user || !channel) {
return;
}
@ -745,8 +748,8 @@ void TalkingUI::on_channelChanged(QObject *obj) {
// the channel this particular user is being displayed in.
// But first we have to make sure there actually exists and entry for
// the new channel.
addChannel(user->cChannel);
moveUserToChannel(user->uiSession, user->cChannel->iId);
addChannel(channel);
moveUserToChannel(user->uiSession, channel->iId);
}
}

View File

@ -13,6 +13,7 @@
#include <QWidget>
#include <memory>
#include <optional>
#include <vector>
#include "Settings.h"
@ -126,7 +127,8 @@ public slots:
void on_mainWindowSelectionChanged(const QModelIndex &current, const QModelIndex &previous);
void on_serverSynchronized();
void on_serverDisconnected();
void on_channelChanged(QObject *user);
void on_channelChanged(unsigned int sessionID, const std::optional< unsigned int > &prevChannelID,
unsigned int newChannelID);
void on_settingsChanged();
void on_clientDisconnected(unsigned int userSession);
void on_muteDeafStateChanged();