File indexing completed on 2024-12-08 04:00:45
0001 /* 0002 SPDX-FileCopyrightText: 2022 Friedrich W. H. Kossebau <kossebau@kde.org> 0003 0004 SPDX-License-Identifier: LGPL-2.1-or-later 0005 */ 0006 0007 #include "widget.hpp" 0008 0009 // KF 0010 #include <KTextToHTML> 0011 0012 namespace Kodaskanna 0013 { 0014 namespace PlainTextDisplay 0015 { 0016 0017 Widget::Widget(QWidget *parent) 0018 : QWidget(parent) 0019 { 0020 m_ui.setupUi(this); 0021 } 0022 0023 Widget::~Widget() = default; 0024 0025 void Widget::setText(const QString &text) 0026 { 0027 // Until we have proper MIME type detection, simply always try to add links to anything that could be linked 0028 // TODO: does KTextToHTML change text only in a way that QTextEdit::toPlainText() still delivers the original one? 0029 const QString textAsHtml = KTextToHTML::convertToHtml(text, {KTextToHTML::PreserveSpaces | KTextToHTML::ConvertPhoneNumbers}); 0030 m_ui.plainTextView->setHtml(textAsHtml); 0031 } 0032 0033 } 0034 }