KTextAddons

grammarresultwidget.cpp
1/*
2 SPDX-FileCopyrightText: 2019-2024 Laurent Montel <montel@kde.org>
3
4 SPDX-License-Identifier: GPL-2.0-or-later
5*/
6
7#include "grammarresultwidget.h"
8#include "grammarresulttextedit.h"
9
10#include <KLocalizedString>
11
12#include <QHBoxLayout>
13#include <QToolButton>
14using namespace TextGrammarCheck;
15GrammarResultWidget::GrammarResultWidget(QWidget *parent)
16 : QWidget(parent)
17 , mResult(new GrammarResultTextEdit(this))
18{
19 auto mainLayout = new QVBoxLayout(this);
20 mainLayout->setObjectName(QStringLiteral("mainlayout"));
21 mainLayout->setContentsMargins({});
22 mainLayout->setSpacing(0);
23
24 mExtraWidgetLayout = new QHBoxLayout;
25 mExtraWidgetLayout->setContentsMargins({});
26 mainLayout->addLayout(mExtraWidgetLayout);
27
28 auto closeBtn = new QToolButton(this);
29 closeBtn->setObjectName(QStringLiteral("close-button"));
30 closeBtn->setIcon(QIcon::fromTheme(QStringLiteral("dialog-close")));
31 closeBtn->setIconSize(QSize(16, 16));
32 closeBtn->setToolTip(i18nc("@info:tooltip", "Close"));
33 closeBtn->setAutoRaise(true);
34 mExtraWidgetLayout->addWidget(closeBtn);
35 mExtraWidgetLayout->addStretch(1);
36 connect(closeBtn, &QToolButton::clicked, this, &GrammarResultWidget::closeChecker);
37
38 mResult->setObjectName(QStringLiteral("grammarResult"));
39 connect(mResult, &GrammarResultTextEdit::replaceText, this, &GrammarResultWidget::replaceText);
40 connect(mResult, &GrammarResultTextEdit::checkAgain, this, &GrammarResultWidget::checkAgain);
41 connect(mResult, &GrammarResultTextEdit::closeChecker, this, &GrammarResultWidget::closeChecker);
42 connect(mResult, &GrammarResultTextEdit::configure, this, &GrammarResultWidget::configure);
43 mainLayout->addWidget(mResult);
44}
45
46GrammarResultWidget::~GrammarResultWidget() = default;
47
48void GrammarResultWidget::addExtraWidget()
49{
50}
51
52void GrammarResultWidget::setText(const QString &str)
53{
54 mResult->setText(str);
55}
56
57void GrammarResultWidget::applyGrammarResult(const QVector<GrammarError> &infos)
58{
59 mResult->applyGrammarResult(infos);
60}
61
62#include "moc_grammarresultwidget.cpp"
QString i18nc(const char *context, const char *text, const TYPE &arg...)
void clicked(bool checked)
QIcon fromTheme(const QString &name)
void setContentsMargins(const QMargins &margins)
void setText(const QString &text)
QFuture< ArgsType< Signal > > connect(Sender *sender, Signal signal)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 4 2024 16:29:59 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.