1 // SPDX-FileCopyrightText: 2021 Carl Schwan <carl@carlschwan.eu> 2 // SPDX-License-Identifier: LGPL-2.0-or-later 3 4 #pragma once 5 6 #include <QObject> 7 #include <QtQml> 8 9 /** 10 * @brief This attached property contains hints for enabling spell checking. 11 * 12 * @warning Kirigami doesn't provide the spell checking, this is just an hint 13 * for the theme. If you want to add spell checking to your custom application 14 * theme checkout \ref Sonnet. 15 * 16 * @code 17 * import org.kde.kirigami 2.18 as Kirigami 18 * TextArea { 19 * Kirigami.SpellChecking.enabled: true 20 * } 21 * @endcode 22 * @author Carl Schwan <carl@carlschwan.eu> 23 * @since 2.18 24 */ 25 class SpellCheckingAttached : public QObject 26 { 27 Q_OBJECT 28 /** 29 * This property holds whether the spell checking should be enabled on the 30 * TextField/TextArea. 31 * 32 * @note By default, false. This might change in KF6, so if you don't want 33 * spellchecking on your application, explicitly set it to false. 34 * 35 * @since 2.18 36 */ 37 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) 38 public: 39 explicit SpellCheckingAttached(QObject *parent = nullptr); 40 ~SpellCheckingAttached() override; 41 42 void setEnabled(bool enabled); 43 bool enabled() const; 44 45 // QML attached property 46 static SpellCheckingAttached *qmlAttachedProperties(QObject *object); 47 48 Q_SIGNALS: 49 void enabledChanged(); 50 51 private: 52 bool m_enabled = false; 53 }; 54 55 QML_DECLARE_TYPEINFO(SpellCheckingAttached, QML_HAS_ATTACHED_PROPERTIES) 56