From f55df96ab51e590f73a7878742662758c1c4369b Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Tue, 17 Apr 2018 17:02:30 +0200 Subject: Examples: Name signal arguments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Use a function declaration for all signal handlers that take at least one argument. Directly referencing the signal values is less robust and arguably too much magic. Change-Id: I49a48e336bdc2149643770b978826884515cc4ad Reviewed-by: Jüri Valdmann Reviewed-by: Michael Brüning --- .../webengine/quicknanobrowser/BrowserDialog.qml | 2 +- .../webengine/quicknanobrowser/BrowserWindow.qml | 33 ++++++++++++++-------- .../webengine/recipebrowser/resources/qml/main.qml | 6 ++-- 3 files changed, 26 insertions(+), 15 deletions(-) (limited to 'examples') diff --git a/examples/webengine/quicknanobrowser/BrowserDialog.qml b/examples/webengine/quicknanobrowser/BrowserDialog.qml index 770cfee6a..6b0b3acd6 100644 --- a/examples/webengine/quicknanobrowser/BrowserDialog.qml +++ b/examples/webengine/quicknanobrowser/BrowserDialog.qml @@ -64,7 +64,7 @@ Window { id: webView anchors.fill: parent - onGeometryChangeRequested: { + onGeometryChangeRequested: function(geometry) { window.x = geometry.x window.y = geometry.y window.width = geometry.width diff --git a/examples/webengine/quicknanobrowser/BrowserWindow.qml b/examples/webengine/quicknanobrowser/BrowserWindow.qml index 5e98997ee..5693ffccc 100644 --- a/examples/webengine/quicknanobrowser/BrowserWindow.qml +++ b/examples/webengine/quicknanobrowser/BrowserWindow.qml @@ -206,8 +206,12 @@ ApplicationWindow { enabled: model.offset } - onObjectAdded: historyMenu.insertItem(index, object) - onObjectRemoved: historyMenu.removeItem(object) + onObjectAdded: function(index, object) { + historyMenu.insertItem(index, object) + } + onObjectRemoved: function(index, object) { + historyMenu.removeItem(object) + } } } } @@ -291,14 +295,18 @@ ApplicationWindow { text: "Off The Record" checkable: true checked: currentWebView.profile.offTheRecord - onToggled: currentWebView.profile = checked ? otrProfile : defaultProfile; + onToggled: function(checked) { + currentWebView.profile = checked ? otrProfile : defaultProfile; + } } MenuItem { id: httpDiskCacheEnabled text: "HTTP Disk Cache" checkable: !currentWebView.profile.offTheRecord checked: (currentWebView.profile.httpCacheType === WebEngineProfile.DiskHttpCache) - onToggled: currentWebView.profile.httpCacheType = checked ? WebEngineProfile.DiskHttpCache : WebEngineProfile.MemoryHttpCache + onToggled: function(checked) { + currentWebView.profile.httpCacheType = checked ? WebEngineProfile.DiskHttpCache : WebEngineProfile.MemoryHttpCache; + } } MenuItem { id: autoLoadIconsForPage @@ -368,7 +376,7 @@ ApplicationWindow { id: webEngineView focus: true - onLinkHovered: { + onLinkHovered: function(hoveredUrl) { if (hoveredUrl == "") resetStatusText.start(); else { @@ -400,12 +408,12 @@ ApplicationWindow { settings.touchIconsEnabled: appSettings.touchIconsEnabled settings.webRTCPublicInterfacesOnly: appSettings.webRTCPublicInterfacesOnly - onCertificateError: { + onCertificateError: function(error) { error.defer(); sslDialog.enqueue(error); } - onNewViewRequested: { + onNewViewRequested: function(request) { if (!request.userInitiated) print("Warning: Blocked a popup window."); else if (request.destination == WebEngineView.NewViewInTab) { @@ -424,7 +432,7 @@ ApplicationWindow { } } - onFullScreenRequested: { + onFullScreenRequested: function(request) { if (request.toggleOn) { webEngineView.state = "FullScreen"; browserWindow.previousVisibility = browserWindow.visibility; @@ -438,19 +446,20 @@ ApplicationWindow { request.accept(); } - onQuotaRequested: { + onQuotaRequested: function(request) { if (request.requestedSize <= 5 * 1024 * 1024) request.accept(); else request.reject(); } - onRegisterProtocolHandlerRequested: { - print("accepting registerProtocolHandler request for " + request.scheme + " from " + request.origin); + onRegisterProtocolHandlerRequested: function(request) { + console.log("accepting registerProtocolHandler request for " + + request.scheme + " from " + request.origin); request.accept(); } - onRenderProcessTerminated: { + onRenderProcessTerminated: function(terminationStatus, exitCode) { var status = ""; switch (terminationStatus) { case WebEngineView.NormalTerminationStatus: diff --git a/examples/webengine/recipebrowser/resources/qml/main.qml b/examples/webengine/recipebrowser/resources/qml/main.qml index 899d307cf..2639b6b5d 100644 --- a/examples/webengine/recipebrowser/resources/qml/main.qml +++ b/examples/webengine/recipebrowser/resources/qml/main.qml @@ -99,7 +99,9 @@ ApplicationWindow { Layout.fillHeight: true focus: true KeyNavigation.tab: webView - onRecipeSelected: webView.showRecipe(url) + onRecipeSelected: function(url) { + webView.showRecipe(url) + } } WebEngineView { @@ -118,7 +120,7 @@ ApplicationWindow { } property bool firstLoadComplete: false - onLoadingChanged: { + onLoadingChanged: function(loadRequest) { if (loadRequest.status === WebEngineView.LoadSucceededStatus && !firstLoadComplete) { // Debounce the showing of the web content, so images are more likely -- cgit v1.2.3