File indexing completed on 2024-12-01 04:37:01

0001 /*
0002    SPDX-FileCopyrightText: 2021-2024 Laurent Montel <montel@kde.org>
0003 
0004    SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "roomreplythreadwidget.h"
0008 
0009 #include <KLocalizedString>
0010 #include <QAction>
0011 #include <QPushButton>
0012 
0013 RoomReplyThreadWidget::RoomReplyThreadWidget(QWidget *parent)
0014     : KMessageWidget(parent)
0015 {
0016     setCloseButtonVisible(false);
0017     setMessageType(Information);
0018     setWordWrap(true);
0019     setText(i18n("Replying in a thread"));
0020     setVisible(false);
0021     auto cancelReplyingInThreadAction = new QAction(i18n("Cancel"), this);
0022     connect(cancelReplyingInThreadAction, &QAction::triggered, this, &RoomReplyThreadWidget::cancelReplyingInThread);
0023     addAction(cancelReplyingInThreadAction);
0024 
0025     setPosition(KMessageWidget::Footer);
0026 }
0027 
0028 RoomReplyThreadWidget::~RoomReplyThreadWidget() = default;
0029 
0030 void RoomReplyThreadWidget::setMessageText(const QString &str)
0031 {
0032     QString strToDisplay = str;
0033     if (strToDisplay.length() > 80) {
0034         strToDisplay = strToDisplay.left(80) + QStringLiteral("...");
0035     }
0036     setText(i18n("Reply in Thread for Message: \'%1\'", strToDisplay));
0037 }
0038 
0039 #include "moc_roomreplythreadwidget.cpp"