diff options
author | Yigit Akcay <yigit.akcay@qt.io> | 2023-03-23 16:12:06 +0100 |
---|---|---|
committer | Yigit Akcay <yigit.akcay@qt.io> | 2023-04-05 14:19:20 +0200 |
commit | fe9d72d931f40eafca97c1012c03e24561c973ff (patch) | |
tree | 08e36634557eadae962bb56b82137294a384879c /examples/webenginequick/recipebrowser/resources/qml | |
parent | 88ef502099d535823156c31e77251dd2a723ad1c (diff) |
Merge recipe browser, stylesheet browser and markdown editor examples
This patch merges the qtwebengine examples recipe browser, stylesheet
browser and markdown editor into one single example.
Pick-to: 6.5
Task-number: QTBUG-108751
Change-Id: I338707d7d3275b03bf2a2d7b65064ac91e562d7f
Reviewed-by: Michal Klocek <michal.klocek@qt.io>
Diffstat (limited to 'examples/webenginequick/recipebrowser/resources/qml')
-rw-r--r-- | examples/webenginequick/recipebrowser/resources/qml/RecipeList.qml | 125 | ||||
-rw-r--r-- | examples/webenginequick/recipebrowser/resources/qml/main.qml | 121 |
2 files changed, 0 insertions, 246 deletions
diff --git a/examples/webenginequick/recipebrowser/resources/qml/RecipeList.qml b/examples/webenginequick/recipebrowser/resources/qml/RecipeList.qml deleted file mode 100644 index bfaf59112..000000000 --- a/examples/webenginequick/recipebrowser/resources/qml/RecipeList.qml +++ /dev/null @@ -1,125 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -import QtQuick -import QtQuick.Controls -import QtQuick.Controls.Material -import QtQuick.Layouts - -FocusScope { - id: root - signal recipeSelected(url url) - - ColumnLayout { - spacing: 0 - anchors.fill: parent - - ToolBar { - id: headerBackground - Layout.fillWidth: true - implicitHeight: headerText.height + 20 - - Label { - id: headerText - width: parent.width - text: qsTr("Favorite recipes") - padding: 10 - anchors.centerIn: parent - } - } - - ListView { - id: listView - Layout.fillWidth: true - Layout.fillHeight: true - keyNavigationWraps: true - clip: true - focus: true - ScrollBar.vertical: ScrollBar { } - - model: recipeModel - - delegate: ItemDelegate { - width: parent.width - text: model.name - contentItem: Text { - text: parent.text - font: parent.font - color: parent.enabled ? parent.Material.primaryTextColor - : parent.Material.hintTextColor - elide: Text.ElideRight - horizontalAlignment: Text.AlignLeft - verticalAlignment: Text.AlignVCenter - wrapMode: Text.Wrap - } - - property url url: model.url - highlighted: ListView.isCurrentItem - - onClicked: { - listView.forceActiveFocus() - listView.currentIndex = model.index - } - } - - onCurrentItemChanged: { - root.recipeSelected(currentItem.url) - } - - ListModel { - id: recipeModel - - ListElement { - name: "Pizza Diavola" - url: "qrc:///pages/pizza.html" - } - ListElement { - name: "Steak" - url: "qrc:///pages/steak.html" - } - ListElement { - name: "Burger" - url: "qrc:///pages/burger.html" - } - ListElement { - name: "Soup" - url: "qrc:///pages/soup.html" - } - ListElement { - name: "Pasta" - url: "qrc:///pages/pasta.html" - } - ListElement { - name: "Grilled Skewers" - url: "qrc:///pages/skewers.html" - } - ListElement { - name: "Cupcakes" - url: "qrc:///pages/cupcakes.html" - } - } - - ToolTip { - id: help - implicitWidth: root.width - padding * 3 - y: root.y + root.height - delay: 1000 - timeout: 5000 - text: qsTr("Use keyboard, mouse, or touch controls to navigate through the\ - recipes.") - - contentItem: Text { - text: help.text - font: help.font - color: help.Material.primaryTextColor - wrapMode: Text.Wrap - } - } - } - } - - function showHelp() { - help.open() - } -} - diff --git a/examples/webenginequick/recipebrowser/resources/qml/main.qml b/examples/webenginequick/recipebrowser/resources/qml/main.qml deleted file mode 100644 index 7db43c871..000000000 --- a/examples/webenginequick/recipebrowser/resources/qml/main.qml +++ /dev/null @@ -1,121 +0,0 @@ -// Copyright (C) 2016 The Qt Company Ltd. -// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause - -import QtQml -import QtQuick -import QtQuick.Controls -import QtQuick.Controls.Material -import QtQuick.Layouts -import QtQuick.Window -import QtWebEngine - -ApplicationWindow { - id: appWindow - title: qsTr("Recipe Browser") - visible: true - - property int shorterDesktop: 768 - property int longerDesktop: 1024 - property int shorterMin: 360 - property int longerMin: 480 - property bool isPortrait: Screen.primaryOrientation === Qt.PortraitOrientation - width: { - if (isEmbedded) - return Screen.width - var potentialWidth = shorterDesktop - if (!isPortrait) - potentialWidth = longerDesktop - return potentialWidth > Screen.width ? Screen.width : potentialWidth - } - height: { - if (isEmbedded) - return Screen.height - var potentialHeight = longerDesktop - if (!isPortrait) - potentialHeight = shorterDesktop - return potentialHeight > Screen.height ? Screen.height : potentialHeight - } - minimumWidth: isPortrait ? shorterMin : longerMin - minimumHeight: isPortrait ? longerMin : shorterMin - - RowLayout { - id: container - anchors.fill: parent - spacing: 0 - - RecipeList { - id: recipeList - Layout.minimumWidth: 124 - Layout.preferredWidth: parent.width / 3 - Layout.maximumWidth: 300 - Layout.fillWidth: true - Layout.fillHeight: true - focus: true - activeFocusOnTab: true - onRecipeSelected: function(url) { - webView.showRecipe(url) - } - } - - WebEngineView { - id: webView - Layout.preferredWidth: 2 * parent.width / 3 - Layout.fillWidth: true - Layout.fillHeight: true - // Make sure focus is not taken by the web view, so user can continue navigating - // recipes with the keyboard. - settings.focusOnNavigationEnabled: false - - onContextMenuRequested: function(request) { - request.accepted = true - } - - property bool firstLoadComplete: false - onLoadingChanged: function(loadRequest) { - if (loadRequest.status === WebEngineView.LoadSucceededStatus - && !firstLoadComplete) { - // Debounce the showing of the web content, so images are more likely - // to have loaded completely. - showTimer.start() - } - } - - Timer { - id: showTimer - interval: 500 - repeat: false - onTriggered: { - webView.show(true) - webView.firstLoadComplete = true - recipeList.showHelp() - } - } - - Rectangle { - id: webViewPlaceholder - anchors.fill: parent - z: 1 - color: "white" - - BusyIndicator { - id: busy - anchors.centerIn: parent - } - } - - function showRecipe(url) { - webView.url = url - } - - function show(show) { - if (show === true) { - busy.running = false - webViewPlaceholder.visible = false - } else { - webViewPlaceholder.visible = true - busy.running = true - } - } - } - } -} |