aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSalanto <62221668+Salanto@users.noreply.github.com>2025-05-08 21:21:37 +0200
committerGitHub <noreply@github.com>2025-05-08 14:21:37 -0500
commit4db979187386326df64b9359b8de5e90468f7fc3 (patch)
tree802d5654730a20bf4ebfb12d38b26b5f4caac192 /src
parentcde34538dc6045223c965958535218a38d22b2ee (diff)
Close punishment dialog when the user leaves (#1097)
* Close punishment dialog when the user leaves Prevents silly moments where the wrong person gets banned/kicked * Fix formatting --------- Co-authored-by: stonedDiscord <Tukz@gmx.de>
Diffstat (limited to 'src')
-rw-r--r--src/courtroom.cpp2
-rw-r--r--src/widgets/playerlistwidget.cpp8
-rw-r--r--src/widgets/playerlistwidget.h7
3 files changed, 17 insertions, 0 deletions
diff --git a/src/courtroom.cpp b/src/courtroom.cpp
index ca1b810f..7646794d 100644
--- a/src/courtroom.cpp
+++ b/src/courtroom.cpp
@@ -520,6 +520,8 @@ Courtroom::Courtroom(AOApplication *p_ao_app)
connect(m_screenslide_timer, &kal::ScreenSlideTimer::finished, this, &Courtroom::post_transition_cleanup);
+ connect(ui_player_list, &PlayerListWidget::notify, this, [this](const QString &message) { append_server_chatmessage("CLIENT", message, "1"); });
+
set_widgets();
set_char_select();
diff --git a/src/widgets/playerlistwidget.cpp b/src/widgets/playerlistwidget.cpp
index c2c65574..04147b82 100644
--- a/src/widgets/playerlistwidget.cpp
+++ b/src/widgets/playerlistwidget.cpp
@@ -117,6 +117,7 @@ void PlayerListWidget::onCustomContextMenuRequested(const QPoint &pos)
ModeratorDialog *dialog = new ModeratorDialog(id, false, ao_app);
dialog->setWindowTitle(tr("Kick %1").arg(name));
connect(this, &PlayerListWidget::destroyed, dialog, &ModeratorDialog::deleteLater);
+ active_moderator_menu = {id, dialog};
dialog->show();
});
@@ -125,6 +126,7 @@ void PlayerListWidget::onCustomContextMenuRequested(const QPoint &pos)
ModeratorDialog *dialog = new ModeratorDialog(id, true, ao_app);
dialog->setWindowTitle(tr("Ban %1").arg(name));
connect(this, &PlayerListWidget::destroyed, dialog, &ModeratorDialog::deleteLater);
+ active_moderator_menu = {id, dialog};
dialog->show();
});
}
@@ -143,6 +145,12 @@ void PlayerListWidget::addPlayer(int playerId)
void PlayerListWidget::removePlayer(int playerId)
{
+ if (active_moderator_menu.first == playerId && active_moderator_menu.second)
+ {
+ delete active_moderator_menu.second;
+ Q_EMIT notify("Closed Moderation Dialog : User left the server.");
+ }
+
delete takeItem(row(m_item_map.take(playerId)));
m_player_map.remove(playerId);
}
diff --git a/src/widgets/playerlistwidget.h b/src/widgets/playerlistwidget.h
index 7886e28a..6fa929db 100644
--- a/src/widgets/playerlistwidget.h
+++ b/src/widgets/playerlistwidget.h
@@ -5,11 +5,14 @@
#include <QList>
#include <QListWidget>
#include <QMap>
+#include <QPointer>
class AOApplication;
+class ModeratorDialog;
class PlayerListWidget : public QListWidget
{
+ Q_OBJECT
public:
explicit PlayerListWidget(AOApplication *ao_app, QWidget *parent = nullptr);
virtual ~PlayerListWidget();
@@ -24,6 +27,7 @@ private:
AOApplication *ao_app;
QMap<int, PlayerData> m_player_map;
QMap<int, QListWidgetItem *> m_item_map;
+ QPair<int, QPointer<ModeratorDialog>> active_moderator_menu;
bool m_is_authenticated = false;
void addPlayer(int playerId);
@@ -34,6 +38,9 @@ private:
void filterPlayerList();
+Q_SIGNALS:
+ void notify(const QString &messasge);
+
private Q_SLOTS:
void onCustomContextMenuRequested(const QPoint &pos);
};