Changeset View
Changeset View
Standalone View
Standalone View
src/touch/qml/MainPage.qml
Show All 17 Lines | |||||
18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | 18 | * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | 19 | * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT | ||
20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | 20 | * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, | ||
21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | 21 | * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | 22 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | ||
23 | * OTHER DEALINGS IN THE SOFTWARE. | 23 | * OTHER DEALINGS IN THE SOFTWARE. | ||
24 | */ | 24 | */ | ||
25 | 25 | | |||
26 | import QtQuick 2.4 | 26 | import QtQuick 2.12 | ||
27 | import QtQuick.Controls 2.0 as Controls | 27 | import QtQuick.Controls 2.0 as Controls | ||
28 | import QtQuick.Layouts 1.2 | 28 | import QtQuick.Layouts 1.2 | ||
29 | import org.kde.kirigami 2.4 as Kirigami | 29 | import org.kde.kirigami 2.4 as Kirigami | ||
30 | import Kookbook 1.0 | 30 | import Kookbook 1.0 | ||
31 | 31 | | |||
32 | Kirigami.ScrollablePage { | 32 | Kirigami.ScrollablePage { | ||
33 | property var scanner; | 33 | property var scanner; | ||
34 | 34 | | |||
35 | title: "Kookbook" | 35 | title: "Kookbook" | ||
36 | 36 | | |||
37 | | ||||
38 | ListView{ | 37 | ListView { | ||
39 | id: listView | 38 | id: listView | ||
40 | header: Controls.TextField { | 39 | header: Controls.TextField { | ||
41 | id: search | 40 | id: search | ||
42 | placeholderText: "Search..." | 41 | placeholderText: qsTr("Search...") | ||
43 | onTextChanged: scanner.filter = text | 42 | onTextChanged: scanner.filter = text | ||
44 | width: listView.width | 43 | width: listView.width | ||
45 | Rectangle { | 44 | leftPadding: Kirigami.Units.largeSpacing | ||
46 | anchors.fill: parent | 45 | | ||
47 | z: -1 | 46 | Item { | ||
48 | color: Kirigami.Theme.backgroundColor | 47 | anchors.right: parent.right | ||
49 | } | 48 | anchors.verticalCenter: parent.verticalCenter | ||
49 | height: parent.height | ||||
50 | width: height | ||||
51 | | ||||
50 | Kirigami.Icon{ | 52 | Kirigami.Icon { | ||
53 | anchors.centerIn: parent | ||||
51 | source: "edit-clear" | 54 | source: "edit-clear" | ||
52 | height: parent.height / 2 | 55 | height: parent.height / 2 | ||
53 | width: height | 56 | width: height | ||
54 | anchors.right: parent.right | 57 | smooth: true | ||
55 | anchors.verticalCenter: parent.verticalCenter | 58 | } | ||
56 | MouseArea { | 59 | TapHandler { | ||
57 | anchors.fill: parent | 60 | onTapped: { | ||
58 | onClicked: { | | |||
59 | search.text = "" | 61 | search.text = "" | ||
60 | } | 62 | } | ||
61 | } | 63 | } | ||
62 | } | 64 | } | ||
63 | z: 2 | 65 | z: 2 | ||
64 | } | 66 | } | ||
65 | headerPositioning: ListView.PullBackHeader | 67 | headerPositioning: ListView.PullBackHeader | ||
66 | 68 | | |||
67 | anchors.fill: parent | 69 | anchors.fill: parent | ||
68 | model: scanner.titleList | 70 | model: scanner.titleList | ||
69 | currentIndex: -1 | 71 | currentIndex: -1 | ||
72 | | ||||
70 | delegate: Kirigami.BasicListItem { | 73 | delegate: Kirigami.BasicListItem { | ||
71 | reserveSpaceForIcon: false | 74 | reserveSpaceForIcon: false | ||
72 | label: display | 75 | label: display | ||
73 | onClicked: { | 76 | onClicked: { | ||
74 | var item = root.pageStack.push(Qt.resolvedUrl("Recipe.qml")) | 77 | var item = root.pageStack.push(Qt.resolvedUrl("Recipe.qml")) | ||
75 | item.path = path; | 78 | item.path = path; | ||
76 | item.title = display | 79 | item.title = display | ||
77 | } | 80 | } | ||
78 | highlighted: focus && ListView.isCurrentItem | 81 | highlighted: focus && ListView.isCurrentItem | ||
79 | } | 82 | } | ||
80 | } | | |||
81 | 83 | | |||
84 | Controls.Label { | ||||
85 | anchors.fill: parent | ||||
86 | horizontalAlignment: Qt.AlignHCenter | ||||
87 | verticalAlignment: Qt.AlignVCenter | ||||
88 | visible: parent.count == 0 | ||||
89 | text: qsTr("Nothing to show") | ||||
90 | opacity: 0.6 | ||||
91 | } | ||||
92 | } | ||||
82 | } | 93 | } |