diff options
Diffstat (limited to 'src/quick/items')
-rw-r--r-- | src/quick/items/qquickitem.cpp | 5 | ||||
-rw-r--r-- | src/quick/items/qquicktext.cpp | 98 | ||||
-rw-r--r-- | src/quick/items/qquickwindowmodule.cpp | 80 |
3 files changed, 132 insertions, 51 deletions
diff --git a/src/quick/items/qquickitem.cpp b/src/quick/items/qquickitem.cpp index c11bf904be..a0329f7afc 100644 --- a/src/quick/items/qquickitem.cpp +++ b/src/quick/items/qquickitem.cpp @@ -7012,7 +7012,10 @@ bool QQuickItem::event(QEvent *ev) } else #endif // QT_NO_IM if (ev->type() == QEvent::StyleAnimationUpdate) { - update(); + if (isVisible()) { + ev->accept(); + update(); + } return true; } return QObject::event(ev); diff --git a/src/quick/items/qquicktext.cpp b/src/quick/items/qquicktext.cpp index d62bf8efa1..ad904a2579 100644 --- a/src/quick/items/qquicktext.cpp +++ b/src/quick/items/qquicktext.cpp @@ -297,44 +297,6 @@ qreal QQuickTextPrivate::getImplicitHeight() const return implicitHeight; } -/*! - \qmlproperty enumeration QtQuick::Text::renderType - - Override the default rendering type for this component. - - Supported render types are: - \list - \li Text.QtRendering - the default - \li Text.NativeRendering - \endlist - - Select Text.NativeRendering if you prefer text to look native on the target platform and do - not require advanced features such as transformation of the text. Using such features in - combination with the NativeRendering render type will lend poor and sometimes pixelated - results. - - On HighDpi "retina" displays and mobile and embedded platforms, this property is ignored - and QtRendering is always used. -*/ -QQuickText::RenderType QQuickText::renderType() const -{ - Q_D(const QQuickText); - return d->renderType; -} - -void QQuickText::setRenderType(QQuickText::RenderType renderType) -{ - Q_D(QQuickText); - if (d->renderType == renderType) - return; - - d->renderType = renderType; - emit renderTypeChanged(); - - if (isComponentComplete()) - d->updateLayout(); -} - void QQuickText::q_imagesLoaded() { Q_D(QQuickText); @@ -641,17 +603,6 @@ void QQuickTextLine::setY(qreal y) m_line->setPosition(QPointF(m_line->x(), y)); } -/*! - \qmlmethod QtQuick::Text::doLayout() - - Triggers a re-layout of the displayed text. -*/ -void QQuickText::doLayout() -{ - Q_D(QQuickText); - d->updateSize(); -} - bool QQuickTextPrivate::isLineLaidOutConnected() { Q_Q(QQuickText); @@ -2665,4 +2616,53 @@ void QQuickText::hoverLeaveEvent(QHoverEvent *event) d->processHoverEvent(event); } +/*! + \qmlproperty enumeration QtQuick::Text::renderType + + Override the default rendering type for this component. + + Supported render types are: + \list + \li Text.QtRendering - the default + \li Text.NativeRendering + \endlist + + Select Text.NativeRendering if you prefer text to look native on the target platform and do + not require advanced features such as transformation of the text. Using such features in + combination with the NativeRendering render type will lend poor and sometimes pixelated + results. + + On HighDpi "retina" displays and mobile and embedded platforms, this property is ignored + and QtRendering is always used. +*/ +QQuickText::RenderType QQuickText::renderType() const +{ + Q_D(const QQuickText); + return d->renderType; +} + +void QQuickText::setRenderType(QQuickText::RenderType renderType) +{ + Q_D(QQuickText); + if (d->renderType == renderType) + return; + + d->renderType = renderType; + emit renderTypeChanged(); + + if (isComponentComplete()) + d->updateLayout(); +} + +/*! + \qmlmethod QtQuick::Text::doLayout() + + Triggers a re-layout of the displayed text. +*/ +void QQuickText::doLayout() +{ + Q_D(QQuickText); + d->updateSize(); +} + QT_END_NAMESPACE diff --git a/src/quick/items/qquickwindowmodule.cpp b/src/quick/items/qquickwindowmodule.cpp index b91edc2fd5..cd1b68991d 100644 --- a/src/quick/items/qquickwindowmodule.cpp +++ b/src/quick/items/qquickwindowmodule.cpp @@ -45,12 +45,50 @@ #include <QtCore/QCoreApplication> #include <QtQml/QQmlEngine> +#include <private/qguiapplication_p.h> +#include <private/qqmlengine_p.h> +#include <qpa/qplatformintegration.h> + QT_BEGIN_NAMESPACE class QQuickWindowQmlImpl : public QQuickWindow, public QQmlParserStatus { Q_INTERFACES(QQmlParserStatus) Q_OBJECT + + Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) + Q_PROPERTY(Visibility visibility READ visibility WRITE setVisibility NOTIFY visibilityChanged) + +public: + QQuickWindowQmlImpl(QWindow *parent = 0) + : QQuickWindow(parent) + , m_complete(false) + , m_visible(isVisible()) + , m_visibility(AutomaticVisibility) + { + connect(this, &QWindow::visibleChanged, this, &QQuickWindowQmlImpl::visibleChanged); + connect(this, &QWindow::visibilityChanged, this, &QQuickWindowQmlImpl::visibilityChanged); + } + + void setVisible(bool visible) { + if (!m_complete) + m_visible = visible; + else + QQuickWindow::setVisible(visible); + } + + void setVisibility(Visibility visibility) + { + if (!m_complete) + m_visibility = visibility; + else + QQuickWindow::setVisibility(m_visibility); + } + +Q_SIGNALS: + void visibleChanged(bool arg); + void visibilityChanged(QWindow::Visibility visibility); + protected: void classBegin() { //Give QQuickView behavior when created from QML with QQmlApplicationEngine @@ -61,7 +99,47 @@ protected: } } - void componentComplete() {} + void componentComplete() { + m_complete = true; + + // We have deferred window creation until we have the full picture of what + // the user wanted in terms of window state, geometry, visibility, etc. + + if ((m_visibility == Hidden && m_visible) || (m_visibility > AutomaticVisibility && !m_visible)) { + QQmlData *data = QQmlData::get(this); + Q_ASSERT(data && data->context); + + QQmlError error; + error.setObject(this); + + const QQmlContextData* urlContext = data->context; + while (urlContext && urlContext->url.isEmpty()) + urlContext = urlContext->parent; + error.setUrl(urlContext ? urlContext->url : QUrl()); + + QString objectId = data->context->findObjectId(this); + if (!objectId.isEmpty()) + error.setDescription(QCoreApplication::translate("QQuickWindowQmlImpl", + "Conflicting properties 'visible' and 'visibility' for Window '%1'").arg(objectId)); + else + error.setDescription(QCoreApplication::translate("QQuickWindowQmlImpl", + "Conflicting properties 'visible' and 'visibility'")); + + QQmlEnginePrivate::get(data->context->engine)->warning(error); + } + + if (m_visibility == AutomaticVisibility) { + setWindowState(QGuiApplicationPrivate::platformIntegration()->defaultWindowState(flags())); + setVisible(m_visible); + } else { + setVisibility(m_visibility); + } + } + +private: + bool m_complete; + bool m_visible; + Visibility m_visibility; }; void QQuickWindowModule::defineModule() |