diff --git a/examples/custompopups/CustomAlertPopup.qml b/examples/custompopups/CustomAlertPopup.qml index 1c21794..7511293 100644 --- a/examples/custompopups/CustomAlertPopup.qml +++ b/examples/custompopups/CustomAlertPopup.qml @@ -10,8 +10,9 @@ import Sailfish.WebView.Popups 1.0 AlertPopupInterface { id: popup - width: (parent.width/5)*4 - height: (parent.height/5)*4 + + width: (parent.width / 5) * 4 + height: (parent.height / 5) * 4 anchors.centerIn: parent acceptText: "Dismiss" @@ -24,11 +25,13 @@ AlertPopupInterface { SilicaFlickable { id: flickable + anchors.fill: parent contentHeight: content.height + Theme.paddingLarge Column { id: content + width: parent.width - 2 * Theme.horizontalPageMargin anchors.centerIn: parent spacing: Theme.paddingLarge @@ -48,6 +51,7 @@ AlertPopupInterface { } TextSwitch { id: toggle + anchors.horizontalCenter: parent.horizontalCenter height: visible ? implicitHeight : 0 visible: popup.preventDialogsVisible diff --git a/examples/custompopups/CustomAuthPopup.qml b/examples/custompopups/CustomAuthPopup.qml index 1492ff2..3b0b4b0 100644 --- a/examples/custompopups/CustomAuthPopup.qml +++ b/examples/custompopups/CustomAuthPopup.qml @@ -10,8 +10,9 @@ import Sailfish.WebView.Popups 1.0 AuthPopupInterface { id: popup - width: (parent.width/5)*4 - height: (parent.height/5)*4 + + width: (parent.width / 5) * 4 + height: (parent.height / 5) * 4 anchors.centerIn: parent usernameValue: username.text @@ -28,11 +29,13 @@ AuthPopupInterface { SilicaFlickable { id: flickable + anchors.fill: parent contentHeight: content.height + Theme.paddingLarge Column { id: content + width: parent.width - 2 * Theme.horizontalPageMargin anchors.centerIn: parent spacing: Theme.paddingLarge @@ -87,17 +90,18 @@ AuthPopupInterface { } Button { - id: acceptBtn anchors.horizontalCenter: parent.horizontalCenter text: popup.acceptText onClicked: { popup.accepted(); popup.visible = false } } Button { - id: rejectBtn anchors.horizontalCenter: parent.horizontalCenter text: popup.cancelText - onClicked: { popup.rejected(); popup.visible = false } + onClicked: { + popup.rejected() + popup.visible = false + } } } } diff --git a/examples/custompopups/CustomBlockedTabPopup.qml b/examples/custompopups/CustomBlockedTabPopup.qml index 1abf6f7..84b4061 100644 --- a/examples/custompopups/CustomBlockedTabPopup.qml +++ b/examples/custompopups/CustomBlockedTabPopup.qml @@ -10,8 +10,9 @@ import Sailfish.WebView.Popups 1.0 BlockedTabPopupInterface { id: popup - width: (parent.width/5)*4 - height: (parent.height/5)*4 + + width: (parent.width / 5) * 4 + height: (parent.height / 5) * 4 anchors.centerIn: parent rememberValue: toggle.checked @@ -26,11 +27,13 @@ BlockedTabPopupInterface { SilicaFlickable { id: flickable + anchors.fill: parent contentHeight: content.height + Theme.paddingLarge Column { id: content + width: parent.width - 2 * Theme.horizontalPageMargin anchors.centerIn: parent spacing: Theme.paddingLarge @@ -54,7 +57,10 @@ BlockedTabPopupInterface { Button { anchors.horizontalCenter: parent.horizontalCenter text: popup.cancelText - onClicked: { popup.rejected(); popup.visible = false } + onClicked: { + popup.rejected() + popup.visible = false + } } } } diff --git a/examples/custompopups/CustomConfirmPopup.qml b/examples/custompopups/CustomConfirmPopup.qml index aff60b2..03ae28e 100644 --- a/examples/custompopups/CustomConfirmPopup.qml +++ b/examples/custompopups/CustomConfirmPopup.qml @@ -10,8 +10,9 @@ import Sailfish.WebView.Popups 1.0 ConfirmPopupInterface { id: popup - width: (parent.width/5)*4 - height: (parent.height/5)*4 + + width: (parent.width / 5) * 4 + height: (parent.height / 5) * 4 anchors.centerIn: parent acceptText: "Confirm" @@ -25,11 +26,13 @@ ConfirmPopupInterface { SilicaFlickable { id: flickable + anchors.fill: parent contentHeight: content.height + Theme.paddingLarge Column { id: content + width: parent.width - 2 * Theme.horizontalPageMargin anchors.centerIn: parent spacing: Theme.paddingLarge @@ -49,6 +52,7 @@ ConfirmPopupInterface { } TextSwitch { id: toggle + anchors.horizontalCenter: parent.horizontalCenter height: visible ? implicitHeight : 0 visible: popup.preventDialogsVisible @@ -58,13 +62,18 @@ ConfirmPopupInterface { Button { anchors.horizontalCenter: parent.horizontalCenter text: popup.acceptText - onClicked: { popup.accepted(); popup.visible = false } + onClicked: { + popup.accepted() + popup.visible = false + } } Button { - id: rejectBtn anchors.horizontalCenter: parent.horizontalCenter text: popup.cancelText - onClicked: { popup.rejected(); popup.visible = false } + onClicked: { + popup.rejected() + popup.visible = false + } } } } diff --git a/examples/custompopups/CustomLocationPopup.qml b/examples/custompopups/CustomLocationPopup.qml index 69fef4b..1180c26 100644 --- a/examples/custompopups/CustomLocationPopup.qml +++ b/examples/custompopups/CustomLocationPopup.qml @@ -10,8 +10,9 @@ import Sailfish.WebView.Popups 1.0 LocationPopupInterface { id: popup - width: (parent.width/5)*4 - height: (parent.height/5)*4 + + width: (parent.width / 5) * 4 + height: (parent.height / 5) * 4 anchors.centerIn: parent acceptText: "Allow" @@ -26,11 +27,13 @@ LocationPopupInterface { SilicaFlickable { id: flickable + anchors.fill: parent contentHeight: content.height + Theme.paddingLarge Column { id: content + width: parent.width - 2 * Theme.horizontalPageMargin anchors.centerIn: parent spacing: Theme.paddingLarge @@ -51,11 +54,13 @@ LocationPopupInterface { } TextSwitch { id: remember + anchors.horizontalCenter: parent.horizontalCenter text: "Remember for this site" } TextSwitch { id: toggle + anchors.horizontalCenter: parent.horizontalCenter height: visible ? implicitHeight : 0 visible: popup.preventDialogsVisible @@ -65,12 +70,18 @@ LocationPopupInterface { Button { anchors.horizontalCenter: parent.horizontalCenter text: popup.acceptText - onClicked: { popup.accepted(); popup.visible = false } + onClicked: { + popup.accepted() + popup.visible = false + } } Button { anchors.horizontalCenter: parent.horizontalCenter text: popup.cancelText - onClicked: { popup.rejected(); popup.visible = false } + onClicked: { + popup.rejected() + popup.visible = false + } } } } diff --git a/examples/custompopups/CustomPasswordManagerPopup.qml b/examples/custompopups/CustomPasswordManagerPopup.qml index 4ebcf69..e9da9e1 100644 --- a/examples/custompopups/CustomPasswordManagerPopup.qml +++ b/examples/custompopups/CustomPasswordManagerPopup.qml @@ -10,8 +10,9 @@ import Sailfish.WebView.Popups 1.0 PasswordManagerPopupInterface { id: popup - width: (parent.width/5)*4 - height: (parent.height/5)*4 + + width: (parent.width / 5) * 4 + height: (parent.height / 5) * 4 anchors.centerIn: parent property string displayUser: popup.formData["displayUser"] @@ -20,9 +21,9 @@ PasswordManagerPopupInterface { ? (displayUser.length ? ("Save password for user " + displayUser + " on " + displayHost + "?") : ("Save password on " + displayHost + "?")) : popup.notificationType == "password-change" - ? (displayUser.length ? ("Update password for user " + displayUser + "?") - : ("Update password?")) - : "Unknown password manager request!" + ? (displayUser.length ? ("Update password for user " + displayUser + "?") + : ("Update password?")) + : "Unknown password manager request!" Rectangle { anchors.fill: parent @@ -31,11 +32,13 @@ PasswordManagerPopupInterface { SilicaFlickable { id: flickable + anchors.fill: parent contentHeight: content.height + Theme.paddingLarge Column { id: content + width: parent.width - 2 * Theme.horizontalPageMargin anchors.centerIn: parent spacing: Theme.paddingLarge @@ -49,12 +52,18 @@ PasswordManagerPopupInterface { Button { anchors.horizontalCenter: parent.horizontalCenter text: "Save password" - onClicked: { popup.accepted(); popup.visible = false } + onClicked: { + popup.accepted() + popup.visible = false + } } Button { anchors.horizontalCenter: parent.horizontalCenter text: "Cancel" - onClicked: { popup.rejected(); popup.visible = false } + onClicked: { + popup.rejected() + popup.visible = false + } } } } diff --git a/examples/custompopups/CustomPromptPopup.qml b/examples/custompopups/CustomPromptPopup.qml index fb68e27..cd96c48 100644 --- a/examples/custompopups/CustomPromptPopup.qml +++ b/examples/custompopups/CustomPromptPopup.qml @@ -13,8 +13,8 @@ PromptPopupInterface { property bool canAccept: input.text.length > 0 - width: (parent.width/5)*4 - height: (parent.height/5)*4 + width: (parent.width / 5) * 4 + height: (parent.height / 5) * 4 anchors.centerIn: parent acceptText: "Ok" @@ -30,11 +30,13 @@ PromptPopupInterface { SilicaFlickable { id: flickable + anchors.fill: parent contentHeight: content.height + Theme.paddingLarge Column { id: content + width: parent.width - 2 * Theme.horizontalPageMargin anchors.centerIn: parent spacing: Theme.paddingLarge @@ -48,6 +50,7 @@ PromptPopupInterface { } TextField { id: input + width: parent.width focus: true label: text.length > 0 ? popup.text : "" @@ -56,10 +59,16 @@ PromptPopupInterface { inputMethodHints: Qt.ImhNoPredictiveText | Qt.ImhNoAutoUppercase EnterKey.enabled: text.length > 0 EnterKey.iconSource: "image://theme/icon-m-enter-accept" - EnterKey.onClicked: { if (popup.canAccept) { popup.accepted(); popup.visible = false } } + EnterKey.onClicked: { + if (popup.canAccept) { + popup.accepted() + popup.visible = false + } + } } TextSwitch { id: toggle + anchors.horizontalCenter: parent.horizontalCenter height: visible ? implicitHeight : 0 visible: popup.preventDialogsVisible @@ -67,16 +76,21 @@ PromptPopupInterface { text: "Don't show this again" } Button { - id: acceptBtn anchors.horizontalCenter: parent.horizontalCenter enabled: popup.canAccept text: popup.acceptText - onClicked: { popup.accepted(); popup.visible = false } + onClicked: { + popup.accepted() + popup.visible = false + } } Button { anchors.horizontalCenter: parent.horizontalCenter text: popup.cancelText - onClicked: { popup.rejected(); popup.visible = false } + onClicked: { + popup.rejected() + popup.visible = false + } } } } diff --git a/examples/custompopups/custompopups.pro b/examples/custompopups/custompopups.pro index 8e69bbc..87746ff 100644 --- a/examples/custompopups/custompopups.pro +++ b/examples/custompopups/custompopups.pro @@ -1,5 +1,5 @@ -TEMPLATE=app -TARGET=custompopups +TEMPLATE = app +TARGET = custompopups TARGETPATH = /usr/bin/ target.path = $$TARGETPATH QT += gui qml quick diff --git a/examples/custompopups/main.qml b/examples/custompopups/main.qml index 3090458..1febf1b 100644 --- a/examples/custompopups/main.qml +++ b/examples/custompopups/main.qml @@ -15,6 +15,9 @@ ApplicationWindow { initialPage: Component { Page { id: page + + allowedOrientations: Orientation.All + WebView { anchors.fill: parent active: true @@ -45,10 +48,12 @@ ApplicationWindow { Component { id: customLocationPermissionPopup + LocationPopupInterface { id: popup - width: (parent.width/5)*4 - height: (parent.height/5)*4 + + width: (parent.width / 5) * 4 + height: (parent.height / 5) * 4 anchors.centerIn: parent acceptText: "Allow" @@ -63,11 +68,13 @@ ApplicationWindow { SilicaFlickable { id: flickable + anchors.fill: parent contentHeight: content.height + Theme.paddingLarge Column { id: content + width: parent.width - 2 * Theme.horizontalPageMargin anchors.centerIn: parent spacing: Theme.paddingLarge @@ -87,11 +94,13 @@ ApplicationWindow { } TextSwitch { id: remember + anchors.horizontalCenter: parent.horizontalCenter text: "Remember for this site" } TextSwitch { id: toggle + anchors.horizontalCenter: parent.horizontalCenter height: visible ? implicitHeight : 0 visible: popup.preventDialogsVisible @@ -101,12 +110,18 @@ ApplicationWindow { Button { anchors.horizontalCenter: parent.horizontalCenter text: popup.acceptText - onClicked: { popup.accepted(); popup.visible = false } + onClicked: { + popup.accepted() + popup.visible = false + } } Button { anchors.horizontalCenter: parent.horizontalCenter text: popup.cancelText - onClicked: { popup.rejected(); popup.visible = false } + onClicked: { + popup.rejected() + popup.visible = false + } } } } diff --git a/examples/examples.pro b/examples/examples.pro index f206d22..c5365d4 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -1,3 +1,4 @@ -TEMPLATE=subdirs -SUBDIRS+=custompopups \ - webview-test-app +TEMPLATE = subdirs +SUBDIRS += \ + custompopups \ + webview-test-app diff --git a/examples/webview-test-app/SpinBox.qml b/examples/webview-test-app/SpinBox.qml index 49adfe1..fe490db 100644 --- a/examples/webview-test-app/SpinBox.qml +++ b/examples/webview-test-app/SpinBox.qml @@ -3,6 +3,7 @@ import Sailfish.Silica 1.0 Item { id: root + property alias label: textField.label property real minimumValue: -Infinity property real maximumValue: Infinity @@ -20,6 +21,7 @@ Item { IconButton { id: buttonMinus + width: height anchors.verticalCenter: textField.verticalCenter icon.source: "image://theme/icon-video-overlay-play" @@ -39,13 +41,13 @@ Item { EnterKey.iconSource: "image://theme/icon-m-enter-next" EnterKey.onClicked: { - focus = false; - root.value = text; + focus = false + root.value = text } onFocusChanged: { if (!focus) { - root.value = text; + root.value = text } } } diff --git a/examples/webview-test-app/main.qml b/examples/webview-test-app/main.qml index a519093..2beb236 100644 --- a/examples/webview-test-app/main.qml +++ b/examples/webview-test-app/main.qml @@ -15,7 +15,7 @@ ApplicationWindow { Page { id: page - anchors.fill: parent + allowedOrientations: Orientation.All function startTest() { var props = { @@ -114,6 +114,7 @@ ApplicationWindow { TextSwitch { id: viewportInfoSwitch + text: "Viewport info" } @@ -147,11 +148,10 @@ ApplicationWindow { property real reloadInterval property bool viewportInfo - property bool webViewLoading: false - property int webViewLoadProgress: 0 - - anchors.fill: parent + property bool webViewLoading + property int webViewLoadProgress + allowedOrientations: Orientation.All showNavigationIndicator: false backNavigation: false @@ -162,10 +162,7 @@ ApplicationWindow { Timer { id: webViewRecreationTimer - interval: (webViewLoader.active ? - destructionDelay : - creationDelay) * 1000.0 - + interval: (webViewLoader.active ? destructionDelay : creationDelay) * 1000.0 running: pageStack.currentPage === webViewPage && mode === 1 repeat: true @@ -247,32 +244,38 @@ ApplicationWindow { Column { id: contentColumn + y: Theme.paddingMedium x: Theme.paddingMedium width: parent.width - Theme.paddingMedium * 2 Label { - text: "Scrollable offset x: " + webViewLoader.item.scrollableOffset.x.toFixed(2) + ", y: " + webViewLoader.item.scrollableOffset.y.toFixed(2) + text: "Scrollable offset x: " + webViewLoader.item.scrollableOffset.x.toFixed(2) + + ", y: " + webViewLoader.item.scrollableOffset.y.toFixed(2) font.pixelSize: Theme.fontSizeSmall } Label { - text: "Scrollable width: " + webViewLoader.item.scrollableSize.width.toFixed(2) + ", height: " + webViewLoader.item.scrollableSize.height.toFixed(2) + text: "Scrollable width: " + webViewLoader.item.scrollableSize.width.toFixed(2) + + ", height: " + webViewLoader.item.scrollableSize.height.toFixed(2) font.pixelSize: Theme.fontSizeSmall } Label { - text: "Content width: " + webViewLoader.item.contentWidth.toFixed(2) + ", height: " + webViewLoader.item.contentHeight.toFixed(2) + text: "Content width: " + webViewLoader.item.contentWidth.toFixed(2) + + ", height: " + webViewLoader.item.contentHeight.toFixed(2) font.pixelSize: Theme.fontSizeSmall } Label { - text: "Content rect x: " + webViewLoader.item.contentRect.x.toFixed(2) + ", y: " + webViewLoader.item.contentRect.y.toFixed(2) + text: "Content rect x: " + webViewLoader.item.contentRect.x.toFixed(2) + + ", y: " + webViewLoader.item.contentRect.y.toFixed(2) font.pixelSize: Theme.fontSizeSmall } Label { - text: "Content rect width: " + webViewLoader.item.contentRect.width.toFixed(2) + ", height: " + webViewLoader.item.contentRect.height.toFixed(2) + text: "Content rect width: " + webViewLoader.item.contentRect.width.toFixed(2) + + ", height: " + webViewLoader.item.contentRect.height.toFixed(2) font.pixelSize: Theme.fontSizeSmall } @@ -323,7 +326,9 @@ ApplicationWindow { Label { anchors.centerIn: parent - text: !webViewLoader.active ? "destroyed" : (webViewPage.webViewLoading ? webViewPage.webViewLoadProgress + "%" : "loaded") + text: !webViewLoader.active ? "destroyed" + : (webViewPage.webViewLoading ? webViewPage.webViewLoadProgress + "%" + : "loaded") } } diff --git a/examples/webview-test-app/webview-test-app.pro b/examples/webview-test-app/webview-test-app.pro index 3e9c7fb..ac98d13 100644 --- a/examples/webview-test-app/webview-test-app.pro +++ b/examples/webview-test-app/webview-test-app.pro @@ -1,5 +1,5 @@ -TEMPLATE=app -TARGET=webview-test-app +TEMPLATE = app +TARGET = webview-test-app TARGETPATH = /usr/bin/ target.path = $$TARGETPATH QT += gui qml quick diff --git a/import/webview/WebView.qml b/import/webview/WebView.qml index ee94be2..c0d450b 100644 --- a/import/webview/WebView.qml +++ b/import/webview/WebView.qml @@ -142,9 +142,7 @@ RawWebView { opacity: canShowSelectionMarkers ? 1.0 : 0.0 contentWidth: Math.max(webview.contentWidth, webview.width) contentHeight: Math.max(webview.contentHeight, webview.height) - anchors { - fill: parent - } + anchors.fill: parent Behavior on opacity { FadeAnimator {} } } @@ -195,7 +193,6 @@ RawWebView { running: false duration: 200 easing.type: Easing.InOutQuad - to: 0 } } diff --git a/import/webview/rawwebview.cpp b/import/webview/rawwebview.cpp index 7d9480c..6ecfa5c 100644 --- a/import/webview/rawwebview.cpp +++ b/import/webview/rawwebview.cpp @@ -116,19 +116,6 @@ void RawWebView::setVirtualKeyboardMargin(qreal vkbMargin) setDynamicToolbarHeight(m_vkbMargin != 0 ? m_footerMargin : 0); emit virtualKeyboardMarginChanged(); - - QVariantMap map; - map.insert("imOpen", m_vkbMargin > 0); - map.insert("pixelRatio", SailfishOS::WebEngineSettings::instance()->pixelRatio()); - map.insert("bottomMargin", m_vkbMargin); - // These map to max css composition size. Item's geometry might update right after this - // meaning that height() + m_vkbMargin doesn't yet equal to available max space. - // Nevertheless, it is not a big deal if we loose a pixel or two from - // max composition size. - map.insert("screenWidth", viewportWidth()); - map.insert("screenHeight", viewportHeight()); - QVariant data(map); - sendAsyncMessage("embedui:vkbOpenCompositionMetrics", data); } }