Warning, /education/kstars/kstars/kstarslite/qml/modules/BottomMenu.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2016 Artem Fedoskin <afedoskin3@gmail.com> 0002 // SPDX-License-Identifier: GPL-2.0-or-later 0003 0004 import QtQuick 2.7 0005 import QtQuick.Layouts 1.1 0006 import QtQuick.Controls 2.0 0007 import QtQuick.Controls.Material 2.0 0008 import QtQuick.Controls.Universal 2.0 0009 import QtQuick.Window 2.2 0010 0011 import TelescopeLiteEnums 1.0 0012 import "../constants" 1.0 0013 import "helpers" 0014 0015 ColumnLayout { 0016 id: bottomMenu 0017 objectName: "bottomMenu" 0018 property int padding: 10 0019 property bool telescope: false 0020 property int slewCount: 1 0021 property alias sliderValue: slider.value 0022 0023 property double openOffset: bottomMenu.height - bottomBar.background.radius //Hide bottom round corners 0024 property double closedOffset: arrowUp.height + padding 0025 property string prevState 0026 0027 property bool isWindowWidthSmall: window.width < menuGrid.maxWidth 0028 0029 //Hide on slew 0030 Connections { 0031 target: SkyMapLite 0032 onSlewingChanged: { 0033 if(SkyMapLite.slewing || skyMapLite.automaticMode) { 0034 prevState = state 0035 state = "hidden" 0036 } else { 0037 state = prevState 0038 } 0039 } 0040 } 0041 0042 state: "closed" 0043 property alias state : bottomMenu.state 0044 spacing: padding 0045 0046 x: (parent.width - width)/2 0047 0048 Layout.fillHeight: true 0049 0050 states: [ 0051 State { 0052 name: "open" 0053 PropertyChanges { 0054 target: bottomMenu 0055 y: parent.height - openOffset 0056 } 0057 }, 0058 State { 0059 name: "closed" 0060 PropertyChanges { 0061 target: bottomMenu 0062 y: parent.height - closedOffset 0063 } 0064 }, 0065 State { 0066 name: "hidden" 0067 PropertyChanges { 0068 target: bottomMenu 0069 y: parent.height 0070 } 0071 } 0072 ] 0073 0074 transitions: [ 0075 Transition { 0076 to: "open" 0077 PropertyAnimation { target: bottomMenu 0078 properties: "y"; duration: 300 } 0079 }, 0080 Transition { 0081 to: "closed" 0082 PropertyAnimation { target: bottomMenu 0083 properties: "y"; duration: 300 } 0084 }, 0085 Transition { 0086 to: "hidden" 0087 PropertyAnimation { target: bottomMenu 0088 properties: "y"; duration: 200 } 0089 } 0090 ] 0091 0092 Image { 0093 id: arrowUp 0094 anchors { 0095 horizontalCenter: parent.horizontalCenter 0096 } 0097 state: "open" 0098 source: "../images/arrow.png" 0099 rotation: { 0100 if(bottomMenu.state == "closed") 0101 return 0 0102 else if(bottomMenu.state == "open") 0103 return 180 0104 return rotation //If it state is "hidden" return current rotation 0105 } 0106 mirror: true // Make sure that arrows in both menus look symmetric 0107 0108 MouseArea { 0109 objectName: "arrowUpMouseArea" 0110 anchors.fill: parent 0111 onPressed: { 0112 bottomMenu.state = bottomMenu.state == "closed" ? "open" : "closed" 0113 } 0114 function manualPress() { 0115 onPressed(1); 0116 } 0117 } 0118 0119 Behavior on rotation { 0120 RotationAnimation { 0121 duration: 200; direction: RotationAnimation.Counterclockwise 0122 } 0123 } 0124 } 0125 0126 RowLayout { 0127 anchors { 0128 bottom: bottomBar.top 0129 horizontalCenter: parent.horizontalCenter 0130 } 0131 visible: bottomMenu.telescope 0132 0133 Slider { 0134 id: slider 0135 background: Rectangle { 0136 y: 11 0137 implicitWidth: 200 0138 implicitHeight: 4 0139 width: control.availableWidth 0140 height: implicitHeight 0141 radius: 2 0142 color: "#bdbebf" 0143 0144 Rectangle { 0145 width: control.visualPosition * parent.width 0146 height: parent.height 0147 color: "#21be2b" 0148 radius: 2 0149 } 0150 } 0151 value: 0 0152 stepSize: 1 0153 from: 1 0154 to: bottomMenu.slewCount-1 0155 wheelEnabled: false 0156 snapMode: Slider.SnapOnRelease 0157 0158 onValueChanged: { 0159 slewLabel.text = ClientManagerLite.getTelescope().getSlewRateLabels()[slider.value] 0160 } 0161 0162 onPressedChanged: { 0163 if (slider.pressed) return 0164 0165 ClientManagerLite.getTelescope().setSlewRate(slider.value) 0166 } 0167 } 0168 0169 Label { 0170 id: slewLabel 0171 color: "#d0d0d0" 0172 width: 100 0173 text: "" 0174 } 0175 } 0176 0177 Pane { 0178 id: bottomBar 0179 anchors.horizontalCenter: parent.horizontalCenter 0180 0181 background: Rectangle { 0182 id: menuRect 0183 color: Num.sysPalette.base 0184 border { 0185 width: 1 0186 color: Num.sysPalette.light 0187 } 0188 radius: 10 0189 } 0190 0191 GridLayout { 0192 id: menuGrid 0193 property double maxWidth: {width} // We make menuGrid smaller when window width is less than this value 0194 0195 onWidthChanged: { 0196 if(width > maxWidth) maxWidth = width 0197 } 0198 0199 anchors { 0200 bottom: parent.bottom 0201 bottomMargin: menuRect.radius/2 // Center vertically menuGrid in background rectangle 0202 } 0203 rows: isWindowWidthSmall ? 2 : 1 0204 flow: isWindowWidthSmall ? GridLayout.TopToBottom : GridLayout.LeftToRight 0205 0206 Layout.fillWidth: true 0207 0208 RowLayout { 0209 Layout.fillHeight: true 0210 Layout.fillWidth: true 0211 anchors { 0212 left: parent.left 0213 right: parent.right 0214 } 0215 0216 BottomMenuButton { 0217 id: telescopeLeft 0218 iconSrc: "../../images/telescope-left.png" 0219 visible: bottomMenu.telescope 0220 onPressed: { 0221 ClientManagerLite.getTelescope().moveWE(TelescopeNS.MOTION_WEST, TelescopeCommand.MOTION_START) 0222 } 0223 onClicked: { 0224 ClientManagerLite.getTelescope().moveWE(TelescopeNS.MOTION_WEST, TelescopeCommand.MOTION_STOP) 0225 } 0226 } 0227 0228 BottomMenuButton { 0229 id: telescopeDown1 0230 iconSrc: "../../images/telescope-down.png" 0231 visible: bottomMenu.telescope && menuGrid.rows == 1 0232 onPressed: { 0233 ClientManagerLite.getTelescope().moveNS(TelescopeNS.MOTION_SOUTH, TelescopeCommand.MOTION_START) 0234 } 0235 onClicked: { 0236 ClientManagerLite.getTelescope().moveNS(TelescopeNS.MOTION_SOUTH, TelescopeCommand.MOTION_STOP) 0237 } 0238 } 0239 0240 BottomMenuButton { 0241 id: goBackwards 0242 iconSrc: "../../images/media-skip-backward.png" 0243 onClicked: { 0244 KStarsLite.slotStepBackward() 0245 } 0246 } 0247 0248 BottomMenuButton { 0249 id: startTimer 0250 state: SimClock.isActive() ? "on" : "off" 0251 0252 states: [ 0253 State { 0254 name: "on" 0255 PropertyChanges { 0256 target: startTimer 0257 iconSrc: "../../images/media-playback-pause.png" 0258 } 0259 }, 0260 State { 0261 name: "off" 0262 PropertyChanges { 0263 target: startTimer 0264 iconSrc: "../../images/media-playback-start.png" 0265 } 0266 } 0267 ] 0268 0269 onClicked: { 0270 KStarsLite.slotToggleTimer() 0271 if(SimClock.isActive()) { 0272 startTimer.state = "on" 0273 } else { 0274 startTimer.state = "off" 0275 } 0276 } 0277 0278 Connections { 0279 target: window 0280 onIsSkyMapVisibleChanged: { 0281 if(!isSkyMapVisible && SimClock.isActive()) { 0282 KStarsLite.slotToggleTimer() 0283 startTimer.state = "off" 0284 } 0285 } 0286 } 0287 } 0288 0289 BottomMenuButton { 0290 iconSrc: "../../images/media-skip-forward.png" 0291 onClicked: { 0292 KStarsLite.slotStepForward() 0293 } 0294 } 0295 0296 RowLayout { 0297 anchors.right: parent.right 0298 0299 BottomMenuButton { 0300 onClicked: { 0301 stackView.push(timePage) 0302 } 0303 visible: isWindowWidthSmall 0304 0305 iconSrc: "../../images/appointment-new.png" 0306 } 0307 0308 Rectangle { 0309 id: separatorSearchSmall 0310 height: decreaseUnitLandscape.height*0.75 0311 color: Num.sysPalette.shadow 0312 width: 1 0313 visible: isWindowWidthSmall 0314 } 0315 0316 BottomMenuButton { 0317 onClicked: { 0318 stackView.push(findDialog) 0319 } 0320 visible: isWindowWidthSmall 0321 0322 iconSrc: "../../images/edit-find.png" 0323 } 0324 0325 BottomMenuButton { 0326 id: telescopeRight1 0327 iconSrc: "../../images/telescope-right.png" 0328 visible: bottomMenu.telescope && menuGrid.rows == 2 0329 onPressed: { 0330 ClientManagerLite.getTelescope().moveWE(TelescopeNS.MOTION_EAST, TelescopeCommand.MOTION_START) 0331 } 0332 onClicked: { 0333 ClientManagerLite.getTelescope().moveWE(TelescopeNS.MOTION_EAST, TelescopeCommand.MOTION_STOP) 0334 } 0335 } 0336 } 0337 } 0338 0339 RowLayout { 0340 id: secondRow 0341 Layout.fillHeight: true 0342 Layout.fillWidth: true 0343 0344 BottomMenuButton { 0345 id: telescopeDown2 0346 iconSrc: "../../images/telescope-down.png" 0347 visible: bottomMenu.telescope && menuGrid.rows == 2 0348 onPressed: { 0349 ClientManagerLite.getTelescope().moveNS(TelescopeNS.MOTION_SOUTH, TelescopeCommand.MOTION_START) 0350 } 0351 onClicked: { 0352 ClientManagerLite.getTelescope().moveNS(TelescopeNS.MOTION_SOUTH, TelescopeCommand.MOTION_STOP) 0353 } 0354 } 0355 0356 BottomMenuButton { 0357 onClicked: { 0358 timeSpinBox.decreaseTimeUnit() 0359 } 0360 visible: isWindowWidthSmall 0361 0362 iconSrc: "../../images/arrow-down.png" 0363 } 0364 0365 TimeSpinBox { 0366 id: timeSpinBox 0367 } 0368 0369 BottomMenuButton { 0370 id: increaseUnit 0371 onClicked: { 0372 timeSpinBox.increaseTimeUnit() 0373 } 0374 0375 iconSrc: "../../images/arrow-up.png" 0376 } 0377 0378 BottomMenuButton { 0379 id: decreaseUnitLandscape 0380 onClicked: { 0381 timeSpinBox.decreaseTimeUnit() 0382 } 0383 visible: !isWindowWidthSmall 0384 0385 iconSrc: "../../images/arrow-down.png" 0386 } 0387 0388 Rectangle { 0389 id: separator 0390 height: decreaseUnitLandscape.height*0.75 0391 color: Num.sysPalette.shadow 0392 width: 1 0393 visible: !isWindowWidthSmall 0394 } 0395 0396 BottomMenuButton { 0397 onClicked: { 0398 stackView.push(timePage) 0399 } 0400 visible: !isWindowWidthSmall 0401 0402 iconSrc: "../../images/appointment-new.png" 0403 } 0404 0405 Rectangle { 0406 id: separatorSearchLarge 0407 height: decreaseUnitLandscape.height*0.75 0408 color: Num.sysPalette.shadow 0409 width: 1 0410 visible: !isWindowWidthSmall 0411 } 0412 0413 BottomMenuButton { 0414 onClicked: { 0415 stackView.push(findDialog) 0416 } 0417 visible: !isWindowWidthSmall 0418 0419 iconSrc: "../../images/edit-find.png" 0420 } 0421 0422 BottomMenuButton { 0423 id: telescopeUp 0424 iconSrc: "../../images/telescope-up.png" 0425 visible: bottomMenu.telescope 0426 onPressed: { 0427 ClientManagerLite.getTelescope().moveNS(TelescopeNS.MOTION_NORTH, TelescopeCommand.MOTION_START) 0428 } 0429 onClicked: { 0430 ClientManagerLite.getTelescope().moveNS(TelescopeNS.MOTION_NORTH, TelescopeCommand.MOTION_STOP) 0431 } 0432 } 0433 0434 BottomMenuButton { 0435 id: telescopeRight2 0436 iconSrc: "../../images/telescope-right.png" 0437 visible: bottomMenu.telescope && menuGrid.rows == 1 0438 onPressed: { 0439 ClientManagerLite.getTelescope().moveWE(TelescopeNS.MOTION_EAST, TelescopeCommand.MOTION_START) 0440 } 0441 onClicked: { 0442 ClientManagerLite.getTelescope().moveWE(TelescopeNS.MOTION_EAST, TelescopeCommand.MOTION_STOP) 0443 } 0444 } 0445 } 0446 } 0447 } 0448 }