File indexing completed on 2024-04-28 15:27:44

0001 // SPDX-FileCopyrightText: 2021 Carl Schwan <carl@carlschwan.eu>
0002 // SPDX-License-Identifier: LGPL-2.0-or-later
0003 
0004 #pragma once
0005 
0006 #include <QObject>
0007 #include <QQmlEngine>
0008 
0009 /**
0010  * @brief This attached property contains hints for enabling spell checking.
0011  *
0012  * @warning Kirigami doesn't provide the spell checking, this is just an hint
0013  * for the theme. If you want to add spell checking to your custom application
0014  * theme checkout \ref Sonnet.
0015  *
0016  * @code
0017  * import org.kde.kirigami 2.18 as Kirigami
0018  * TextArea {
0019  *    Kirigami.SpellChecking.enabled: true
0020  * }
0021  * @endcode
0022  * @author Carl Schwan <carl@carlschwan.eu>
0023  * @since org.kde.kirigami 2.18
0024  */
0025 class SpellCheckingAttached : public QObject
0026 {
0027     Q_OBJECT
0028     /**
0029      * @brief This property holds whether the spell checking should be enabled on the
0030      * TextField/TextArea.
0031      *
0032      * @note By default, false. This might change in KF6, so if you don't want
0033      * spellchecking on your application, explicitly set it to false.
0034      *
0035      * @since org.kde.kirigami 2.18
0036      */
0037     Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged)
0038 public:
0039     explicit SpellCheckingAttached(QObject *parent = nullptr);
0040     ~SpellCheckingAttached() override;
0041 
0042     void setEnabled(bool enabled);
0043     bool enabled() const;
0044 
0045     // QML attached property
0046     static SpellCheckingAttached *qmlAttachedProperties(QObject *object);
0047 
0048 Q_SIGNALS:
0049     void enabledChanged();
0050 
0051 private:
0052     bool m_enabled = false;
0053 };
0054 
0055 QML_DECLARE_TYPEINFO(SpellCheckingAttached, QML_HAS_ATTACHED_PROPERTIES)