Libksieve

multilineedit.cpp
1/*
2 SPDX-FileCopyrightText: 2013-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: LGPL-2.0-or-later
5*/
6#include "multilineedit.h"
7#include <KLocalizedString>
8#include <QStyleOptionFrame>
9
10using namespace KSieveUi;
11
12MultiLineEdit::MultiLineEdit(QWidget *parent)
13 : TextCustomEditor::PlainTextEditor(parent)
14{
15 setPlaceholderText(i18nc("@info:placeholder", "Enter messageā€¦"));
16 setSearchSupport(false);
18 connect(this, &MultiLineEdit::textChanged, this, &MultiLineEdit::valueChanged);
19}
20
21MultiLineEdit::~MultiLineEdit() = default;
22
23QSize MultiLineEdit::sizeHint() const
24{
25 const QFontMetrics fm(font());
26
27 const int h = qMax(document()->size().toSize().height() - fm.descent() + 2 * frameWidth(), 50);
28
30 opt.initFrom(this);
31 opt.rect = QRect(0, 0, 100, h);
32 opt.lineWidth = lineWidth();
33 opt.midLineWidth = 0;
34 opt.state |= QStyle::State_Sunken;
35
36 QSize s = style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(100, h), this);
37
38 return s;
39}
40
41QSize MultiLineEdit::minimumSizeHint() const
42{
43 return sizeHint();
44}
45
46#include "moc_multilineedit.cpp"
QString i18nc(const char *context, const char *text, const TYPE &arg...)
QTextDocument * document() const const
virtual QSize sizeFromContents(ContentsType type, const QStyleOption *option, const QSize &contentsSize, const QWidget *widget) const const=0
void initFrom(const QWidget *widget)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
QStyle * style() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 16:57:10 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.