Kirigami2

spellcheckattached.h
1// SPDX-FileCopyrightText: 2021 Carl Schwan <carl@carlschwan.eu>
2// SPDX-License-Identifier: LGPL-2.0-or-later
3
4#ifndef SPELLCHECKATTACHED_H
5#define SPELLCHECKATTACHED_H
6
7#include <QObject>
8#include <QQmlEngine>
9
10#include <qqmlregistration.h>
11
12/**
13 * @brief This attached property contains hints for spell checker.
14 *
15 * @warning Kirigami doesn't provide any spell checker per se, this is just a
16 * hint for QQC2 style implementation and other downstream components. If you
17 * want to add spell checking to your custom application theme checkout
18 * \ref Sonnet.
19 *
20 * @code
21 * import QtQuick.Controls as QQC2
22 * import org.kde.kirigami as Kirigami
23 *
24 * QQC2.TextArea {
25 * Kirigami.SpellCheck.enabled: true
26 * }
27 * @endcode
28 *
29 * @author Carl Schwan <carl@carlschwan.eu>
30 * @since 2.18
31 */
33{
35 QML_ELEMENT
36 QML_NAMED_ELEMENT(SpellCheck)
37 QML_UNCREATABLE("Attached property only")
38 QML_ATTACHED(SpellCheckAttached)
39
40 /**
41 * This property holds whether the spell checking should be enabled on the
42 * TextField/TextArea.
43 *
44 * @note By default, false. This might change in KF6, so if you don't want
45 * spellcheck in your application, explicitly set it to false.
46 *
47 * @since 2.18
48 */
49 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged FINAL)
50public:
51 explicit SpellCheckAttached(QObject *parent = nullptr);
52 ~SpellCheckAttached() override;
53
54 void setEnabled(bool enabled);
55 bool enabled() const;
56
57 // QML attached property
58 static SpellCheckAttached *qmlAttachedProperties(QObject *object);
59
61 void enabledChanged();
62
63private:
64 bool m_enabled = false;
65};
66
67QML_DECLARE_TYPEINFO(SpellCheckAttached, QML_HAS_ATTACHED_PROPERTIES)
68
69#endif // SPELLCHECKATTACHED_H
This attached property contains hints for spell checker.
QML_ELEMENTbool enabled
This property holds whether the spell checking should be enabled on the TextField/TextArea.
Q_OBJECTQ_OBJECT
Q_PROPERTY(...)
Q_SIGNALSQ_SIGNALS
QObject * parent() const const
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 19 2024 11:52:23 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.