Kstars

TopMenu.qml
1// SPDX-FileCopyrightText: 2016 Artem Fedoskin <afedoskin3@gmail.com>
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4import QtQuick 2.7
5import QtQuick.Layouts 1.1
6import QtQuick.Controls 2.0
7import QtQuick.Controls.Material 2.0
8import QtQuick.Controls.Universal 2.0
9
10import QtQuick.Window 2.2
11import "../constants" 1.0
12import "helpers"
13import KStarsLiteEnums 1.0
14
15ColumnLayout {
16 id: topMenu
17 objectName: "topMenu"
18 property int padding: 10
19 property double openOffset: -topBar.background.radius //Hide top round corners
20 property double closedOffset: -topBar.height // Hide top bar when closed
21 property string prevState
22
24 target: SkyMapLite
26 if(SkyMapLite.slewing || skyMapLite.automaticMode) {
27 prevState = state
28 state = "hidden"
29 } else {
30 state = prevState
31 }
32 }
33 }
34
35 state: "closed"
36 property alias state : topMenu.state
37 spacing: padding
38
39 x: (parent.width - width)/2
40
41 Layout.fillHeight: true
42 width: parent.width < menuFlow.childrenWidth ? parent.width : menuFlow.childrenWidth
43
44 states: [
45 State {
46 name: "open"
48 target: topMenu
49 y: openOffset
50 }
51 },
52 State {
53 name: "closed"
55 target: topMenu
56 y: closedOffset
57 }
58 },
59 State {
60 name: "hidden"
62 target: topMenu
63 y: -topMenu.height
64 }
65 }
66 ]
67
68 transitions: [
70 to: "open"
71 PropertyAnimation { target: topMenu
72 properties: "y"; duration: 300 }
73 },
75 to: "closed"
76 PropertyAnimation { target: topMenu
77 properties: "y"; duration: 300 }
78 },
80 to: "hidden"
81 PropertyAnimation { target: topMenu
82 properties: "y"; duration: 200 }
83 }
84 ]
85
86 Pane {
87 id: topBar
88 anchors.horizontalCenter: parent.horizontalCenter
89 implicitWidth: parent.width
90 Layout.fillHeight: true
91
92 background: Rectangle {
93 id: menuRect
94 color: Num.sysPalette.base
95 border {
96 width: 2
97 color: Num.sysPalette.light
98 }
99 radius: 10
100 }
101
102 Flow {
103 id: menuFlow
104 spacing: 5
105 width: parent.width
106 property double childrenWidth: 0
107
108 Component.onCompleted: {
109 if(Qt.platform.os == "android") {
110 //Automatic mode is available only for Android
111 var columnForTab = Qt.createQmlObject('import QtQuick 2.7
112 import "helpers"
113 TopMenuButton {
114 id: autoModeButton
115 iconSrc: "../../images/kstars_automode.png"
116 title: xi18n("Automatic mode")
117 titlePlural: false
118 visible: Qt.platform.os == "android"
119
120 toggled: SkyMapLite.automaticMode
121 onClicked: {
122 SkyMapLite.automaticMode = !SkyMapLite.automaticMode
123 }
124 }', menuFlow)
125 }
126
127 for(var i = 0; i < children.length; ++i) {
128 childrenWidth += children[i].width + spacing
129 }
130 childrenWidth += topBar.padding*2 //Account for topBar padding to have enough space for all elements
131 }
132
133 anchors {
134 top: parent.top
135 topMargin: menuRect.radius/2 // Center vertically menuGrid in background rectangle
136 }
137 Layout.fillHeight: true
138
139 TopMenuButton {
140 iconSrc: "../../images/kstars_stars.png"
141 title: xi18n("Stars")
142
143 toggled: KStarsLite.isToggled(ObjectsToToggle.Stars)
144 onClicked: {
145 KStarsLite.toggleObjects(ObjectsToToggle.Stars, toggled)
146 }
147 }
148 TopMenuButton {
149 iconSrc: "../../images/kstars_deepsky.png"
150 title: xi18n("DeepSky Objects")
151
152 toggled: KStarsLite.isToggled(ObjectsToToggle.DeepSky)
153 onClicked: {
154 KStarsLite.toggleObjects(ObjectsToToggle.DeepSky, toggled)
155 }
156 }
157 TopMenuButton {
158 iconSrc: "../../images/kstars_planets.png"
159 title: xi18n("Solar System")
160 titlePlural: false
161
162 toggled: KStarsLite.isToggled(ObjectsToToggle.Planets)
163 onClicked: {
164 KStarsLite.toggleObjects(ObjectsToToggle.Planets, toggled)
165 }
166 }
167 TopMenuButton {
168 iconSrc: "../../images/kstars_supernovae.png"
169 title: xi18n("Supernovae")
170
171 toggled: KStarsLite.isToggled(ObjectsToToggle.Supernovae)
172 onClicked: {
173 KStarsLite.toggleObjects(ObjectsToToggle.Supernovae, toggled)
174 }
175 }
176 TopMenuButton {
177 iconSrc: "../../images/kstars_satellites.png"
178 title: xi18n("Satellites")
179
180 toggled: KStarsLite.isToggled(ObjectsToToggle.Satellites)
181 onClicked: {
182 KStarsLite.toggleObjects(ObjectsToToggle.Satellites, toggled)
183 }
184 }
185 TopMenuButton {
186 iconSrc: "../../images/kstars_clines.png"
187 title: xi18n("Constellation Lines")
188
189 toggled: KStarsLite.isToggled(ObjectsToToggle.CLines)
190 onClicked: {
191 KStarsLite.toggleObjects(ObjectsToToggle.CLines, toggled)
192 }
193 }
194 TopMenuButton {
195 iconSrc: "../../images/kstars_cnames.png"
196 title: xi18n("Constellation Names")
197
198 toggled: KStarsLite.isToggled(ObjectsToToggle.CNames)
199 onClicked: {
200 KStarsLite.toggleObjects(ObjectsToToggle.CNames, toggled)
201 }
202 }
203
204 TopMenuButton {
205 iconSrc: "../../images/kstars_constellationart.png"
206 title: xi18n("Constellation Art")
207 titlePlural: false
208
209 toggled: KStarsLite.isToggled(ObjectsToToggle.ConstellationArt)
210 onClicked: {
211 KStarsLite.toggleObjects(ObjectsToToggle.ConstellationArt, toggled)
212 }
213 }
214
215 TopMenuButton {
216 iconSrc: "../../images/kstars_cbound.png"
217 title: xi18n("Constellation Bounds")
218
219 toggled: KStarsLite.isToggled(ObjectsToToggle.CBounds)
220 onClicked: {
221 KStarsLite.toggleObjects(ObjectsToToggle.CBounds, toggled)
222 }
223 }
224 TopMenuButton {
225 iconSrc: "../../images/kstars_mw.png"
226 title: xi18n("Milky Way")
227 titlePlural: false
228
229 toggled: KStarsLite.isToggled(ObjectsToToggle.MilkyWay)
230 onClicked: {
231 KStarsLite.toggleObjects(ObjectsToToggle.MilkyWay, toggled)
232 }
233 }
234 TopMenuButton {
235 iconSrc: "../../images/kstars_grid.png"
236 title: xi18n("Equatorial Grid")
237 titlePlural: false
238
239 toggled: KStarsLite.isToggled(ObjectsToToggle.EquatorialGrid)
240 onClicked: {
241 KStarsLite.toggleObjects(ObjectsToToggle.EquatorialGrid, toggled)
242 }
243 }
244 TopMenuButton {
245 iconSrc: "../../images/kstars_hgrid.png"
246 title: xi18n("Horizontal Grid")
247 titlePlural: false
248
249 toggled: KStarsLite.isToggled(ObjectsToToggle.HorizontalGrid)
250 onClicked: {
251 KStarsLite.toggleObjects(ObjectsToToggle.HorizontalGrid, toggled)
252 }
253 }
254 TopMenuButton {
255 iconSrc: "../../images/kstars_horizon.png"
256 title: xi18n("Horizon")
257 titlePlural: false
258
259 toggled: KStarsLite.isToggled(ObjectsToToggle.Ground)
260 onClicked: {
261 KStarsLite.toggleObjects(ObjectsToToggle.Ground, toggled)
262 }
263 }
264 }
265 }
266
267 Image {
268 id: arrowDown
269 anchors {
270 horizontalCenter: parent.horizontalCenter
271 }
272 state: "open"
273 source: "../images/arrow.png"
274 rotation: {
275 if(topMenu.state == "closed")
276 return 180
277 else if(topMenu.state == "open")
278 return 0
279 return rotation //If it state is "hidden" return current rotation
280 }
281
282 MouseArea {
283 objectName: "arrowDownMouseArea"
284 anchors.fill: parent
285 onPressed: {
286 topMenu.state = topMenu.state == "closed" ? "open" : "closed"
287 }
288 function manualPress() {
289 onPressed(1);
290 }
291 }
292
293 Behavior on rotation {
295 duration: 200; direction: RotationAnimation.Counterclockwise
296 }
297 }
298 }
299}
This class loads QML files and connects SkyMapLite and KStarsData Unlike KStars class it is not a mai...
Definition kstarslite.h:47
Class that handles drawing of MilkyWay (both filled and non-filled)
Definition milkyway.h:25
This is the main item that displays all SkyItems.
Definition skymaplite.h:59
bool slewing
true if SkyMapLite is being panned
Definition skymaplite.h:70
Q_INVOKABLE void toggleObjects(ObjectsToToggle toToggle, bool toggle)
toggles on/off objects of group toToggle
QString xi18n(const char *text, const TYPE &arg...)
KGuiItem properties()
QString name(StandardShortcut id)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:19:03 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.