blob: 19217290979d61e343b5bc18b408581fcf3cf269 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#include "moderation_functions.h"
#include <QInputDialog>
#include <QMessageBox>
#include <QObject>
std::optional<QString> call_moderator_support(QString title)
{
if (title.isEmpty())
{
title = QObject::tr("Call moderator");
}
else
{
title = QObject::tr("Call moderator: %1").arg(title);
}
QInputDialog input;
input.setLabelText(QObject::tr("Reason:"));
input.setWindowFlags(Qt::WindowSystemMenuHint);
input.setWindowTitle(title);
while (input.exec())
{
QString text = input.textValue();
if (text.isEmpty())
{
QMessageBox::critical(&input, QObject::tr("Error"), QObject::tr("Please, enter a reason."));
}
else if (text.length() > 255)
{
QMessageBox::critical(&input, QObject::tr("Error"), QObject::tr("Reason is too long."));
}
else
{
return text;
}
}
return std::nullopt;
}
|