aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquicktextarea.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-01-19 13:19:11 +0100
committerJ-P Nurmi <jpnurmi@qt.io>2017-01-19 12:59:24 +0000
commit945a407d6f6ca25098efcf3bdf138fb622cd5110 (patch)
tree7146610a3c1eaa2ffa8e31492e37c335c6743a60 /src/quicktemplates2/qquicktextarea.cpp
parent9c9f439e8d9ada233ad5c08a8a65b7f48f261733 (diff)
Cleanup QQuickTextArea
Same as the previous commit, but for QQuickTextArea. Change-Id: I8f0880ce51f81a403aa9752cb939716604e464ee Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquicktextarea.cpp')
-rw-r--r--src/quicktemplates2/qquicktextarea.cpp153
1 files changed, 73 insertions, 80 deletions
diff --git a/src/quicktemplates2/qquicktextarea.cpp b/src/quicktemplates2/qquicktextarea.cpp
index 0a6ae07d..fb006c1b 100644
--- a/src/quicktemplates2/qquicktextarea.cpp
+++ b/src/quicktemplates2/qquicktextarea.cpp
@@ -39,10 +39,8 @@
#include "qquickcontrol_p.h"
#include "qquickcontrol_p_p.h"
-#include <QtGui/qguiapplication.h>
#include <QtQml/qqmlinfo.h>
#include <QtQuick/private/qquickitem_p.h>
-#include <QtQuick/private/qquicktext_p.h>
#include <QtQuick/private/qquickclipnode_p.h>
#include <QtQuick/private/qquickflickable_p.h>
@@ -133,8 +131,12 @@ QT_BEGIN_NAMESPACE
*/
QQuickTextAreaPrivate::QQuickTextAreaPrivate()
- : hovered(false), explicitHoverEnabled(false), background(nullptr),
- focusReason(Qt::OtherFocusReason), accessibleAttached(nullptr), flickable(nullptr)
+ : hovered(false),
+ explicitHoverEnabled(false),
+ background(nullptr),
+ focusReason(Qt::OtherFocusReason),
+ accessibleAttached(nullptr),
+ flickable(nullptr)
{
#ifndef QT_NO_ACCESSIBILITY
QAccessible::installActivationObserver(this);
@@ -170,6 +172,50 @@ void QQuickTextAreaPrivate::resizeBackground()
}
}
+/*!
+ \internal
+
+ Determine which font is implicitly imposed on this control by its ancestors
+ and QGuiApplication::font, resolve this against its own font (attributes from
+ the implicit font are copied over). Then propagate this font to this
+ control's children.
+*/
+void QQuickTextAreaPrivate::resolveFont()
+{
+ Q_Q(QQuickTextArea);
+ inheritFont(QQuickControlPrivate::parentFont(q));
+}
+
+void QQuickTextAreaPrivate::inheritFont(const QFont &f)
+{
+ Q_Q(QQuickTextArea);
+ QFont parentFont = font.resolve(f);
+ parentFont.resolve(font.resolve() | f.resolve());
+
+ const QFont defaultFont = QQuickControlPrivate::themeFont(QPlatformTheme::EditorFont);
+ const QFont resolvedFont = parentFont.resolve(defaultFont);
+
+ const bool changed = resolvedFont != sourceFont;
+ q->QQuickTextEdit::setFont(resolvedFont);
+ if (changed)
+ emit q->fontChanged();
+}
+
+void QQuickTextAreaPrivate::updateHoverEnabled(bool enabled, bool xplicit)
+{
+ Q_Q(QQuickTextArea);
+ if (!xplicit && explicitHoverEnabled)
+ return;
+
+ bool wasEnabled = q->isHoverEnabled();
+ explicitHoverEnabled = xplicit;
+ if (wasEnabled != enabled) {
+ q->setAcceptHoverEvents(enabled);
+ QQuickControlPrivate::updateHoverEnabledRecur(q, enabled);
+ emit q->hoverEnabledChanged();
+ }
+}
+
void QQuickTextAreaPrivate::attachFlickable(QQuickFlickable *item)
{
Q_Q(QQuickTextArea);
@@ -305,75 +351,7 @@ void QQuickTextAreaPrivate::implicitHeightChanged()
emit q->implicitHeightChanged3();
}
-QQuickTextArea::QQuickTextArea(QQuickItem *parent)
- : QQuickTextEdit(*(new QQuickTextAreaPrivate), parent)
-{
- Q_D(QQuickTextArea);
- setActiveFocusOnTab(true);
- setAcceptedMouseButtons(Qt::AllButtons);
- d->setImplicitResizeEnabled(false);
- d->pressHandler.control = this;
-#ifndef QT_NO_CURSOR
- setCursor(Qt::IBeamCursor);
-#endif
- QObjectPrivate::connect(this, &QQuickTextEdit::readOnlyChanged,
- d, &QQuickTextAreaPrivate::_q_readOnlyChanged);
-}
-
-QQuickTextArea::~QQuickTextArea()
-{
-}
-
-QQuickTextAreaAttached *QQuickTextArea::qmlAttachedProperties(QObject *object)
-{
- return new QQuickTextAreaAttached(object);
-}
-
-/*!
- \internal
-
- Determine which font is implicitly imposed on this control by its ancestors
- and QGuiApplication::font, resolve this against its own font (attributes from
- the implicit font are copied over). Then propagate this font to this
- control's children.
-*/
-void QQuickTextAreaPrivate::resolveFont()
-{
- Q_Q(QQuickTextArea);
- inheritFont(QQuickControlPrivate::parentFont(q));
-}
-
-void QQuickTextAreaPrivate::inheritFont(const QFont &f)
-{
- Q_Q(QQuickTextArea);
- QFont parentFont = font.resolve(f);
- parentFont.resolve(font.resolve() | f.resolve());
-
- const QFont defaultFont = QQuickControlPrivate::themeFont(QPlatformTheme::EditorFont);
- const QFont resolvedFont = parentFont.resolve(defaultFont);
-
- const bool changed = resolvedFont != sourceFont;
- q->QQuickTextEdit::setFont(resolvedFont);
- if (changed)
- emit q->fontChanged();
-}
-
-void QQuickTextAreaPrivate::updateHoverEnabled(bool enabled, bool xplicit)
-{
- Q_Q(QQuickTextArea);
- if (!xplicit && explicitHoverEnabled)
- return;
-
- bool wasEnabled = q->isHoverEnabled();
- explicitHoverEnabled = xplicit;
- if (wasEnabled != enabled) {
- q->setAcceptHoverEvents(enabled);
- QQuickControlPrivate::updateHoverEnabledRecur(q, enabled);
- emit q->hoverEnabledChanged();
- }
-}
-
-void QQuickTextAreaPrivate::_q_readOnlyChanged(bool isReadOnly)
+void QQuickTextAreaPrivate::readOnlyChanged(bool isReadOnly)
{
#ifndef QT_NO_ACCESSIBILITY
if (accessibleAttached)
@@ -414,6 +392,26 @@ void QQuickTextAreaPrivate::deleteDelegate(QObject *delegate)
pendingDeletions.append(delegate);
}
+QQuickTextArea::QQuickTextArea(QQuickItem *parent)
+ : QQuickTextEdit(*(new QQuickTextAreaPrivate), parent)
+{
+ Q_D(QQuickTextArea);
+ setActiveFocusOnTab(true);
+ setAcceptedMouseButtons(Qt::AllButtons);
+ d->setImplicitResizeEnabled(false);
+ d->pressHandler.control = this;
+#ifndef QT_NO_CURSOR
+ setCursor(Qt::IBeamCursor);
+#endif
+ QObjectPrivate::connect(this, &QQuickTextEdit::readOnlyChanged,
+ d, &QQuickTextAreaPrivate::readOnlyChanged);
+}
+
+QQuickTextAreaAttached *QQuickTextArea::qmlAttachedProperties(QObject *object)
+{
+ return new QQuickTextAreaAttached(object);
+}
+
QFont QQuickTextArea::font() const
{
return QQuickTextEdit::font();
@@ -728,11 +726,10 @@ void QQuickTextArea::mouseDoubleClickEvent(QMouseEvent *event)
void QQuickTextArea::timerEvent(QTimerEvent *event)
{
Q_D(QQuickTextArea);
- if (event->timerId() == d->pressHandler.timer.timerId()) {
+ if (event->timerId() == d->pressHandler.timer.timerId())
d->pressHandler.timerEvent(event);
- } else {
+ else
QQuickTextEdit::timerEvent(event);
- }
}
class QQuickTextAreaAttachedPrivate : public QObjectPrivate
@@ -748,10 +745,6 @@ QQuickTextAreaAttached::QQuickTextAreaAttached(QObject *parent)
{
}
-QQuickTextAreaAttached::~QQuickTextAreaAttached()
-{
-}
-
/*!
\qmlattachedproperty TextArea QtQuick.Controls::TextArea::flickable