added moderation buttons

This commit is contained in:
fourtf
2018-01-17 14:14:31 +01:00
parent 252f648ff8
commit 6d6b99f3ef
15 changed files with 367 additions and 76 deletions
+7 -2
View File
@@ -641,7 +641,7 @@ void ChannelView::mouseMoveEvent(QMouseEvent *event)
}
// check if word has a link
if (hoverLayoutElement->getCreator().getLink().isValid()) {
if (hoverLayoutElement->getLink().isValid()) {
this->setCursor(Qt::PointingHandCursor);
} else {
this->setCursor(Qt::ArrowCursor);
@@ -764,7 +764,7 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
return;
}
auto &link = hoverLayoutElement->getCreator().getLink();
auto &link = hoverLayoutElement->getLink();
switch (link.getType()) {
case messages::Link::UserInfo: {
@@ -782,6 +782,11 @@ void ChannelView::mouseReleaseEvent(QMouseEvent *event)
QDesktopServices::openUrl(QUrl(link.getValue()));
break;
}
case messages::Link::UserAction: {
QString value = link.getValue();
value.replace("{user}", layout->getMessage()->loginName);
this->channel->sendMessage(value);
}
}
}
+5 -5
View File
@@ -21,21 +21,21 @@ ModerationPage::ModerationPage()
auto layout = layoutCreator.emplace<QVBoxLayout>().withoutMargin();
{
// clang-format off
auto label = layout.emplace<QLabel>("In channels that you moderate there is a button <insert image of button here> to enable moderation mode.");
auto label = layout.emplace<QLabel>("In channels that you moderate there is a button <insert image of button here> to enable moderation mode.\n\nOne action per line. {user} will be replaced with the username.\nExample `/timeout {user} 120`");
label->setWordWrap(true);
// clang-format on
auto text = layout.emplace<QTextEdit>().getElement();
settings.moderationActions.connect([=](const QString &str, auto) {
text->setPlainText(str); //
});
QObject::connect(text, &QTextEdit::textChanged, this,
[this] { this->itemsChangedTimer.start(200); });
QObject::connect(&this->itemsChangedTimer, &QTimer::timeout, this,
[text, &settings]() { settings.moderationActions = text->toPlainText(); });
settings.highlightUserBlacklist.connect([=](const QString &str, auto) {
text->setPlainText(str); //
});
}
// ---- misc