diff options
author | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2015-07-21 16:20:38 +0200 |
---|---|---|
committer | Friedemann Kleint <Friedemann.Kleint@theqtcompany.com> | 2015-07-22 22:16:19 +0000 |
commit | 1e2e356f0f4f9f7dd424bc69cff0dce956f528e5 (patch) | |
tree | 0f000a235afa8aac621dc785e8655a99d5dc0a42 /examples | |
parent | bc7dff35723e8f2cf09660b94f7fba9e8478860f (diff) | |
download | qtdeclarative-1e2e356f0f4f9f7dd424bc69cff0dce956f528e5.tar.gz qtdeclarative-1e2e356f0f4f9f7dd424bc69cff0dce956f528e5.tar.bz2 qtdeclarative-1e2e356f0f4f9f7dd424bc69cff0dce956f528e5.zip |
Port examples to new connection syntax.
Change-Id: I121c59ac0ad56acb4cd54b99ecd37567368385ce
Reviewed-by: Alan Alpert <aalpert@blackberry.com>
Diffstat (limited to 'examples')
11 files changed, 30 insertions, 34 deletions
diff --git a/examples/qml/qmlextensionplugins/plugin.cpp b/examples/qml/qmlextensionplugins/plugin.cpp index 729c88da7..56057b7f0 100644 --- a/examples/qml/qmlextensionplugins/plugin.cpp +++ b/examples/qml/qmlextensionplugins/plugin.cpp @@ -110,7 +110,7 @@ public: if (++instances == 1) { if (!timer) timer = new MinuteTimer(QCoreApplication::instance()); - connect(timer, SIGNAL(timeChanged()), this, SIGNAL(timeChanged())); + connect(timer, &MinuteTimer::timeChanged, this, &TimeModel::timeChanged); timer->start(); } } diff --git a/examples/qml/referenceexamples/binding/happybirthdaysong.cpp b/examples/qml/referenceexamples/binding/happybirthdaysong.cpp index 85a541619..975f6d409 100644 --- a/examples/qml/referenceexamples/binding/happybirthdaysong.cpp +++ b/examples/qml/referenceexamples/binding/happybirthdaysong.cpp @@ -45,7 +45,7 @@ HappyBirthdaySong::HappyBirthdaySong(QObject *parent) { setName(QString()); QTimer *timer = new QTimer(this); - QObject::connect(timer, SIGNAL(timeout()), this, SLOT(advance())); + QObject::connect(timer, &QTimer::timeout, this, &HappyBirthdaySong::advance); timer->start(1000); } diff --git a/examples/qml/referenceexamples/valuesource/happybirthdaysong.cpp b/examples/qml/referenceexamples/valuesource/happybirthdaysong.cpp index 7655b3ebc..96b4abe77 100644 --- a/examples/qml/referenceexamples/valuesource/happybirthdaysong.cpp +++ b/examples/qml/referenceexamples/valuesource/happybirthdaysong.cpp @@ -45,7 +45,7 @@ HappyBirthdaySong::HappyBirthdaySong(QObject *parent) { setName(QString()); QTimer *timer = new QTimer(this); - QObject::connect(timer, SIGNAL(timeout()), this, SLOT(advance())); + QObject::connect(timer, &QTimer::timeout, this, &HappyBirthdaySong::advance); timer->start(1000); } diff --git a/examples/quick/embeddedinwidgets/main.cpp b/examples/quick/embeddedinwidgets/main.cpp index aa6da01bd..ef404f9fb 100644 --- a/examples/quick/embeddedinwidgets/main.cpp +++ b/examples/quick/embeddedinwidgets/main.cpp @@ -63,10 +63,10 @@ MainWindow::MainWindow() QVBoxLayout *layout = new QVBoxLayout(centralWidget); m_quickView->setResizeMode(QQuickView::SizeRootObjectToView); - connect(m_quickView, SIGNAL(statusChanged(QQuickView::Status)), - this, SLOT(quickViewStatusChanged(QQuickView::Status))); - connect(m_quickView, SIGNAL(sceneGraphError(QQuickWindow::SceneGraphError,QString)), - this, SLOT(sceneGraphError(QQuickWindow::SceneGraphError,QString))); + connect(m_quickView, &QQuickView::statusChanged, + this, &MainWindow::quickViewStatusChanged); + connect(m_quickView, &QQuickWindow::sceneGraphError, + this, &MainWindow::sceneGraphError); m_quickView->setSource(QUrl(QStringLiteral("qrc:///embeddedinwidgets/main.qml"))); QWidget *container = QWidget::createWindowContainer(m_quickView); @@ -79,8 +79,7 @@ MainWindow::MainWindow() setCentralWidget(centralWidget); QMenu *fileMenu = menuBar()->addMenu(tr("File")); - QAction *quitAction = fileMenu->addAction(tr("Quit")); - connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); + fileMenu->addAction(tr("Quit"), qApp, &QCoreApplication::quit); } void MainWindow::quickViewStatusChanged(QQuickView::Status status) diff --git a/examples/quick/quickwidgets/quickwidget/main.cpp b/examples/quick/quickwidgets/quickwidget/main.cpp index 1e5cf8931..65258d958 100644 --- a/examples/quick/quickwidgets/quickwidget/main.cpp +++ b/examples/quick/quickwidgets/quickwidget/main.cpp @@ -78,10 +78,10 @@ MainWindow::MainWindow() QUrl source("qrc:quickwidget/rotatingsquare.qml"); - connect(m_quickWidget, SIGNAL(statusChanged(QQuickWidget::Status)), - this, SLOT(quickWidgetStatusChanged(QQuickWidget::Status))); - connect(m_quickWidget, SIGNAL(sceneGraphError(QQuickWindow::SceneGraphError,QString)), - this, SLOT(sceneGraphError(QQuickWindow::SceneGraphError,QString))); + connect(m_quickWidget, &QQuickWidget::statusChanged, + this, &MainWindow::quickWidgetStatusChanged); + connect(m_quickWidget, &QQuickWidget::sceneGraphError, + this, &MainWindow::sceneGraphError); m_quickWidget->resize(300,300); m_quickWidget->setResizeMode(QQuickWidget::SizeRootObjectToView ); m_quickWidget->setSource(source); @@ -91,12 +91,9 @@ MainWindow::MainWindow() setCentralWidget(centralWidget); QMenu *fileMenu = menuBar()->addMenu(tr("&File")); - QAction *grabAction = fileMenu->addAction(tr("Grab to image")); - connect(grabAction, SIGNAL(triggered()), this, SLOT(grabToFile())); - QAction *renderAction = fileMenu->addAction(tr("Render to pixmap")); - connect(renderAction, SIGNAL(triggered()), this, SLOT(renderToFile())); - QAction *quitAction = fileMenu->addAction(tr("Quit")); - connect(quitAction, SIGNAL(triggered()), qApp, SLOT(quit())); + fileMenu->addAction(tr("Grab to imFage"), this, &MainWindow::grabToFile); + fileMenu->addAction(tr("Render to pixmap"), this, &MainWindow::renderToFile); + fileMenu->addAction(tr("Quit"), qApp, &QCoreApplication::quit); } void MainWindow::quickWidgetStatusChanged(QQuickWidget::Status status) diff --git a/examples/quick/rendercontrol/window_multithreaded.cpp b/examples/quick/rendercontrol/window_multithreaded.cpp index 8de5a7776..4df3488ab 100644 --- a/examples/quick/rendercontrol/window_multithreaded.cpp +++ b/examples/quick/rendercontrol/window_multithreaded.cpp @@ -353,7 +353,7 @@ void WindowMultiThreaded::polishSyncAndRender() void WindowMultiThreaded::run() { - disconnect(m_qmlComponent, SIGNAL(statusChanged(QQmlComponent::Status)), this, SLOT(run())); + disconnect(m_qmlComponent, &QQmlComponent::statusChanged, this, &WindowMultiThreaded::run); if (m_qmlComponent->isError()) { QList<QQmlError> errorList = m_qmlComponent->errors(); diff --git a/examples/quick/rendercontrol/window_singlethreaded.cpp b/examples/quick/rendercontrol/window_singlethreaded.cpp index 1e81f08f7..e43093e24 100644 --- a/examples/quick/rendercontrol/window_singlethreaded.cpp +++ b/examples/quick/rendercontrol/window_singlethreaded.cpp @@ -206,7 +206,7 @@ void WindowSingleThreaded::requestUpdate() void WindowSingleThreaded::run() { - disconnect(m_qmlComponent, SIGNAL(statusChanged(QQmlComponent::Status)), this, SLOT(run())); + disconnect(m_qmlComponent, &QQmlComponent::statusChanged, this, &WindowSingleThreaded::run); if (m_qmlComponent->isError()) { QList<QQmlError> errorList = m_qmlComponent->errors(); diff --git a/examples/quick/scenegraph/openglunderqml/squircle.cpp b/examples/quick/scenegraph/openglunderqml/squircle.cpp index 2834b93e1..8bb9af1ed 100644 --- a/examples/quick/scenegraph/openglunderqml/squircle.cpp +++ b/examples/quick/scenegraph/openglunderqml/squircle.cpp @@ -42,7 +42,7 @@ Squircle::Squircle() : m_t(0) , m_renderer(0) { - connect(this, SIGNAL(windowChanged(QQuickWindow*)), this, SLOT(handleWindowChanged(QQuickWindow*))); + connect(this, &QQuickItem::windowChanged, this, &Squircle::handleWindowChanged); } //! [7] @@ -62,8 +62,8 @@ void Squircle::setT(qreal t) void Squircle::handleWindowChanged(QQuickWindow *win) { if (win) { - connect(win, SIGNAL(beforeSynchronizing()), this, SLOT(sync()), Qt::DirectConnection); - connect(win, SIGNAL(sceneGraphInvalidated()), this, SLOT(cleanup()), Qt::DirectConnection); + connect(win, &QQuickWindow::beforeSynchronizing, this, &Squircle::sync, Qt::DirectConnection); + connect(win, &QQuickWindow::sceneGraphInvalidated, this, &Squircle::cleanup, Qt::DirectConnection); //! [1] // If we allow QML to do the clearing, they would clear what we paint // and nothing would show. @@ -93,7 +93,7 @@ void Squircle::sync() { if (!m_renderer) { m_renderer = new SquircleRenderer(); - connect(window(), SIGNAL(beforeRendering()), m_renderer, SLOT(paint()), Qt::DirectConnection); + connect(window(), &QQuickWindow::beforeRendering, m_renderer, &SquircleRenderer::paint, Qt::DirectConnection); } m_renderer->setViewportSize(window()->size() * window()->devicePixelRatio()); m_renderer->setT(m_t); diff --git a/examples/quick/scenegraph/textureinthread/threadrenderer.cpp b/examples/quick/scenegraph/textureinthread/threadrenderer.cpp index 272b903ef..95fd377dc 100644 --- a/examples/quick/scenegraph/textureinthread/threadrenderer.cpp +++ b/examples/quick/scenegraph/textureinthread/threadrenderer.cpp @@ -228,7 +228,7 @@ void ThreadRenderer::ready() m_renderThread->moveToThread(m_renderThread); - connect(window(), SIGNAL(sceneGraphInvalidated()), m_renderThread, SLOT(shutDown()), Qt::QueuedConnection); + connect(window(), &QQuickWindow::sceneGraphInvalidated, m_renderThread, &RenderThread::shutDown, Qt::QueuedConnection); m_renderThread->start(); update(); @@ -274,10 +274,10 @@ QSGNode *ThreadRenderer::updatePaintNode(QSGNode *oldNode, UpdatePaintNodeData * * * This FBO rendering pipeline is throttled by vsync on the scene graph rendering thread. */ - connect(m_renderThread, SIGNAL(textureReady(int,QSize)), node, SLOT(newTexture(int,QSize)), Qt::DirectConnection); - connect(node, SIGNAL(pendingNewTexture()), window(), SLOT(update()), Qt::QueuedConnection); - connect(window(), SIGNAL(beforeRendering()), node, SLOT(prepareNode()), Qt::DirectConnection); - connect(node, SIGNAL(textureInUse()), m_renderThread, SLOT(renderNext()), Qt::QueuedConnection); + connect(m_renderThread, &RenderThread::textureReady, node, &TextureNode::newTexture, Qt::DirectConnection); + connect(node, &TextureNode::pendingNewTexture, window(), &QQuickWindow::update, Qt::QueuedConnection); + connect(window(), &QQuickWindow::beforeRendering, node, &TextureNode::prepareNode, Qt::DirectConnection); + connect(node, &TextureNode::textureInUse, m_renderThread, &RenderThread::renderNext, Qt::QueuedConnection); // Get the production of FBO textures started.. QMetaObject::invokeMethod(m_renderThread, "renderNext", Qt::QueuedConnection); diff --git a/examples/quick/scenegraph/threadedanimation/spinner.cpp b/examples/quick/scenegraph/threadedanimation/spinner.cpp index 04b91e544..6fefc33f4 100644 --- a/examples/quick/scenegraph/threadedanimation/spinner.cpp +++ b/examples/quick/scenegraph/threadedanimation/spinner.cpp @@ -49,8 +49,8 @@ public: , m_spinning(false) , m_window(window) { - connect(window, SIGNAL(beforeRendering()), this, SLOT(maybeRotate())); - connect(window, SIGNAL(frameSwapped()), this, SLOT(maybeUpdate())); + connect(window, &QQuickWindow::beforeRendering, this, &SpinnerNode::maybeRotate); + connect(window, &QQuickWindow::frameSwapped, this, &SpinnerNode::maybeUpdate); QImage image(":/scenegraph/threadedanimation/spinner.png"); m_texture = window->createTextureFromImage(image); diff --git a/examples/quick/scenegraph/twotextureproviders/xorblender.cpp b/examples/quick/scenegraph/twotextureproviders/xorblender.cpp index 384d11880..0dd035ffe 100644 --- a/examples/quick/scenegraph/twotextureproviders/xorblender.cpp +++ b/examples/quick/scenegraph/twotextureproviders/xorblender.cpp @@ -151,8 +151,8 @@ public: // If this node is used as in a shader effect source, we need to propegate // changes that will occur in this node outwards. - connect(m_provider1, SIGNAL(textureChanged()), this, SLOT(textureChange()), Qt::DirectConnection); - connect(m_provider2, SIGNAL(textureChanged()), this, SLOT(textureChange()), Qt::DirectConnection); + connect(m_provider1.data(), &QSGTextureProvider::textureChanged, this, &XorNode::textureChange, Qt::DirectConnection); + connect(m_provider2.data(), &QSGTextureProvider::textureChanged, this, &XorNode::textureChange, Qt::DirectConnection); } void preprocess() { |