diff options
| author | wewlad1 <30403438+wewlad1@users.noreply.github.com> | 2018-08-06 07:47:46 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2018-08-06 07:47:46 +0900 |
| commit | bec2b7aef4fcc6c9edff3e7ca465d1a15a897f0f (patch) | |
| tree | 71d65a4b6095470b4d7ed41f54a2bd1bd550bde0 /courtroom.cpp | |
| parent | a8344ced3f7d412a05a6438e3b7ccdd4f1c3c15b (diff) | |
| parent | 3fc478bc4f5ec8e0b32c8a93ef1637f9549f600b (diff) | |
Merge pull request #2 from argoneuscze/modcall_reason
Added check for empty reason for modcalls
Diffstat (limited to 'courtroom.cpp')
| -rw-r--r-- | courtroom.cpp | 27 |
1 files changed, 16 insertions, 11 deletions
diff --git a/courtroom.cpp b/courtroom.cpp index f6935ba1..b3c3ba29 100644 --- a/courtroom.cpp +++ b/courtroom.cpp @@ -2019,20 +2019,25 @@ void Courtroom::on_spectator_clicked() void Courtroom::on_call_mod_clicked() { if (ao_app->modcall_reason_enabled) { - auto box = new QInputDialog(); - box->setLabelText("Enter a reason:"); - auto code = box->exec(); + QMessageBox errorBox; + QInputDialog input; - if (code != QDialog::Accepted) { - delete box; - return; - } + input.setWindowFlags(Qt::WindowSystemMenuHint); + input.setLabelText("Reason:"); + input.setWindowTitle("Call Moderator"); + auto code = input.exec(); - auto text = box->textValue(); - if (text.isEmpty()) - text = "N/A"; + if (code != QDialog::Accepted) + return; - delete box; + QString text = input.textValue(); + if (text.isEmpty()) { + errorBox.critical(nullptr, "Error", "You must provide a reason."); + return; + } else if (text.length() > 256) { + errorBox.critical(nullptr, "Error", "The message is too long."); + return; + } QStringList mod_reason; mod_reason.append(text); |
