Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/courtroom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 8 additions & 0 deletions src/widgets/playerlistwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
});

Expand All @@ -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();
});
}
Expand All @@ -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);
}
Expand Down
7 changes: 7 additions & 0 deletions src/widgets/playerlistwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -24,6 +27,7 @@ class PlayerListWidget : public QListWidget
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);
Expand All @@ -34,6 +38,9 @@ class PlayerListWidget : public QListWidget

void filterPlayerList();

Q_SIGNALS:
void notify(const QString &messasge);

private Q_SLOTS:
void onCustomContextMenuRequested(const QPoint &pos);
};
Loading