summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorDeepBlueV7.X <nicolas.werner@hotmail.de>2022-03-06 23:39:27 +0000
committerGitHub <noreply@github.com>2022-03-06 23:39:27 +0000
commit54d93becbffcf9bc3a084f7f906b96f38e7e8ce0 (patch)
tree5e74a1990f2b4bea3bc22b2d75cdf4ac4812a938 /src
parentAllow explicit selection of SSO method (diff)
parentAdd GUI for specifying kick/ban reason (diff)
downloadnheko-54d93becbffcf9bc3a084f7f906b96f38e7e8ce0.tar.xz
Merge pull request #976 from tastytea/redaction-reason
Add GUI for redact/kick/ban reasons
Diffstat (limited to 'src')
-rw-r--r--src/ChatPage.cpp31
-rw-r--r--src/timeline/TimelineModel.cpp8
-rw-r--r--src/timeline/TimelineModel.h2
3 files changed, 28 insertions, 13 deletions
diff --git a/src/ChatPage.cpp b/src/ChatPage.cpp

index cdaf7260..3743eae0 100644 --- a/src/ChatPage.cpp +++ b/src/ChatPage.cpp
@@ -785,11 +785,18 @@ ChatPage::kickUser(QString userid, QString reason) { auto room = currentRoom(); - if (QMessageBox::question(nullptr, - tr("Confirm kick"), - tr("Do you really want to kick %1 (%2)?") - .arg(cache::displayName(room, userid), userid)) != QMessageBox::Yes) + bool confirmed; + reason = + QInputDialog::getText(nullptr, + tr("Reason for the kick"), + tr("Enter reason for kicking %1 (%2) or hit enter for no reason:") + .arg(cache::displayName(room, userid), userid), + QLineEdit::Normal, + reason, + &confirmed); + if (!confirmed) { return; + } http::client()->kick_user( room.toStdString(), @@ -809,12 +816,18 @@ ChatPage::banUser(QString userid, QString reason) { auto room = currentRoom(); - if (QMessageBox::question( - nullptr, - tr("Confirm ban"), - tr("Do you really want to ban %1 (%2)?").arg(cache::displayName(room, userid), userid)) != - QMessageBox::Yes) + bool confirmed; + reason = + QInputDialog::getText(nullptr, + tr("Reason for the ban"), + tr("Enter reason for banning %1 (%2) or hit enter for no reason:") + .arg(cache::displayName(room, userid), userid), + QLineEdit::Normal, + reason, + &confirmed); + if (!confirmed) { return; + } http::client()->ban_user( room.toStdString(), diff --git a/src/timeline/TimelineModel.cpp b/src/timeline/TimelineModel.cpp
index 903f137f..8e6c7235 100644 --- a/src/timeline/TimelineModel.cpp +++ b/src/timeline/TimelineModel.cpp
@@ -1240,7 +1240,7 @@ TimelineModel::showReadReceipts(QString id) } void -TimelineModel::redactEvent(const QString &id) +TimelineModel::redactEvent(const QString &id, const QString &reason) { if (!id.isEmpty()) { auto edits = events.edits(id.toStdString()); @@ -1255,7 +1255,8 @@ TimelineModel::redactEvent(const QString &id) } emit dataAtIdChanged(id); - }); + }, + reason.toStdString()); // redact all edits to prevent leaks for (const auto &e : edits) { @@ -1271,7 +1272,8 @@ TimelineModel::redactEvent(const QString &id) } emit dataAtIdChanged(id); - }); + }, + reason.toStdString()); } } } diff --git a/src/timeline/TimelineModel.h b/src/timeline/TimelineModel.h
index e4e3fa9d..f47203f0 100644 --- a/src/timeline/TimelineModel.h +++ b/src/timeline/TimelineModel.h
@@ -272,7 +272,7 @@ public: Q_INVOKABLE void unpin(const QString &id); Q_INVOKABLE void pin(const QString &id); Q_INVOKABLE void showReadReceipts(QString id); - Q_INVOKABLE void redactEvent(const QString &id); + Q_INVOKABLE void redactEvent(const QString &id, const QString &reason = ""); Q_INVOKABLE int idToIndex(const QString &id) const; Q_INVOKABLE QString indexToId(int index) const; Q_INVOKABLE void openMedia(const QString &eventId);