Baloo Widgets

keditcommentdialog.cpp
1 /*
2  SPDX-FileCopyrightText: 2014 Felix Eisele
3 
4  SPDX-License-Identifier: LGPL-2.0-only
5 */
6 
7 #include "keditcommentdialog.h"
8 
9 #include <QDialogButtonBox>
10 #include <QLabel>
11 #include <QLayout>
12 #include <QPushButton>
13 #include <QTextEdit>
14 #include <QWidget>
15 
16 #include <KLocalizedString>
17 
18 KEditCommentDialog::KEditCommentDialog(QWidget *parent, const QString &commentText, const QString &captionText)
19  : QDialog(parent)
20  , m_editor(new QTextEdit(this))
21 {
22  setWindowTitle(captionText);
23 
24  auto layout = new QVBoxLayout(this);
25 
26  m_editor->setText(commentText);
27 
28  layout->addWidget(m_editor);
29 
30  auto buttonBox = new QDialogButtonBox(this);
31  layout->addWidget(buttonBox);
32 
33  buttonBox->addButton(i18n("Save"), QDialogButtonBox::AcceptRole);
34  buttonBox->addButton(QDialogButtonBox::Cancel);
35 
38 
39  resize(sizeHint());
40 }
41 
42 KEditCommentDialog::~KEditCommentDialog() = default;
43 
44 QString KEditCommentDialog::getCommentText() const
45 {
46  return m_editor->toPlainText();
47 }
virtual void reject()
virtual QLayout * layout() override
QMetaObject::Connection connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
QString i18n(const char *text, const TYPE &arg...)
virtual void accept()
void addWidget(QWidget *w)
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Thu Aug 11 2022 04:13:42 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.