aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2013-12-03 18:26:49 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-03 19:41:32 +0100
commit321fcab5933d37ca9cb5097892621aa4979b45fa (patch)
tree72c79563d195aa05d5ca23543aa275cf7e0fa424 /src
parent9ad9615d0003c9fb84255152f0cbb473ee2a7a70 (diff)
parenta79d616501f028183c154f175ec3ed0fa45ffd85 (diff)
Merge "Merge remote-tracking branch 'origin/release' into stable" into refs/staging/stable
Diffstat (limited to 'src')
-rw-r--r--src/qml/doc/qtqml.qdocconf4
-rw-r--r--src/qml/doc/src/cppintegration/extending-tutorial.qdoc45
-rw-r--r--src/quick/items/qquickitem.cpp5
-rw-r--r--src/quick/items/qquicktext.cpp98
-rw-r--r--src/quick/items/qquickwindowmodule.cpp80
-rw-r--r--src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp11
-rw-r--r--src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h4
-rw-r--r--src/quick/scenegraph/qsgthreadedrenderloop.cpp16
-rw-r--r--src/quick/scenegraph/qsgthreadedrenderloop_p.h2
9 files changed, 172 insertions, 93 deletions
diff --git a/src/qml/doc/qtqml.qdocconf b/src/qml/doc/qtqml.qdocconf
index 1b11fa1bf7..74aaae7724 100644
--- a/src/qml/doc/qtqml.qdocconf
+++ b/src/qml/doc/qtqml.qdocconf
@@ -48,6 +48,10 @@ exampledirs += ../../../examples/qml \
imagedirs += images
+# Add a thumbnail for examples that do not have images
+manifestmeta.thumbnail.names += "QtQml/Chapter 4*" \
+ "QtQml/Chapter 6*"
+
navigation.landingpage = "Qt QML"
navigation.cppclassespage = "Qt QML C++ Classes"
navigation.qmltypespage = "Qt QML QML Types"
diff --git a/src/qml/doc/src/cppintegration/extending-tutorial.qdoc b/src/qml/doc/src/cppintegration/extending-tutorial.qdoc
index d0fb03a03c..ecfcf8f106 100644
--- a/src/qml/doc/src/cppintegration/extending-tutorial.qdoc
+++ b/src/qml/doc/src/cppintegration/extending-tutorial.qdoc
@@ -397,36 +397,50 @@ The complete code can be seen in the updated \c examples/qml/tutorials/extending
Currently the \c PieChart and \c PieSlice types are used by \c app.qml,
which is displayed using a QQuickView in a C++ application. An alternative
way to use our QML extension is to create a plugin library to make it available
-to the QML engine. This would allow the \c PieChart and \c PieSlice types to be
-registered into a type namespace which could be imported by any QML application,
-instead of restricting these types to be only used by the one application.
+to the QML engine as a new QML import module. This allows the \c PieChart and
+\c PieSlice types to be registered into a type namespace which can be imported
+by any QML application, instead of restricting these types to be only used by
+the one application.
-The setps for creating a plugin are described in \l {Creating C++ Plugins for QML}.
+The steps for creating a plugin are described in \l {Creating C++ Plugins for QML}.
To start with, we create a plugin class named \c ChartsPlugin. It subclasses QQmlExtensionPlugin
and registers our QML types in the inherited \l{QQmlExtensionPlugin::}{registerTypes()} method.
Here is the \c ChartsPlugin definition in \c chartsplugin.h:
-\snippet tutorials/extending/chapter6-plugins/chartsplugin.h 0
+\snippet tutorials/extending/chapter6-plugins/import/chartsplugin.h 0
And its implementation in \c chartsplugin.cpp:
-\snippet tutorials/extending/chapter6-plugins/chartsplugin.cpp 0
+\snippet tutorials/extending/chapter6-plugins/import/chartsplugin.cpp 0
Then, we write a \c .pro project file that defines the project as a plugin library
-and specifies with DESTDIR that library files should be built into a "lib" subdirectory:
+and specifies with DESTDIR that library files should be built into a \c {../Charts}
+directory.
-\quotefile tutorials/extending/chapter6-plugins/chapter6-plugins.pro
+\quotefile tutorials/extending/chapter6-plugins/import/import.pro
-Finally, we add a \l{qtqml-modules-qmldir.html}{qmldir} file that is
-parsed by the QML engine. In this file, we specify that a plugin named
-"chapter6-plugin" (the name of the example project) can be found in the "lib" subdirectory:
+In this example, the \c Charts directory is located at the same level as the application
+that uses our new import module. This way, the QML engine will find our module
+as the default search path for QML imports includes the directory of the application
+executable. Alternatively, we could control what directories the \l {QML Import Path}
+{QML import path} contains, useful if there are multiple QML applications using the
+same QML imports.
-\quotefile tutorials/extending/chapter6-plugins/Charts/qmldir
+The \c .pro file also contains additional magic to ensure that the
+\l {Module Definition qmldir Files}{module definition qmldir file} is always copied
+to the same location as the plugin binary.
-Now we have a plugin, and instead of having a main.cpp and an executable, we can build
-the project and then load the QML file using the \l{Prototyping with qmlscene}{qmlscene tool},
-setting the import path to the current directory so that it finds the \c qmldir file:
+The \c qmldir file declares the module name and the plugin that is made available
+by the module:
+
+\quotefile tutorials/extending/chapter6-plugins/import/qmldir
+
+Now we have a QML module that can be imported to any application, provided that the
+QML engine knows where to find it. The example contains an executable that loads
+\c app.qml, which uses the \c {import Charts 1.0} statement. Alternatively, you can
+load the QML file using the \l{Prototyping with qmlscene}{qmlscene tool}, setting the
+import path to the current directory so that it finds the \c qmldir file:
\code
qmlscene -I . app.qml
@@ -434,7 +448,6 @@ setting the import path to the current directory so that it finds the \c qmldir
The module "Charts" will be loaded by the QML engine, and the types provided by that
module will be available for use in any QML document which imports it.
-
*/
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()
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
index 79b5de72c0..676efe84bc 100644
--- a/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
+++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer.cpp
@@ -590,15 +590,18 @@ void Element::computeBounds()
}
bounds.map(*node->matrix());
- if (!qIsFinite(bounds.tl.x))
+ if (!qIsFinite(bounds.tl.x) || bounds.tl.x == FLT_MAX)
bounds.tl.x = -FLT_MAX;
- if (!qIsFinite(bounds.tl.y))
+ if (!qIsFinite(bounds.tl.y) || bounds.tl.y == FLT_MAX)
bounds.tl.y = -FLT_MAX;
- if (!qIsFinite(bounds.br.x))
+ if (!qIsFinite(bounds.br.x) || bounds.br.x == -FLT_MAX)
bounds.br.x = FLT_MAX;
- if (!qIsFinite(bounds.br.y))
+ if (!qIsFinite(bounds.br.y) || bounds.br.y == -FLT_MAX)
bounds.br.y = FLT_MAX;
+ Q_ASSERT(bounds.tl.x <= bounds.br.x);
+ Q_ASSERT(bounds.tl.y <= bounds.br.y);
+
boundsOutsideFloatRange = bounds.isOutsideFloatRange();
}
diff --git a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
index 95e111552d..5404b669a0 100644
--- a/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
+++ b/src/quick/scenegraph/coreapi/qsgbatchrenderer_p.h
@@ -104,8 +104,6 @@ struct Rect {
tl.y = pt.y;
if (pt.y > br.y)
br.y = pt.y;
- Q_ASSERT(tl.x <= br.x);
- Q_ASSERT(tl.y <= br.y);
}
void operator |= (const Rect &r) {
@@ -117,8 +115,6 @@ struct Rect {
br.x = r.br.x;
if (r.br.y > br.y)
br.y = r.br.y;
- Q_ASSERT(tl.x <= br.x);
- Q_ASSERT(tl.y <= br.y);
}
void map(const QMatrix4x4 &m);
diff --git a/src/quick/scenegraph/qsgthreadedrenderloop.cpp b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
index bfd24e727a..2759d82e77 100644
--- a/src/quick/scenegraph/qsgthreadedrenderloop.cpp
+++ b/src/quick/scenegraph/qsgthreadedrenderloop.cpp
@@ -817,7 +817,6 @@ void QSGThreadedRenderLoop::show(QQuickWindow *window)
win.thread = new QSGRenderThread(this, QQuickWindowPrivate::get(window)->context);
win.timerId = 0;
win.updateDuringSync = false;
- win.gotBrokenExposeFromPlatformPlugin = false;
m_windows << win;
}
@@ -883,19 +882,6 @@ void QSGThreadedRenderLoop::exposureChanged(QQuickWindow *window)
}
}
-void QSGThreadedRenderLoop::resize(QQuickWindow *window)
-{
- Window *w = windowFor(m_windows, window);
- if (w
- && w->gotBrokenExposeFromPlatformPlugin
- && window->width() > 0 && window->height() > 0
- && w->window->geometry().intersects(w->window->screen()->availableGeometry())) {
- w->gotBrokenExposeFromPlatformPlugin = false;
- handleExposure(w);
- }
-}
-
-
/*!
Will post an event to the render thread that this window should
start to render.
@@ -909,8 +895,6 @@ void QSGThreadedRenderLoop::handleExposure(Window *w)
#ifndef QT_NO_DEBUG
qWarning("QSGThreadedRenderLoop: expose event received for window with invalid geometry.");
#endif
- w->gotBrokenExposeFromPlatformPlugin = true;
- return;
}
// Because we are going to bind a GL context to it, make sure it
diff --git a/src/quick/scenegraph/qsgthreadedrenderloop_p.h b/src/quick/scenegraph/qsgthreadedrenderloop_p.h
index 844d180788..5943d0bd08 100644
--- a/src/quick/scenegraph/qsgthreadedrenderloop_p.h
+++ b/src/quick/scenegraph/qsgthreadedrenderloop_p.h
@@ -60,7 +60,6 @@ public:
void show(QQuickWindow *window);
void hide(QQuickWindow *window);
- void resize(QQuickWindow *window);
void windowDestroyed(QQuickWindow *window);
void exposureChanged(QQuickWindow *window);
@@ -90,7 +89,6 @@ private:
QSGRenderThread *thread;
int timerId;
uint updateDuringSync : 1;
- uint gotBrokenExposeFromPlatformPlugin : 1;
};
friend class QSGRenderThread;