[network/ruqola] src/widgets: Clean up api

Laurent Montel <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit de2a4f72bcc90fa37e6eed9ba3d3b7cd7f1cfc85 by Laurent Montel.
Committed on 20/07/2026 at 05:41.
Pushed by mlaurent into branch 'master'.

Clean up api

M  +2    -12   src/widgets/dialogs/directchannelinfodialog.cpp
M  +3    -3    src/widgets/dialogs/directchannelinfodialog.h
M  +15   -23   src/widgets/dialogs/directchannelinfowidget.cpp
M  +9    -7    src/widgets/dialogs/directchannelinfowidget.h
M  +6    -3    src/widgets/room/messagelistview.cpp
M  +6    -2    src/widgets/room/roomwidget.cpp
M  +6    -3    src/widgets/room/usersinroommenu.cpp
M  +6    -1    src/widgets/room/usersinroomwidget.cpp

https://invent.kde.org/network/ruqola/-/commit/de2a4f72bcc90fa37e6eed9ba3d3b7cd7f1cfc85

diff --git a/src/widgets/dialogs/directchannelinfodialog.cpp b/src/widgets/dialogs/directchannelinfodialog.cpp
index 15a70b5ee4..3cf465b097 100644
--- a/src/widgets/dialogs/directchannelinfodialog.cpp
+++ b/src/widgets/dialogs/directchannelinfodialog.cpp
@@ -33,19 +33,9 @@ DirectChannelInfoDialog::DirectChannelInfoDialog(RocketChatAccount *account, QWi
 
 DirectChannelInfoDialog::~DirectChannelInfoDialog() = default;
 
-void DirectChannelInfoDialog::setUserName(const QString &userName)
+void DirectChannelInfoDialog::setDirectChannelInfo(const DirectChannelInfoWidget::DirectChannelInfo &info)
 {
-    mDirectChannelInfoWidget->setUserName(userName);
-}
-
-void DirectChannelInfoDialog::setRoles(const QList<RoleInfo> &newRoles)
-{
-    mDirectChannelInfoWidget->setRoles(newRoles);
-}
-
-void DirectChannelInfoDialog::setRoom(Room *room)
-{
-    mDirectChannelInfoWidget->setRoom(room);
+    mDirectChannelInfoWidget->setDirectChannelInfo(info);
 }
 
 #include "moc_directchannelinfodialog.cpp"
diff --git a/src/widgets/dialogs/directchannelinfodialog.h b/src/widgets/dialogs/directchannelinfodialog.h
index 3085992fe9..80f861d32c 100644
--- a/src/widgets/dialogs/directchannelinfodialog.h
+++ b/src/widgets/dialogs/directchannelinfodialog.h
@@ -8,6 +8,7 @@
 #include <QDialog>
 #include <QList>
 
+#include "directchannelinfowidget.h"
 #include "libruqolawidgets_private_export.h"
 class DirectChannelInfoWidget;
 class User;
@@ -20,9 +21,8 @@ class LIBRUQOLAWIDGETS_TESTS_EXPORT DirectChannelInfoDialog : public QDialog
 public:
     explicit DirectChannelInfoDialog(RocketChatAccount *account, QWidget *parent = nullptr);
     ~DirectChannelInfoDialog() override;
-    void setUserName(const QString &userName);
-    void setRoles(const QList<RoleInfo> &newRoles);
-    void setRoom(Room *room);
+
+    void setDirectChannelInfo(const DirectChannelInfoWidget::DirectChannelInfo &info);
 
 private:
     DirectChannelInfoWidget *const mDirectChannelInfoWidget;
diff --git a/src/widgets/dialogs/directchannelinfowidget.cpp b/src/widgets/dialogs/directchannelinfowidget.cpp
index bf86dc5aab..2f48eff485 100644
--- a/src/widgets/dialogs/directchannelinfowidget.cpp
+++ b/src/widgets/dialogs/directchannelinfowidget.cpp
@@ -10,7 +10,7 @@
 #include "rocketchataccount.h"
 #include "room/usersinroommenu.h"
 #include "ruqolawidgets_debug.h"
-#include "user.h"
+
 #include "users/userinfojob.h"
 
 #include <KLocalizedString>
@@ -46,24 +46,21 @@ DirectChannelInfoWidget::DirectChannelInfoWidget(RocketChatAccount *account, QWi
 
 DirectChannelInfoWidget::~DirectChannelInfoWidget() = default;
 
-void DirectChannelInfoWidget::slotIgnoreUser()
+void DirectChannelInfoWidget::setDirectChannelInfo(const DirectChannelInfo &info)
 {
-    // TODO
+    mListRoleInfos = info.roles;
+    fetchUserInfo(info.userName);
+    mDirectChannelActionWidget->setRoom(info.room);
 }
 
-void DirectChannelInfoWidget::slotReportUser()
+void DirectChannelInfoWidget::slotIgnoreUser()
 {
     // TODO
 }
 
-void DirectChannelInfoWidget::setUserName(const QString &userName)
-{
-    fetchUserInfo(userName);
-}
-
-void DirectChannelInfoWidget::setRoles(const QList<RoleInfo> &newRoles)
+void DirectChannelInfoWidget::slotReportUser()
 {
-    mListRoleInfos = newRoles;
+    // TODO
 }
 
 void DirectChannelInfoWidget::fetchUserInfo(const QString &userName)
@@ -225,12 +222,7 @@ void DirectChannelInfoWidget::setUser(const User &user)
     }
     // mDirectChannelActionWidget->setVisible(user.userId() != mRocketChatAccount->userId());
     mDirectChannelActionWidget->setVisible(false); // TODO
-    mDirectChannelActionWidget->setUser(user);
-}
-
-void DirectChannelInfoWidget::setRoom(Room *room)
-{
-    mDirectChannelActionWidget->setRoom(room);
+    mDirectChannelActionWidget->generateRoomMenu(user);
 }
 
 DirectChannelActionWidget::DirectChannelActionWidget(RocketChatAccount *account, QWidget *parent)
@@ -258,7 +250,12 @@ DirectChannelActionWidget::DirectChannelActionWidget(RocketChatAccount *account,
 
 DirectChannelActionWidget::~DirectChannelActionWidget() = default;
 
-void DirectChannelActionWidget::setUser(const User &user)
+void DirectChannelActionWidget::setRoom(Room *room)
+{
+    mRoom = room;
+}
+
+void DirectChannelActionWidget::generateRoomMenu(const User &user)
 {
     auto menu = new UsersInRoomMenu(mRocketChatAccount, this);
     menu->setParentWidget(this);
@@ -268,9 +265,4 @@ void DirectChannelActionWidget::setUser(const User &user)
     mToolButton->setMenu(menu->createMenu());
 }
 
-void DirectChannelActionWidget::setRoom(Room *room)
-{
-    mRoom = room;
-}
-
 #include "moc_directchannelinfowidget.cpp"
diff --git a/src/widgets/dialogs/directchannelinfowidget.h b/src/widgets/dialogs/directchannelinfowidget.h
index 616477d52f..d37e40c1bf 100644
--- a/src/widgets/dialogs/directchannelinfowidget.h
+++ b/src/widgets/dialogs/directchannelinfowidget.h
@@ -5,13 +5,12 @@
 */
 
 #pragma once
-
 #include "roles/roleinfo.h"
+#include "user.h"
 #include <QList>
 #include <QWidget>
 
 #include "libruqolawidgets_private_export.h"
-class User;
 class QFormLayout;
 class RocketChatAccount;
 class ResizablePixmapLabel;
@@ -23,7 +22,7 @@ class LIBRUQOLAWIDGETS_TESTS_EXPORT DirectChannelActionWidget : public QWidget
 public:
     explicit DirectChannelActionWidget(RocketChatAccount *account, QWidget *parent = nullptr);
     ~DirectChannelActionWidget() override;
-    void setUser(const User &user);
+    void generateRoomMenu(const User &user);
     void setRoom(Room *room);
 Q_SIGNALS:
     void ignoreUser();
@@ -39,13 +38,16 @@ class LIBRUQOLAWIDGETS_TESTS_EXPORT DirectChannelInfoWidget : public QWidget
 {
     Q_OBJECT
 public:
+    struct DirectChannelInfo {
+        QString userName;
+        QList<RoleInfo> roles;
+        Room *room = nullptr;
+    };
+
     explicit DirectChannelInfoWidget(RocketChatAccount *account, QWidget *parent = nullptr);
     ~DirectChannelInfoWidget() override;
 
-    void setUserName(const QString &userName);
-
-    void setRoles(const QList<RoleInfo> &newRoles);
-    void setRoom(Room *room);
+    void setDirectChannelInfo(const DirectChannelInfo &info);
 
 private:
     LIBRUQOLAWIDGETS_NO_EXPORT void slotIgnoreUser();
diff --git a/src/widgets/room/messagelistview.cpp b/src/widgets/room/messagelistview.cpp
index eeb43223b9..e04bb10064 100644
--- a/src/widgets/room/messagelistview.cpp
+++ b/src/widgets/room/messagelistview.cpp
@@ -1180,9 +1180,12 @@ void MessageListView::slotReplyInThread(const QModelIndex &index)
 void MessageListView::slotShowUserInfo(const QString &userName)
 {
     DirectChannelInfoDialog dlg(mCurrentRocketChatAccount, this);
-    dlg.setUserName(userName);
-    dlg.setRoles(mCurrentRocketChatAccount->roleInfo());
-    dlg.setRoom(mRoom);
+    const DirectChannelInfoWidget::DirectChannelInfo info{
+        .userName = userName,
+        .roles = mCurrentRocketChatAccount->roleInfo(),
+        .room = mRoom,
+    };
+    dlg.setDirectChannelInfo(info);
     dlg.exec();
 }
 
diff --git a/src/widgets/room/roomwidget.cpp b/src/widgets/room/roomwidget.cpp
index 867145c87b..e0ff12efef 100644
--- a/src/widgets/room/roomwidget.cpp
+++ b/src/widgets/room/roomwidget.cpp
@@ -299,8 +299,12 @@ void RoomWidget::slotChannelInfoRequested()
     }
     if (mRoomType == Room::RoomType::Direct) {
         DirectChannelInfoDialog dlg(mCurrentRocketChatAccount, this);
-        dlg.setUserName(mRoom->name());
-        dlg.setRoom(mRoom);
+        const DirectChannelInfoWidget::DirectChannelInfo info{
+            .userName = mRoom->name(),
+            .roles = {},
+            .room = mRoom,
+        };
+        dlg.setDirectChannelInfo(info);
         dlg.exec();
     } else {
         QPointer<ChannelInfoDialog> dlg = new ChannelInfoDialog(mRoom, mCurrentRocketChatAccount, this);
diff --git a/src/widgets/room/usersinroommenu.cpp b/src/widgets/room/usersinroommenu.cpp
index ba74b36922..5851c061ea 100644
--- a/src/widgets/room/usersinroommenu.cpp
+++ b/src/widgets/room/usersinroommenu.cpp
@@ -251,9 +251,12 @@ void UsersInRoomMenu::slotBanUserFromRoomAction()
 void UsersInRoomMenu::slotUserInfo()
 {
     DirectChannelInfoDialog dlg(mRocketChatAccount, mParentWidget);
-    dlg.setUserName(mUserName);
-    dlg.setRoles(mRocketChatAccount->roleInfo());
-    dlg.setRoom(mRoom);
+    const DirectChannelInfoWidget::DirectChannelInfo info{
+        .userName = mUserName,
+        .roles = mRocketChatAccount->roleInfo(),
+        .room = mRoom,
+    };
+    dlg.setDirectChannelInfo(info);
     dlg.exec();
 }
 
diff --git a/src/widgets/room/usersinroomwidget.cpp b/src/widgets/room/usersinroomwidget.cpp
index 6c1a728f31..fead233ab5 100644
--- a/src/widgets/room/usersinroomwidget.cpp
+++ b/src/widgets/room/usersinroomwidget.cpp
@@ -145,7 +145,12 @@ void UsersInRoomWidget::slotShowUserInfo(const QModelIndex &index)
     if (index.isValid()) {
         const QString userName = index.data(UsersForRoomModel::UsersForRoomRoles::UserName).toString();
         DirectChannelInfoDialog dlg(mRocketChatAccount, this);
-        dlg.setUserName(userName);
+        const DirectChannelInfoWidget::DirectChannelInfo info{
+            .userName = userName,
+            .roles = {},
+            .room = mRoom,
+        };
+        dlg.setDirectChannelInfo(info);
         dlg.exec();
     }
 }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.