File indexing completed on 2024-05-19 16:00:33

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 #if QT_VERSION > QT_VERSION_CHECK(6, 0, 0)
0026     setPosition(KMessageWidget::Footer);
0027 #endif
0028 }
0029 
0030 RoomReplyThreadWidget::~RoomReplyThreadWidget() = default;
0031 
0032 void RoomReplyThreadWidget::setMessageText(const QString &str)
0033 {
0034     QString strToDisplay = str;
0035     if (strToDisplay.length() > 80) {
0036         strToDisplay = strToDisplay.left(80) + QStringLiteral("...");
0037     }
0038     setText(i18n("Reply in Thread for Message: \'%1\'", strToDisplay));
0039 }
0040 
0041 #include "moc_roomreplythreadwidget.cpp"