File indexing completed on 2024-04-21 03:56:02
0001 // SPDX-FileCopyrightText: 2021 Carl Schwan <carl@carlschwan.eu> 0002 // SPDX-License-Identifier: LGPL-2.0-or-later 0003 0004 #ifndef SPELLCHECKATTACHED_H 0005 #define SPELLCHECKATTACHED_H 0006 0007 #include <QObject> 0008 #include <QQmlEngine> 0009 0010 #include <qqmlregistration.h> 0011 0012 /** 0013 * @brief This attached property contains hints for spell checker. 0014 * 0015 * @warning Kirigami doesn't provide any spell checker per se, this is just a 0016 * hint for QQC2 style implementation and other downstream components. If you 0017 * want to add spell checking to your custom application theme checkout 0018 * \ref Sonnet. 0019 * 0020 * @code 0021 * import QtQuick.Controls as QQC2 0022 * import org.kde.kirigami as Kirigami 0023 * 0024 * QQC2.TextArea { 0025 * Kirigami.SpellCheck.enabled: true 0026 * } 0027 * @endcode 0028 * 0029 * @author Carl Schwan <carl@carlschwan.eu> 0030 * @since 2.18 0031 */ 0032 class SpellCheckAttached : public QObject 0033 { 0034 Q_OBJECT 0035 QML_ELEMENT 0036 QML_NAMED_ELEMENT(SpellCheck) 0037 QML_UNCREATABLE("Attached property only") 0038 QML_ATTACHED(SpellCheckAttached) 0039 0040 /** 0041 * This property holds whether the spell checking should be enabled on the 0042 * TextField/TextArea. 0043 * 0044 * @note By default, false. This might change in KF6, so if you don't want 0045 * spellcheck in your application, explicitly set it to false. 0046 * 0047 * @since 2.18 0048 */ 0049 Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged FINAL) 0050 public: 0051 explicit SpellCheckAttached(QObject *parent = nullptr); 0052 ~SpellCheckAttached() override; 0053 0054 void setEnabled(bool enabled); 0055 bool enabled() const; 0056 0057 // QML attached property 0058 static SpellCheckAttached *qmlAttachedProperties(QObject *object); 0059 0060 Q_SIGNALS: 0061 void enabledChanged(); 0062 0063 private: 0064 bool m_enabled = false; 0065 }; 0066 0067 QML_DECLARE_TYPEINFO(SpellCheckAttached, QML_HAS_ATTACHED_PROPERTIES) 0068 0069 #endif // SPELLCHECKATTACHED_H