Debian Codegraph @

src/GUI/qml/AircraftRatingsPanel.qml

raw
1 // SPDX-FileCopyrightText: 2018 James Turner
2 // SPDX-License-Identifier: GPL-2.0-or-later
3
4 import QtQuick 2.2
5 import FlightGear.Launcher 1.0 as FG
6 import FlightGear 1.0
7
8 ListHeaderBox
9 {
10 id: root
11 signal clearSelection();
12
13 GettingStartedScope.controller: tips.controller
14
15 contents: [
16
17 ToggleSwitch {
18 id: doFilterCheck
19 checked: _launcher.browseAircraftModel.ratingsFilterEnabled
20
21 onCheckedChanged: {
22 _launcher.browseAircraftModel.ratingsFilterEnabled = checked
23 _launcher.saveUISetting("enable-ratings-filter", checked);
24 }
25
26 label: qsTr("Filter using ratings")
27 anchors.verticalCenter: parent.verticalCenter
28 },
29
30 StyledText {
31 anchors {
32 verticalCenter: parent.verticalCenter
33 leftMargin: Style.margin
34 left: doFilterCheck.right
35 right: adjustRatingsText.left
36 }
37 text: _launcher.browseAircraftModel.summaryText
38 },
39
40 ClickableText {
41 id: adjustRatingsText
42 anchors.right: parent.right
43 anchors.rightMargin: Style.margin
44 text: qsTr("Adjust minimum ratings")
45 anchors.verticalCenter: parent.verticalCenter
46 onClicked: {
47 // clear selection so we don't jump to the selected item
48 // each time the proxy model changes.
49 root.clearSelection();
50 editRatingsPanel.visible = true
51
52 }
53
54 Component.onCompleted: {
55 editTip.showOneShot()
56 }
57
58 GettingStartedTip {
59 id: editTip
60 tipId: "editRatingsTip"
61
62 anchors {
63 horizontalCenter: parent.horizontalCenter
64 top: parent.bottom
65 }
66 standalone: true
67 arrow: GettingStartedTip.TopRight
68 text: qsTr("Click here to change which aircraft are shown or hidden based on their ratings")
69 }
70 },
71
72 // mouse are behind panel to consume clicks
73 MouseArea {
74 width: 10000 // deliberately huge values here
75 height: 10000
76 anchors.horizontalCenter: parent.horizontalCenter
77 anchors.top: parent.top
78 visible: editRatingsPanel.visible
79
80 onClicked: {
81 editRatingsPanel.visible = false
82 }
83 },
84
85 Rectangle {
86 id: editRatingsPanel
87 visible: false
88 width: parent.width
89 y: parent.height - 1
90 height: childrenRect.height + (Style.margin * 2)
91
92 border.width: 1
93 border.color: "#9f9f9f"
94
95 Column {
96 y: Style.margin
97 spacing: (Style.margin * 2)
98
99 StyledText {
100 text: qsTr("Aircraft are rated by the community based on four criteria, on a scale from " +
101 "one to five. The ratings are designed to help make an informed guess how "+
102 "complete and functional an aircraft is.")
103 width: editRatingsPanel.width - Style.strutSize * 2
104 wrapMode: Text.WordWrap
105 anchors.horizontalCenter: parent.horizontalCenter
106 }
107
108 RatingSlider {
109 label: qsTr("Minimum flight-model (FDM) rating")
110 ratings: _launcher.browseAircraftModel.ratings
111 ratingIndex: 0
112 }
113
114 RatingSlider {
115 label: qsTr("Minimum systems rating")
116 ratings: _launcher.browseAircraftModel.ratings
117 ratingIndex: 1
118 }
119
120 RatingSlider {
121 label: qsTr("Minimum cockpit visual rating")
122 ratings: _launcher.browseAircraftModel.ratings
123 ratingIndex: 2
124 }
125
126 RatingSlider {
127 label: qsTr("Minimum external visual model rating")
128 ratings: _launcher.browseAircraftModel.ratings
129 ratingIndex: 3
130 }
131 }
132 }
133 ]
134
135 }