Kstars

BottomMenu.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
9import QtQuick.Window 2.2
10
11import TelescopeLiteEnums 1.0
12import "../constants" 1.0
13import "helpers"
14
15ColumnLayout {
16 id: bottomMenu
17 objectName: "bottomMenu"
18 property int padding: 10
19 property bool telescope: false
20 property int slewCount: 1
21 property alias sliderValue: slider.value
22
23 property double openOffset: bottomMenu.height - bottomBar.background.radius //Hide bottom round corners
24 property double closedOffset: arrowUp.height + padding
25 property string prevState
26
27 property bool isWindowWidthSmall: window.width < menuGrid.maxWidth
28
29 //Hide on slew
31 target: SkyMapLite
33 if(SkyMapLite.slewing || skyMapLite.automaticMode) {
34 prevState = state
35 state = "hidden"
36 } else {
37 state = prevState
38 }
39 }
40 }
41
42 state: "closed"
43 property alias state : bottomMenu.state
44 spacing: padding
45
46 x: (parent.width - width)/2
47
48 Layout.fillHeight: true
49
50 states: [
51 State {
52 name: "open"
54 target: bottomMenu
55 y: parent.height - openOffset
56 }
57 },
58 State {
59 name: "closed"
61 target: bottomMenu
62 y: parent.height - closedOffset
63 }
64 },
65 State {
66 name: "hidden"
68 target: bottomMenu
69 y: parent.height
70 }
71 }
72 ]
73
74 transitions: [
76 to: "open"
77 PropertyAnimation { target: bottomMenu
78 properties: "y"; duration: 300 }
79 },
81 to: "closed"
82 PropertyAnimation { target: bottomMenu
83 properties: "y"; duration: 300 }
84 },
86 to: "hidden"
87 PropertyAnimation { target: bottomMenu
88 properties: "y"; duration: 200 }
89 }
90 ]
91
92 Image {
93 id: arrowUp
94 anchors {
95 horizontalCenter: parent.horizontalCenter
96 }
97 state: "open"
98 source: "../images/arrow.png"
99 rotation: {
100 if(bottomMenu.state == "closed")
101 return 0
102 else if(bottomMenu.state == "open")
103 return 180
104 return rotation //If it state is "hidden" return current rotation
105 }
106 mirror: true // Make sure that arrows in both menus look symmetric
107
108 MouseArea {
109 objectName: "arrowUpMouseArea"
110 anchors.fill: parent
111 onPressed: {
112 bottomMenu.state = bottomMenu.state == "closed" ? "open" : "closed"
113 }
114 function manualPress() {
115 onPressed(1);
116 }
117 }
118
119 Behavior on rotation {
121 duration: 200; direction: RotationAnimation.Counterclockwise
122 }
123 }
124 }
125
126 RowLayout {
127 anchors {
128 bottom: bottomBar.top
129 horizontalCenter: parent.horizontalCenter
130 }
131 visible: bottomMenu.telescope
132
133 Slider {
134 id: slider
135 background: Rectangle {
136 y: 11
137 implicitWidth: 200
138 implicitHeight: 4
139 width: control.availableWidth
140 height: implicitHeight
141 radius: 2
142 color: "#bdbebf"
143
144 Rectangle {
145 width: control.visualPosition * parent.width
146 height: parent.height
147 color: "#21be2b"
148 radius: 2
149 }
150 }
151 value: 0
152 stepSize: 1
153 from: 1
154 to: bottomMenu.slewCount-1
155 wheelEnabled: false
156 snapMode: Slider.SnapOnRelease
157
158 onValueChanged: {
159 slewLabel.text = ClientManagerLite.getTelescope().getSlewRateLabels()[slider.value]
160 }
161
162 onPressedChanged: {
163 if (slider.pressed) return
164
165 ClientManagerLite.getTelescope().setSlewRate(slider.value)
166 }
167 }
168
169 Label {
170 id: slewLabel
171 color: "#d0d0d0"
172 width: 100
173 text: ""
174 }
175 }
176
177 Pane {
178 id: bottomBar
179 anchors.horizontalCenter: parent.horizontalCenter
180
181 background: Rectangle {
182 id: menuRect
183 color: Num.sysPalette.base
184 border {
185 width: 1
186 color: Num.sysPalette.light
187 }
188 radius: 10
189 }
190
191 GridLayout {
192 id: menuGrid
193 property double maxWidth: {width} // We make menuGrid smaller when window width is less than this value
194
196 if(width > maxWidth) maxWidth = width
197 }
198
199 anchors {
200 bottom: parent.bottom
201 bottomMargin: menuRect.radius/2 // Center vertically menuGrid in background rectangle
202 }
203 rows: isWindowWidthSmall ? 2 : 1
204 flow: isWindowWidthSmall ? GridLayout.TopToBottom : GridLayout.LeftToRight
205
206 Layout.fillWidth: true
207
208 RowLayout {
209 Layout.fillHeight: true
210 Layout.fillWidth: true
211 anchors {
212 left: parent.left
213 right: parent.right
214 }
215
216 BottomMenuButton {
217 id: telescopeLeft
218 iconSrc: "../../images/telescope-left.png"
219 visible: bottomMenu.telescope
220 onPressed: {
221 ClientManagerLite.getTelescope().moveWE(TelescopeNS.MOTION_WEST, TelescopeCommand.MOTION_START)
222 }
223 onClicked: {
224 ClientManagerLite.getTelescope().moveWE(TelescopeNS.MOTION_WEST, TelescopeCommand.MOTION_STOP)
225 }
226 }
227
228 BottomMenuButton {
230 iconSrc: "../../images/telescope-down.png"
231 visible: bottomMenu.telescope && menuGrid.rows == 1
232 onPressed: {
233 ClientManagerLite.getTelescope().moveNS(TelescopeNS.MOTION_SOUTH, TelescopeCommand.MOTION_START)
234 }
235 onClicked: {
236 ClientManagerLite.getTelescope().moveNS(TelescopeNS.MOTION_SOUTH, TelescopeCommand.MOTION_STOP)
237 }
238 }
239
240 BottomMenuButton {
241 id: goBackwards
242 iconSrc: "../../images/media-skip-backward.png"
243 onClicked: {
245 }
246 }
247
248 BottomMenuButton {
249 id: startTimer
250 state: SimClock.isActive() ? "on" : "off"
251
252 states: [
253 State {
254 name: "on"
256 target: startTimer
257 iconSrc: "../../images/media-playback-pause.png"
258 }
259 },
260 State {
261 name: "off"
263 target: startTimer
264 iconSrc: "../../images/media-playback-start.png"
265 }
266 }
267 ]
268
269 onClicked: {
271 if(SimClock.isActive()) {
272 startTimer.state = "on"
273 } else {
274 startTimer.state = "off"
275 }
276 }
277
279 target: window
281 if(!isSkyMapVisible && SimClock.isActive()) {
283 startTimer.state = "off"
284 }
285 }
286 }
287 }
288
289 BottomMenuButton {
290 iconSrc: "../../images/media-skip-forward.png"
291 onClicked: {
293 }
294 }
295
296 RowLayout {
297 anchors.right: parent.right
298
299 BottomMenuButton {
300 onClicked: {
301 stackView.push(timePage)
302 }
303 visible: isWindowWidthSmall
304
305 iconSrc: "../../images/appointment-new.png"
306 }
307
308 Rectangle {
310 height: decreaseUnitLandscape.height*0.75
311 color: Num.sysPalette.shadow
312 width: 1
313 visible: isWindowWidthSmall
314 }
315
316 BottomMenuButton {
317 onClicked: {
318 stackView.push(findDialog)
319 }
320 visible: isWindowWidthSmall
321
322 iconSrc: "../../images/edit-find.png"
323 }
324
325 BottomMenuButton {
327 iconSrc: "../../images/telescope-right.png"
328 visible: bottomMenu.telescope && menuGrid.rows == 2
329 onPressed: {
330 ClientManagerLite.getTelescope().moveWE(TelescopeNS.MOTION_EAST, TelescopeCommand.MOTION_START)
331 }
332 onClicked: {
333 ClientManagerLite.getTelescope().moveWE(TelescopeNS.MOTION_EAST, TelescopeCommand.MOTION_STOP)
334 }
335 }
336 }
337 }
338
339 RowLayout {
340 id: secondRow
341 Layout.fillHeight: true
342 Layout.fillWidth: true
343
344 BottomMenuButton {
346 iconSrc: "../../images/telescope-down.png"
347 visible: bottomMenu.telescope && menuGrid.rows == 2
348 onPressed: {
349 ClientManagerLite.getTelescope().moveNS(TelescopeNS.MOTION_SOUTH, TelescopeCommand.MOTION_START)
350 }
351 onClicked: {
352 ClientManagerLite.getTelescope().moveNS(TelescopeNS.MOTION_SOUTH, TelescopeCommand.MOTION_STOP)
353 }
354 }
355
356 BottomMenuButton {
357 onClicked: {
358 timeSpinBox.decreaseTimeUnit()
359 }
360 visible: isWindowWidthSmall
361
362 iconSrc: "../../images/arrow-down.png"
363 }
364
366 id: timeSpinBox
367 }
368
369 BottomMenuButton {
370 id: increaseUnit
371 onClicked: {
372 timeSpinBox.increaseTimeUnit()
373 }
374
375 iconSrc: "../../images/arrow-up.png"
376 }
377
378 BottomMenuButton {
380 onClicked: {
381 timeSpinBox.decreaseTimeUnit()
382 }
383 visible: !isWindowWidthSmall
384
385 iconSrc: "../../images/arrow-down.png"
386 }
387
388 Rectangle {
389 id: separator
390 height: decreaseUnitLandscape.height*0.75
391 color: Num.sysPalette.shadow
392 width: 1
393 visible: !isWindowWidthSmall
394 }
395
396 BottomMenuButton {
397 onClicked: {
398 stackView.push(timePage)
399 }
400 visible: !isWindowWidthSmall
401
402 iconSrc: "../../images/appointment-new.png"
403 }
404
405 Rectangle {
407 height: decreaseUnitLandscape.height*0.75
408 color: Num.sysPalette.shadow
409 width: 1
410 visible: !isWindowWidthSmall
411 }
412
413 BottomMenuButton {
414 onClicked: {
415 stackView.push(findDialog)
416 }
417 visible: !isWindowWidthSmall
418
419 iconSrc: "../../images/edit-find.png"
420 }
421
422 BottomMenuButton {
423 id: telescopeUp
424 iconSrc: "../../images/telescope-up.png"
425 visible: bottomMenu.telescope
426 onPressed: {
427 ClientManagerLite.getTelescope().moveNS(TelescopeNS.MOTION_NORTH, TelescopeCommand.MOTION_START)
428 }
429 onClicked: {
430 ClientManagerLite.getTelescope().moveNS(TelescopeNS.MOTION_NORTH, TelescopeCommand.MOTION_STOP)
431 }
432 }
433
434 BottomMenuButton {
436 iconSrc: "../../images/telescope-right.png"
437 visible: bottomMenu.telescope && menuGrid.rows == 1
438 onPressed: {
439 ClientManagerLite.getTelescope().moveWE(TelescopeNS.MOTION_EAST, TelescopeCommand.MOTION_START)
440 }
441 onClicked: {
442 ClientManagerLite.getTelescope().moveWE(TelescopeNS.MOTION_EAST, TelescopeCommand.MOTION_STOP)
443 }
444 }
445 }
446 }
447 }
448}
This class loads QML files and connects SkyMapLite and KStarsData Unlike KStars class it is not a mai...
Definition kstarslite.h:47
void slotToggleTimer()
action slot: toggle whether kstars clock is running or not
void slotStepBackward()
action slot: advance one step backward in time
void slotStepForward()
action slot: advance one step forward in time
kstars simulation clock
Definition simclock.h:23
Q_INVOKABLE bool isActive()
Whether the clock is active or not is a bit complicated by the introduction of "manual mode".
Definition simclock.cpp:96
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
Custom spinbox to handle selection of timestep values with variable units.
KGUIADDONS_EXPORT QWindow * window(QObject *job)
QString name(StandardAction id)
KGuiItem properties()
QTextStream & left(QTextStream &stream)
QTextStream & right(QTextStream &stream)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri May 24 2024 11:49:22 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.