summaryrefslogtreecommitdiffstats
path: root/examples/quick
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2016-10-18 08:33:26 +0200
committerLiang Qi <liang.qi@qt.io>2016-10-18 08:33:26 +0200
commitf04c2c40fd7ee91e5cbff2ca4df0fdc30dfbbcd5 (patch)
tree4e96d097987deb8d4d1a963e911dcbd1641a8502 /examples/quick
parent0da811cdfebdae1d96c99fe681e6a776e73d2f7f (diff)
parente76ed6a2655894bd671ee7397a15f2e57cfc8d33 (diff)
Merge remote-tracking branch 'origin/5.8' into dev
Conflicts: src/qml/jsruntime/qv4variantobject.cpp src/qml/types/qquickworkerscript.cpp src/quick/scenegraph/util/qsgdefaultpainternode_p.h tools/qmljs/qmljs.cpp Change-Id: I876242714ec8c046238d8fd673a5ace2455b2b59
Diffstat (limited to 'examples/quick')
-rw-r--r--examples/quick/demos/tweetsearch/content/LineInput.qml2
-rw-r--r--examples/quick/quickwidgets/quickwidget/main.cpp30
-rw-r--r--examples/quick/quickwidgets/quickwidget/rotatingsquare.qml6
-rw-r--r--examples/quick/scenegraph/rendernode/customrenderitem.cpp2
-rw-r--r--examples/quick/scenegraph/rendernode/d3d12renderer.cpp4
-rw-r--r--examples/quick/scenegraph/rendernode/d3d12renderer.h4
-rw-r--r--examples/quick/scenegraph/rendernode/rendernode.pro3
7 files changed, 35 insertions, 16 deletions
diff --git a/examples/quick/demos/tweetsearch/content/LineInput.qml b/examples/quick/demos/tweetsearch/content/LineInput.qml
index 7e4ffda92b..46bc73f3af 100644
--- a/examples/quick/demos/tweetsearch/content/LineInput.qml
+++ b/examples/quick/demos/tweetsearch/content/LineInput.qml
@@ -62,7 +62,7 @@ FocusScope {
text: "Enter word"
font.pixelSize: 18
color: "#707070"
- opacity: input.length ? 0 : 1
+ opacity: input.displayText.length ? 0 : 1
}
Text {
diff --git a/examples/quick/quickwidgets/quickwidget/main.cpp b/examples/quick/quickwidgets/quickwidget/main.cpp
index 590f29ed29..7cb35d7bcd 100644
--- a/examples/quick/quickwidgets/quickwidget/main.cpp
+++ b/examples/quick/quickwidgets/quickwidget/main.cpp
@@ -39,6 +39,7 @@
****************************************************************************/
#include <QQuickWidget>
+#include <QQuickItem>
#include <QQmlError>
#include <QtWidgets>
#include "fbitem.h"
@@ -51,8 +52,9 @@ public:
private slots:
void quickWidgetStatusChanged(QQuickWidget::Status);
void sceneGraphError(QQuickWindow::SceneGraphError error, const QString &message);
- void grabToFile();
- void renderToFile();
+ void grabFramebuffer();
+ void renderToPixmap();
+ void grabToImage();
void createQuickWidgetsInTabs(QMdiArea *mdiArea);
private:
@@ -93,8 +95,9 @@ MainWindow::MainWindow()
setCentralWidget(centralWidget);
QMenu *fileMenu = menuBar()->addMenu(tr("&File"));
- fileMenu->addAction(tr("Grab to image"), this, &MainWindow::grabToFile);
- fileMenu->addAction(tr("Render to pixmap"), this, &MainWindow::renderToFile);
+ fileMenu->addAction(tr("Grab framebuffer"), this, &MainWindow::grabFramebuffer);
+ fileMenu->addAction(tr("Render to pixmap"), this, &MainWindow::renderToPixmap);
+ fileMenu->addAction(tr("Grab via grabToImage"), this, &MainWindow::grabToImage);
fileMenu->addAction(tr("Quit"), qApp, &QCoreApplication::quit);
QMenu *windowMenu = menuBar()->addMenu(tr("&Window"));
@@ -144,8 +147,7 @@ void MainWindow::sceneGraphError(QQuickWindow::SceneGraphError, const QString &m
template<class T> void saveToFile(QWidget *parent, T *saveable)
{
- QString t;
- QFileDialog fd(parent, t, QString());
+ QFileDialog fd(parent);
fd.setAcceptMode(QFileDialog::AcceptSave);
fd.setDefaultSuffix("png");
fd.selectFile("test.png");
@@ -153,19 +155,31 @@ template<class T> void saveToFile(QWidget *parent, T *saveable)
saveable->save(fd.selectedFiles().first());
}
-void MainWindow::grabToFile()
+void MainWindow::grabFramebuffer()
{
QImage image = m_quickWidget->grabFramebuffer();
saveToFile(this, &image);
}
-void MainWindow::renderToFile()
+void MainWindow::renderToPixmap()
{
QPixmap pixmap(m_quickWidget->size());
m_quickWidget->render(&pixmap);
saveToFile(this, &pixmap);
}
+void MainWindow::grabToImage()
+{
+ QFileDialog fd(this);
+ fd.setAcceptMode(QFileDialog::AcceptSave);
+ fd.setDefaultSuffix("png");
+ fd.selectFile("test_grabToImage.png");
+ if (fd.exec() == QDialog::Accepted) {
+ QMetaObject::invokeMethod(m_quickWidget->rootObject(), "performLayerBasedGrab",
+ Q_ARG(QVariant, fd.selectedFiles().first()));
+ }
+}
+
int main(int argc, char **argv)
{
QApplication app(argc, argv);
diff --git a/examples/quick/quickwidgets/quickwidget/rotatingsquare.qml b/examples/quick/quickwidgets/quickwidget/rotatingsquare.qml
index 0c25eddf88..03b1114d20 100644
--- a/examples/quick/quickwidgets/quickwidget/rotatingsquare.qml
+++ b/examples/quick/quickwidgets/quickwidget/rotatingsquare.qml
@@ -57,4 +57,10 @@ Rectangle {
anchors.centerIn: parent
text: "Qt Quick running in a widget"
}
+
+ function performLayerBasedGrab(fn) {
+ root.grabToImage(function(result) {
+ result.saveToFile(fn);
+ });
+ }
}
diff --git a/examples/quick/scenegraph/rendernode/customrenderitem.cpp b/examples/quick/scenegraph/rendernode/customrenderitem.cpp
index 2465f4cbc7..a92a400922 100644
--- a/examples/quick/scenegraph/rendernode/customrenderitem.cpp
+++ b/examples/quick/scenegraph/rendernode/customrenderitem.cpp
@@ -67,7 +67,7 @@ QSGNode *CustomRenderItem::updatePaintNode(QSGNode *node, UpdatePaintNodeData *)
break;
#endif
case QSGRendererInterface::Direct3D12:
-#ifdef HAS_D3D12
+#if QT_CONFIG(d3d12)
n = new D3D12RenderNode(this);
break;
#endif
diff --git a/examples/quick/scenegraph/rendernode/d3d12renderer.cpp b/examples/quick/scenegraph/rendernode/d3d12renderer.cpp
index d35f82a76a..3b377f1cb1 100644
--- a/examples/quick/scenegraph/rendernode/d3d12renderer.cpp
+++ b/examples/quick/scenegraph/rendernode/d3d12renderer.cpp
@@ -43,7 +43,7 @@
#include <QQuickWindow>
#include <QSGRendererInterface>
-#ifdef HAS_D3D12
+#if QT_CONFIG(d3d12)
#include "vs_shader.hlslh"
#include "ps_shader.hlslh"
@@ -280,4 +280,4 @@ QRectF D3D12RenderNode::rect() const
return QRect(0, 0, m_item->width(), m_item->height());
}
-#endif // HAS_D3D12
+#endif // d3d12
diff --git a/examples/quick/scenegraph/rendernode/d3d12renderer.h b/examples/quick/scenegraph/rendernode/d3d12renderer.h
index f13a1d451c..1d2726819f 100644
--- a/examples/quick/scenegraph/rendernode/d3d12renderer.h
+++ b/examples/quick/scenegraph/rendernode/d3d12renderer.h
@@ -43,7 +43,7 @@
#include <qsgrendernode.h>
-#ifdef HAS_D3D12
+#if QT_CONFIG(d3d12)
class QQuickItem;
@@ -77,6 +77,6 @@ private:
quint8 *cbPtr = nullptr;
};
-#endif // HAS_D3D12
+#endif // d3d12
#endif
diff --git a/examples/quick/scenegraph/rendernode/rendernode.pro b/examples/quick/scenegraph/rendernode/rendernode.pro
index 851d5927bd..968902a5be 100644
--- a/examples/quick/scenegraph/rendernode/rendernode.pro
+++ b/examples/quick/scenegraph/rendernode/rendernode.pro
@@ -18,8 +18,7 @@ OTHER_FILES += \
main.qml \
shader.hlsl
-config_d3d12 {
- DEFINES += HAS_D3D12
+qtConfig(d3d12) {
HEADERS += d3d12renderer.h
SOURCES += d3d12renderer.cpp
LIBS += -ld3d12