File indexing completed on 2024-05-12 16:27:15
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 "messagetexteditor.h" 0008 0009 MessageTextEditor::MessageTextEditor(QWidget *parent) 0010 : KTextEdit(parent) 0011 { 0012 setAcceptRichText(false); 0013 } 0014 0015 MessageTextEditor::~MessageTextEditor() = default; 0016 0017 QSize MessageTextEditor::sizeHint() const 0018 { 0019 // The width of the QTextDocument is the current widget width, so this is somewhat circular logic. 0020 // But I don't really want to redo the layout with a different width like idealWidth(), seems slow. 0021 const QSize docSize = document()->size().toSize(); 0022 const int margin = int(document()->documentMargin()); 0023 return {docSize.width() + margin, qMin(300, 2 * docSize.height()) + margin}; 0024 } 0025 0026 QSize MessageTextEditor::minimumSizeHint() const 0027 { 0028 const int margin = int(document()->documentMargin()); 0029 return {300, fontMetrics().height() * 2 + margin}; 0030 } 0031 0032 #include "moc_messagetexteditor.cpp"