#include <private/qdeclarativeglobal_p.h>
#include <private/qdeclarativeproperty_p.h>
#include <private/qtextengine_p.h>
-#include <QtQuick/private/qsgtexture_p.h>
#include <private/qsgadaptationlayer_p.h>
QT_BEGIN_NAMESPACE
-DEFINE_BOOL_CONFIG_OPTION(qmlDisableDistanceField, QML_DISABLE_DISTANCEFIELD)
-DEFINE_BOOL_CONFIG_OPTION(qmlEnableImageCache, QML_ENABLE_TEXT_IMAGE_CACHE)
-
/*!
\qmlclass TextEdit QQuickTextEdit
\inqmlmodule QtQuick 2
#else
d->control->setPlainText(text);
#endif
- d->useImageFallback = qmlEnableImageCache();
} else {
d->control->setPlainText(text);
}
} else if (!wasRich && d->richText) {
d->control->setHtml(!d->textCached ? d->control->toPlainText() : d->text);
updateSize();
- d->useImageFallback = qmlEnableImageCache();
}
#endif
QQuickImplicitSizeItem::componentComplete();
d->document->setBaseUrl(baseUrl(), d->richText);
- if (d->richText)
- d->useImageFallback = qmlEnableImageCache();
-
if (d->dirty) {
d->determineHorizontalAlignment();
d->updateDefaultTextOption();
}
-void QQuickTextEdit::updateImageCache(const QRectF &)
-{
- Q_D(QQuickTextEdit);
-
- // Do we really need the image cache?
- if (!d->richText || !d->useImageFallback) {
- if (!d->pixmapCache.isNull())
- d->pixmapCache = QPixmap();
- return;
- }
-
- if (width() != d->pixmapCache.width() || height() != d->pixmapCache.height())
- d->pixmapCache = QPixmap(width(), height());
-
- if (d->pixmapCache.isNull())
- return;
-
- // ### Use supplied rect, clear area and update only this part (for cursor updates)
- QRectF bounds = QRectF(0, 0, width(), height());
- d->pixmapCache.fill(Qt::transparent);
- {
- QPainter painter(&d->pixmapCache);
-
- painter.setRenderHint(QPainter::TextAntialiasing);
- painter.translate(0, d->yoff);
-
- d->control->drawContents(&painter, bounds);
- }
-
-}
-
void QQuickTextEdit::triggerPreprocess()
{
Q_D(QQuickTextEdit);
d->updateType = QQuickTextEditPrivate::UpdateNone;
QSGNode *currentNode = oldNode;
- if (d->richText && d->useImageFallback) {
- QSGImageNode *node = 0;
- if (oldNode == 0 || d->nodeType != QQuickTextEditPrivate::NodeIsTexture) {
- delete oldNode;
- node = QQuickItemPrivate::get(this)->sceneGraphContext()->createImageNode();
- d->texture = new QSGPlainTexture();
- d->nodeType = QQuickTextEditPrivate::NodeIsTexture;
- currentNode = node;
- } else {
- node = static_cast<QSGImageNode *>(oldNode);
- }
-
- qobject_cast<QSGPlainTexture *>(d->texture)->setImage(d->pixmapCache.toImage());
- node->setTexture(0);
- node->setTexture(d->texture);
-
- node->setTargetRect(QRectF(0, 0, d->pixmapCache.width(), d->pixmapCache.height()));
- node->setSourceRect(QRectF(0, 0, 1, 1));
- node->setHorizontalWrapMode(QSGTexture::ClampToEdge);
- node->setVerticalWrapMode(QSGTexture::ClampToEdge);
- node->setFiltering(QSGTexture::Linear); // Nonsmooth text just ugly, so don't do that..
- node->update();
-
- } else if (oldNode == 0 || d->documentDirty) {
+ if (oldNode == 0 || d->documentDirty) {
d->documentDirty = false;
#if defined(Q_OS_MAC)
#endif
QQuickTextNode *node = 0;
- if (oldNode == 0 || d->nodeType != QQuickTextEditPrivate::NodeIsText) {
- delete oldNode;
+ if (oldNode == 0) {
node = new QQuickTextNode(QQuickItemPrivate::get(this)->sceneGraphContext(), this);
- d->nodeType = QQuickTextEditPrivate::NodeIsText;
currentNode = node;
} else {
node = static_cast<QQuickTextNode *>(oldNode);
#endif
}
- if (d->nodeType == QQuickTextEditPrivate::NodeIsText && d->cursorComponent == 0 && !isReadOnly()) {
+ if (d->cursorComponent == 0 && !isReadOnly()) {
QQuickTextNode *node = static_cast<QQuickTextNode *>(currentNode);
QColor color = (!d->cursorVisible || !d->control->cursorOn())
d->documentDirty = true;
if (isComponentComplete()) {
- updateImageCache();
d->updateType = QQuickTextEditPrivate::UpdatePaintNode;
update();
}
{
Q_D(QQuickTextEdit);
if (isComponentComplete()) {
- updateImageCache(d->control->cursorRect());
d->updateType = QQuickTextEditPrivate::UpdatePaintNode;
update();
}
QTextOption::WrapMode oldWrapMode = opt.wrapMode();
opt.setWrapMode(QTextOption::WrapMode(wrapMode));
+ opt.setUseDesignMetrics(true);
- bool oldUseDesignMetrics = opt.useDesignMetrics();
- bool useDesignMetrics = !qmlDisableDistanceField();
- opt.setUseDesignMetrics(useDesignMetrics);
-
- if (oldWrapMode == opt.wrapMode()
- && oldAlignment == opt.alignment()
- && oldUseDesignMetrics == useDesignMetrics) {
+ if (oldWrapMode == opt.wrapMode() && oldAlignment == opt.alignment())
return;
- }
+
document->setDefaultTextOption(opt);
}
#include "qquickimplicitsizeitem_p_p.h"
#include <QtDeclarative/qdeclarative.h>
-#include <QtGui/qpixmap.h>
QT_BEGIN_NAMESPACE
class QTextLayout;
: color("black"), hAlign(QQuickTextEdit::AlignLeft), vAlign(QQuickTextEdit::AlignTop),
documentDirty(true), dirty(false), richText(false), cursorVisible(false), focusOnPress(true),
persistentSelection(false), requireImplicitWidth(false), selectByMouse(false), canPaste(false),
- canPasteValid(false), hAlignImplicit(true), rightToLeftText(false), useImageFallback(false),
+ canPasteValid(false), hAlignImplicit(true), rightToLeftText(false),
textCached(false),
textMargin(0.0), lastSelectionStart(0), lastSelectionEnd(0), cursorComponent(0), cursor(0),
format(QQuickTextEdit::PlainText), document(0), wrapMode(QQuickTextEdit::NoWrap),
mouseSelectionMode(QQuickTextEdit::SelectCharacters),
- lineCount(0), yoff(0), nodeType(NodeIsNull), texture(0), updateType(UpdatePaintNode)
+ lineCount(0), yoff(0), updateType(UpdatePaintNode)
{
}
bool canPasteValid:1;
bool hAlignImplicit:1;
bool rightToLeftText:1;
- bool useImageFallback:1;
bool textCached:1;
qreal textMargin;
int yoff;
QSize contentSize;
- enum NodeType {
- NodeIsNull,
- NodeIsTexture,
- NodeIsText
- };
- NodeType nodeType;
- QSGTexture *texture;
- QPixmap pixmapCache;
-
enum UpdateType {
UpdateNone,
UpdateOnlyPreprocess,