diff options
Diffstat (limited to 'src/templates')
-rw-r--r-- | src/templates/qquicktextarea.cpp | 52 | ||||
-rw-r--r-- | src/templates/qquicktextarea_p.h | 8 | ||||
-rw-r--r-- | src/templates/qquicktextarea_p_p.h | 3 | ||||
-rw-r--r-- | src/templates/qquicktextfield.cpp | 51 | ||||
-rw-r--r-- | src/templates/qquicktextfield_p.h | 8 | ||||
-rw-r--r-- | src/templates/qquicktextfield_p_p.h | 3 |
6 files changed, 37 insertions, 88 deletions
diff --git a/src/templates/qquicktextarea.cpp b/src/templates/qquicktextarea.cpp index e9b33399..4c23ba9b 100644 --- a/src/templates/qquicktextarea.cpp +++ b/src/templates/qquicktextarea.cpp @@ -58,12 +58,12 @@ QT_BEGIN_NAMESPACE \ingroup qtlabscontrols-input \brief A multi line text input control. - TextArea is a multi-line text editor. TextArea extends TextEdit - with a \l placeholder text functionality, and adds decoration. + TextArea is a multi-line text editor. TextArea extends TextEdit with + a \l {placeholderText}{placeholder text} functionality, and adds decoration. \code TextArea { - placeholder.text: qsTr("Enter description") + placeholderText: qsTr("Enter description") } \endcode @@ -71,7 +71,7 @@ QT_BEGIN_NAMESPACE */ QQuickTextAreaPrivate::QQuickTextAreaPrivate() - : background(Q_NULLPTR), placeholder(Q_NULLPTR), accessibleAttached(Q_NULLPTR) + : background(Q_NULLPTR), accessibleAttached(Q_NULLPTR) { #ifndef QT_NO_ACCESSIBILITY QAccessible::installActivationObserver(this); @@ -171,16 +171,6 @@ void QQuickTextAreaPrivate::_q_readOnlyChanged(bool isReadOnly) #endif } -void QQuickTextAreaPrivate::_q_placeholderTextChanged(const QString &text) -{ -#ifndef QT_NO_ACCESSIBILITY - if (accessibleAttached) - accessibleAttached->setDescription(text); -#else - Q_UNUSED(text) -#endif -} - #ifndef QT_NO_ACCESSIBILITY void QQuickTextAreaPrivate::accessibilityActiveChanged(bool active) { @@ -192,8 +182,7 @@ void QQuickTextAreaPrivate::accessibilityActiveChanged(bool active) if (accessibleAttached) { accessibleAttached->setRole(accessibleRole()); accessibleAttached->set_readOnly(q->isReadOnly()); - if (placeholder) - accessibleAttached->setDescription(placeholder->text()); + accessibleAttached->setDescription(placeholder); } else { qWarning() << "QQuickTextArea: " << q << " QQuickAccessibleAttached object creation failed!"; } @@ -265,39 +254,26 @@ void QQuickTextArea::setBackground(QQuickItem *background) } /*! - \qmlproperty Text Qt.labs.controls::TextArea::placeholder - - This property holds the placeholder text item. + \qmlproperty string Qt.labs.controls::TextArea::placeholderText - \sa {Customizing TextArea} + This property holds the placeholder text. */ -QQuickText *QQuickTextArea::placeholder() const +QString QQuickTextArea::placeholderText() const { Q_D(const QQuickTextArea); return d->placeholder; } -void QQuickTextArea::setPlaceholder(QQuickText *placeholder) +void QQuickTextArea::setPlaceholderText(const QString &text) { Q_D(QQuickTextArea); - if (d->placeholder != placeholder) { - if (d->placeholder) { - QObjectPrivate::disconnect(d->placeholder, &QQuickText::textChanged, - d, &QQuickTextAreaPrivate::_q_placeholderTextChanged); - delete d->placeholder; - } - d->placeholder = placeholder; - if (placeholder && !placeholder->parentItem()) { - placeholder->setParentItem(this); - QObjectPrivate::connect(d->placeholder, &QQuickText::textChanged, - d, &QQuickTextAreaPrivate::_q_placeholderTextChanged); - } else { + if (d->placeholder != text) { + d->placeholder = text; #ifndef QT_NO_ACCESSIBILITY - if (d->accessibleAttached) - d->accessibleAttached->setDescription(QLatin1Literal("")); + if (d->accessibleAttached) + d->accessibleAttached->setDescription(text); #endif - } - emit placeholderChanged(); + emit placeholderTextChanged(); } } diff --git a/src/templates/qquicktextarea_p.h b/src/templates/qquicktextarea_p.h index a77cfeb8..13022ce5 100644 --- a/src/templates/qquicktextarea_p.h +++ b/src/templates/qquicktextarea_p.h @@ -64,7 +64,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickTextArea : public QQuickTextEdit Q_PROPERTY(qreal implicitWidth READ implicitWidth WRITE setImplicitWidth NOTIFY implicitWidthChanged FINAL) Q_PROPERTY(qreal implicitHeight READ implicitHeight WRITE setImplicitHeight NOTIFY implicitHeightChanged FINAL) Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL) - Q_PROPERTY(QQuickText *placeholder READ placeholder WRITE setPlaceholder NOTIFY placeholderChanged FINAL) + Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText NOTIFY placeholderTextChanged FINAL) public: explicit QQuickTextArea(QQuickItem *parent = Q_NULLPTR); @@ -76,15 +76,15 @@ public: QQuickItem *background() const; void setBackground(QQuickItem *background); - QQuickText *placeholder() const; - void setPlaceholder(QQuickText *placeholder); + QString placeholderText() const; + void setPlaceholderText(const QString &text); Q_SIGNALS: void fontChanged(); void implicitWidthChanged(); void implicitHeightChanged(); void backgroundChanged(); - void placeholderChanged(); + void placeholderTextChanged(); void pressAndHold(QQuickMouseEvent *event); protected: diff --git a/src/templates/qquicktextarea_p_p.h b/src/templates/qquicktextarea_p_p.h index ba71ecf8..2960f7bf 100644 --- a/src/templates/qquicktextarea_p_p.h +++ b/src/templates/qquicktextarea_p_p.h @@ -85,7 +85,6 @@ public: void implicitHeightChanged() Q_DECL_OVERRIDE; void _q_readOnlyChanged(bool isReadOnly); - void _q_placeholderTextChanged(const QString &text); #ifndef QT_NO_ACCESSIBILITY void accessibilityActiveChanged(bool active) Q_DECL_OVERRIDE; @@ -93,7 +92,7 @@ public: #endif QQuickItem *background; - QQuickText *placeholder; + QString placeholder; QQuickPressAndHoldHelper pressAndHoldHelper; QQuickAccessibleAttached *accessibleAttached; }; diff --git a/src/templates/qquicktextfield.cpp b/src/templates/qquicktextfield.cpp index b55c799e..dd8ef362 100644 --- a/src/templates/qquicktextfield.cpp +++ b/src/templates/qquicktextfield.cpp @@ -59,8 +59,8 @@ QT_BEGIN_NAMESPACE \ingroup qtlabscontrols-input \brief A single line text input control. - TextField is a single line text editor. TextField extends TextInput - with a \l placeholder text functionality, and adds decoration. + TextField is a single line text editor. TextField extends TextInput with + a \l {placeholderText}{placeholder text} functionality, and adds decoration. \table \row \li \image qtlabscontrols-textfield-normal.png @@ -73,7 +73,7 @@ QT_BEGIN_NAMESPACE \code TextField { - placeholder.text: qsTr("Enter name") + placeholderText: qsTr("Enter name") } \endcode @@ -90,7 +90,6 @@ QT_BEGIN_NAMESPACE QQuickTextFieldPrivate::QQuickTextFieldPrivate() : background(Q_NULLPTR) - , placeholder(Q_NULLPTR) , accessibleAttached(Q_NULLPTR) { #ifndef QT_NO_ACCESSIBILITY @@ -193,16 +192,6 @@ void QQuickTextFieldPrivate::_q_readOnlyChanged(bool isReadOnly) #endif } -void QQuickTextFieldPrivate::_q_placeholderTextChanged(const QString &text) -{ -#ifndef QT_NO_ACCESSIBILITY - if (accessibleAttached) - accessibleAttached->setDescription(text); -#else - Q_UNUSED(text) -#endif -} - void QQuickTextFieldPrivate::_q_echoModeChanged(QQuickTextField::EchoMode echoMode) { #ifndef QT_NO_ACCESSIBILITY @@ -225,8 +214,7 @@ void QQuickTextFieldPrivate::accessibilityActiveChanged(bool active) accessibleAttached->setRole(accessibleRole()); accessibleAttached->set_readOnly(m_readOnly); accessibleAttached->set_passwordEdit((m_echoMode == QQuickTextField::Password || m_echoMode == QQuickTextField::PasswordEchoOnEdit) ? true : false); - if (placeholder) - accessibleAttached->setDescription(placeholder->text()); + accessibleAttached->setDescription(placeholder); } else { qWarning() << "QQuickTextField: " << q << " QQuickAccessibleAttached object creation failed!"; } @@ -298,39 +286,26 @@ void QQuickTextField::setBackground(QQuickItem *background) } /*! - \qmlproperty Text Qt.labs.controls::TextField::placeholder - - This property holds the placeholder text item. + \qmlproperty string Qt.labs.controls::TextField::placeholderText - \sa {Customizing TextField} + This property holds the placeholder text. */ -QQuickText *QQuickTextField::placeholder() const +QString QQuickTextField::placeholderText() const { Q_D(const QQuickTextField); return d->placeholder; } -void QQuickTextField::setPlaceholder(QQuickText *placeholder) +void QQuickTextField::setPlaceholderText(const QString &text) { Q_D(QQuickTextField); - if (d->placeholder != placeholder) { - if (d->placeholder) { - QObjectPrivate::disconnect(d->placeholder, &QQuickText::textChanged, - d, &QQuickTextFieldPrivate::_q_placeholderTextChanged); - delete d->placeholder; - } - d->placeholder = placeholder; - if (placeholder && !placeholder->parentItem()) { - placeholder->setParentItem(this); - QObjectPrivate::connect(d->placeholder, &QQuickText::textChanged, - d, &QQuickTextFieldPrivate::_q_placeholderTextChanged); - } else { + if (d->placeholder != text) { + d->placeholder = text; #ifndef QT_NO_ACCESSIBILITY - if (d->accessibleAttached) - d->accessibleAttached->setDescription(QLatin1Literal("")); + if (d->accessibleAttached) + d->accessibleAttached->setDescription(text); #endif - } - emit placeholderChanged(); + emit placeholderTextChanged(); } } diff --git a/src/templates/qquicktextfield_p.h b/src/templates/qquicktextfield_p.h index 445cf3d9..c219fa79 100644 --- a/src/templates/qquicktextfield_p.h +++ b/src/templates/qquicktextfield_p.h @@ -64,7 +64,7 @@ class Q_LABSTEMPLATES_EXPORT QQuickTextField : public QQuickTextInput Q_PROPERTY(qreal implicitWidth READ implicitWidth WRITE setImplicitWidth NOTIFY implicitWidthChanged FINAL) Q_PROPERTY(qreal implicitHeight READ implicitHeight WRITE setImplicitHeight NOTIFY implicitHeightChanged FINAL) Q_PROPERTY(QQuickItem *background READ background WRITE setBackground NOTIFY backgroundChanged FINAL) - Q_PROPERTY(QQuickText *placeholder READ placeholder WRITE setPlaceholder NOTIFY placeholderChanged FINAL) + Q_PROPERTY(QString placeholderText READ placeholderText WRITE setPlaceholderText NOTIFY placeholderTextChanged FINAL) public: explicit QQuickTextField(QQuickItem *parent = Q_NULLPTR); @@ -76,15 +76,15 @@ public: QQuickItem *background() const; void setBackground(QQuickItem *background); - QQuickText *placeholder() const; - void setPlaceholder(QQuickText *placeholder); + QString placeholderText() const; + void setPlaceholderText(const QString &text); Q_SIGNALS: void fontChanged(); void implicitWidthChanged(); void implicitHeightChanged(); void backgroundChanged(); - void placeholderChanged(); + void placeholderTextChanged(); void pressAndHold(QQuickMouseEvent *mouse); protected: diff --git a/src/templates/qquicktextfield_p_p.h b/src/templates/qquicktextfield_p_p.h index 324ee6fb..459e0847 100644 --- a/src/templates/qquicktextfield_p_p.h +++ b/src/templates/qquicktextfield_p_p.h @@ -85,7 +85,6 @@ public: void implicitHeightChanged() Q_DECL_OVERRIDE; void _q_readOnlyChanged(bool isReadOnly); - void _q_placeholderTextChanged(const QString &text); void _q_echoModeChanged(QQuickTextField::EchoMode echoMode); #ifndef QT_NO_ACCESSIBILITY @@ -94,7 +93,7 @@ public: #endif QQuickItem *background; - QQuickText *placeholder; + QString placeholder; QQuickPressAndHoldHelper pressAndHoldHelper; QQuickAccessibleAttached *accessibleAttached; }; |