Libksieve

multilineedit.cpp
1 /*
2  SPDX-FileCopyrightText: 2013-2021 Laurent Montel <[email protected]>
3 
4  SPDX-License-Identifier: LGPL-2.0-or-later
5 */
6 #include "multilineedit.h"
7 #include <KLocalizedString>
8 #include <QStyleOptionFrame>
9 
10 using namespace KSieveUi;
11 
12 MultiLineEdit::MultiLineEdit(QWidget *parent)
13  : KPIMTextEdit::PlainTextEditor(parent)
14 {
15  setPlaceholderText(i18n("Enter message..."));
16  setSearchSupport(false);
18  connect(this, &MultiLineEdit::textChanged, this, &MultiLineEdit::valueChanged);
19 }
20 
21 MultiLineEdit::~MultiLineEdit()
22 {
23 }
24 
25 QSize MultiLineEdit::sizeHint() const
26 {
27  QFontMetrics fm(font());
28 
29  const int h = qMax(document()->size().toSize().height() - fm.descent() + 2 * frameWidth(), 50);
30 
32  opt.initFrom(this);
33  opt.rect = QRect(0, 0, 100, h);
34  opt.lineWidth = lineWidth();
35  opt.midLineWidth = 0;
36  opt.state |= QStyle::State_Sunken;
37 
38  QSize s = style()->sizeFromContents(QStyle::CT_LineEdit, &opt, QSize(100, h), this);
39 
40  return s;
41 }
42 
43 QSize MultiLineEdit::minimumSizeHint() const
44 {
45  return sizeHint();
46 }
void initFrom(const QWidget *widget)
QString i18n(const char *text, const TYPE &arg...)
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
This file is part of the KDE documentation.
Documentation copyright © 1996-2021 The KDE developers.
Generated on Fri Apr 16 2021 23:09:33 by doxygen 1.8.11 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.