Warning, /education/kstars/kstars/kstarslite/qml/main.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 0006 import QtQuick.Controls 2.0 0007 import QtQuick.Controls.Material 2.0 0008 0009 import QtQuick.Window 2.2 as Window 0010 import QtQuick.Layouts 1.1 0011 0012 import "modules" 0013 import "modules/helpers" 0014 import "modules/popups" 0015 import "modules/menus" 0016 import "modules/tutorial" 0017 0018 0019 import "dialogs" 0020 import "dialogs/menus" 0021 import "dialogs/helpers" 0022 0023 import "constants" 1.0 0024 import "indi" 0025 0026 ApplicationWindow { 0027 id: window 0028 objectName: "window" 0029 width: Window.Screen.desktopAvailableWidth 0030 height: Window.Screen.desktopAvailableHeight 0031 visible: true 0032 0033 //Application properties 0034 property bool isLoaded: false 0035 property bool isPortrait: width < height ? true: false 0036 property bool isSkyMapVisible: stackView.currentItem == initPage 0037 signal loaded(); 0038 0039 onIsLoadedChanged: { 0040 if(isLoaded) { 0041 loaded() 0042 if(KStarsLite.runTutorial) tutorialPopup.open() 0043 } 0044 } 0045 0046 header: ToolBar { 0047 id: toolBar 0048 Material.foreground: "white" 0049 height: stackView.currentItem != initPage ? backButton.height : 0 0050 visible: stackView.currentItem != initPage 0051 0052 /*background: Rectangle { 0053 anchors.fill: parent 0054 color: Num.sysPalette.dark 0055 }*/ 0056 0057 Behavior on height { 0058 NumberAnimation { 0059 duration: 200 0060 easing.type: Easing.InOutQuad 0061 } 0062 } 0063 0064 Row { 0065 id: toolRow 0066 spacing: 20 0067 height: parent.height 0068 width: parent.width 0069 0070 ToolButton { 0071 id: backButton 0072 contentItem: Image { 0073 fillMode: Image.Pad 0074 horizontalAlignment: Image.AlignHCenter 0075 verticalAlignment: Image.AlignVCenter 0076 source: "images/back.png" 0077 } 0078 onClicked: { 0079 if(stackView.depth != 1) stackView.pop() 0080 } 0081 } 0082 0083 KSLabel { 0084 id: titleLabel 0085 text: stackView.currentItem.title 0086 0087 font.pixelSize: 20 0088 width: parent.width - backButton.width - toolRow.spacing //To allow ellision of the text 0089 0090 elide: Label.ElideRight 0091 wrapMode: Label.Wrap 0092 maximumLineCount: 1 0093 0094 anchors.verticalCenter: parent.verticalCenter 0095 } 0096 } 0097 } 0098 0099 Splash { 0100 z:1 0101 anchors.fill:parent 0102 onTimeout: { 0103 isLoaded = true 0104 } 0105 } 0106 0107 StackView { 0108 visible: isLoaded 0109 id: stackView 0110 anchors.fill: parent 0111 initialItem: initPage 0112 } 0113 0114 Units { 0115 id: units 0116 } 0117 0118 //Dialogs 0119 FindDialog { 0120 id: findDialog 0121 } 0122 0123 //Details 0124 DetailsDialog { 0125 id: detailsDialog 0126 } 0127 0128 DetailsAddLink { 0129 id: detailsAddLink 0130 } 0131 0132 DetailsLinkMenu { 0133 id: detailsLinkMenu 0134 x: (window.width - width)/2 0135 y: (window.height - height)/2 0136 } 0137 0138 //Location 0139 LocationDialog { 0140 id: locationDialog 0141 } 0142 0143 LocationEdit { 0144 id: locationEdit 0145 } 0146 0147 LocationLoading { 0148 id: locationLoading 0149 } 0150 0151 AboutDialog { 0152 id: aboutDialog 0153 } 0154 0155 //Pages 0156 INDIControlPanel { 0157 id: indiControlPanel 0158 } 0159 0160 Page { 0161 id: initPage 0162 title: xi18n("Sky Map") 0163 padding: 0 0164 0165 Rectangle { 0166 anchors.fill: parent 0167 color: "black" //Color scheme 0168 } 0169 } 0170 0171 SkyMapLiteWrapper { 0172 /*The reason SkyMapLite is a not a child of initPage is that it can't handle properly change of 0173 opacity. Each time we go from / to initPage this component is made invisible / visible and 0174 skyMapLiteWrapper is anchored to fill null / parent*/ 0175 id: skyMapLite 0176 anchors.fill: parent 0177 } 0178 0179 //Popups 0180 TimePage { 0181 id: timePage 0182 } 0183 0184 ColorSchemePopup { 0185 id: colorSchemePopup 0186 x: (window.width - width)/2 0187 y: (window.height - height)/2 0188 } 0189 0190 ProjectionsPopup { 0191 id: projPopup 0192 x: (window.width - width)/2 0193 y: (window.height - height)/2 0194 } 0195 0196 FOVPopup { 0197 id: fovPopup 0198 x: (window.width - width)/2 0199 y: (window.height - height)/2 0200 } 0201 0202 TutorialPopup { 0203 id: tutorialPopup 0204 x: (window.width - width)/2 0205 y: (window.height - height)/2 0206 } 0207 0208 TutorialExitPopup { 0209 id: tutorialExitPopup 0210 x: (window.width - width)/2 0211 y: (window.height - height)/2 0212 } 0213 0214 //Menus 0215 ContextMenu { 0216 id: contextMenu 0217 x: (window.width - width)/2 0218 y: (window.height - height)/2 0219 } 0220 0221 LocationsGeoMenu { 0222 id: locationsGeoMenu 0223 x: (window.width - width)/2 0224 y: (window.height - height)/2 0225 } 0226 0227 Drawer { 0228 id: globalDrawer 0229 objectName: "globalDrawer" 0230 width: Math.min(window.width, window.height) / 4 * 2 0231 height: window.height 0232 //Disable drawer while loading 0233 dragMargin: isLoaded ? Qt.styleHints.startDragDistance : -Qt.styleHints.startDragDistance 0234 background: Rectangle { 0235 anchors.fill: parent 0236 color: Num.sysPalette.base 0237 } 0238 0239 onOpened: { 0240 contextDrawer.close() 0241 } 0242 0243 Image { 0244 id: drawerBanner 0245 source: "images/kstars.png" 0246 fillMode: Image.PreserveAspectFit 0247 0248 anchors { 0249 left: parent.left 0250 top: parent.top 0251 right: parent.right 0252 } 0253 } 0254 0255 ListView { 0256 clip: true 0257 id: pagesList 0258 anchors { 0259 left: parent.left 0260 top: drawerBanner.bottom 0261 right: parent.right 0262 bottom: parent.bottom 0263 } 0264 0265 delegate: ItemDelegate { 0266 id: globalDrawerControl 0267 Rectangle { 0268 anchors { 0269 horizontalCenter: parent.horizontalCenter 0270 bottom: parent.bottom 0271 } 0272 width: parent.width - 10 0273 color: "#E8E8E8" 0274 height: 1 0275 } 0276 0277 contentItem: KSText { 0278 rightPadding: globalDrawerControl.spacing 0279 text: globalDrawerControl.text 0280 font: globalDrawerControl.font 0281 elide: Text.ElideRight 0282 visible: globalDrawerControl.text 0283 horizontalAlignment: Text.AlignLeft 0284 verticalAlignment: Text.AlignVCenter 0285 } 0286 0287 width: parent.width 0288 text: model.objID.title 0289 onClicked: { 0290 if(stackView.currentItem != model.objID) { 0291 if(model.objID != initPage) { 0292 stackView.replace(null, [initPage, model.objID]) 0293 } else { 0294 stackView.replace(null, initPage) 0295 } 0296 globalDrawer.close() 0297 } 0298 } 0299 } 0300 0301 property ListModel drawerModel : ListModel { 0302 //Trick to enable storing of object ids 0303 Component.onCompleted: { 0304 append({objID: initPage}); 0305 append({objID: indiControlPanel}); 0306 append({objID: findDialog}); 0307 append({objID: locationDialog}); 0308 append({objID: aboutDialog}); 0309 } 0310 } 0311 0312 model: drawerModel 0313 0314 ScrollIndicator.vertical: ScrollIndicator { } 0315 } 0316 } 0317 0318 //Study mode 0319 property bool step1: false 0320 property bool step2: false 0321 property bool step3: false 0322 property bool step4: false 0323 property bool step5: false 0324 0325 function askExitTutorial() { 0326 tutorialExitPopup.open() 0327 } 0328 0329 function exitTutorial() { 0330 KStarsLite.runTutorial = false 0331 tutorialPopup.close() 0332 step1 = false 0333 step2 = false 0334 step3 = false 0335 step4 = false 0336 step5 = false 0337 } 0338 0339 //Step 1 - Global Drawer 0340 TutorialStep1 { 0341 0342 } 0343 0344 //Step 2 - Context Drawer 0345 TutorialStep2 { 0346 0347 } 0348 0349 //Step 5 - Location 0350 TutorialStep5 { 0351 0352 } 0353 0354 Drawer { 0355 id: contextDrawer 0356 objectName: "contextDrawer" 0357 width: Math.min(window.width, window.height) / 4 * 2 0358 height: window.height 0359 //Disable drawer while loading and if SkyMapLite is not visible 0360 dragMargin: isSkyMapVisible && isLoaded ? Qt.styleHints.startDragDistance + 15 : -Qt.styleHints.startDragDistance 0361 edge: Qt.RightEdge 0362 background: Rectangle { 0363 anchors.fill: parent 0364 color: Num.sysPalette.base 0365 } 0366 0367 onOpened: { 0368 globalDrawer.close() 0369 } 0370 0371 KSLabel { 0372 id: contextTitle 0373 anchors { 0374 top: parent.top 0375 left: parent.left 0376 margins: 10 0377 } 0378 0379 font.pointSize: 14 0380 text: stackView.currentItem.title 0381 } 0382 0383 ListView { 0384 id: contextList 0385 anchors { 0386 left: parent.left 0387 top: contextTitle.bottom 0388 right: parent.right 0389 bottom: parent.bottom 0390 topMargin: 15 0391 } 0392 model: drawerModel 0393 0394 delegate: ItemDelegate { 0395 id: contextDrawerControl 0396 Rectangle { 0397 anchors { 0398 horizontalCenter: parent.horizontalCenter 0399 bottom: parent.bottom 0400 } 0401 width: parent.width - 10 0402 color: "#E8E8E8" 0403 height: 1 0404 } 0405 0406 width: parent.width 0407 text: model.title 0408 onClicked: { 0409 if(model.type == "popup") { 0410 objID.open() 0411 } 0412 0413 contextDrawer.close() 0414 } 0415 0416 contentItem: KSText { 0417 rightPadding: contextDrawerControl.spacing 0418 text: contextDrawerControl.text 0419 font: contextDrawerControl.font 0420 elide: Text.ElideRight 0421 visible: contextDrawerControl.text 0422 horizontalAlignment: Text.AlignLeft 0423 verticalAlignment: Text.AlignVCenter 0424 } 0425 } 0426 0427 property ListModel drawerModel : ListModel { 0428 //Trick to enable storing of object ids 0429 Component.onCompleted: { 0430 append({title: xi18n("Projection systems"), objID: projPopup, type: "popup"}); 0431 append({title: xi18n("Color Schemes"), objID: colorSchemePopup, type: "popup"}); 0432 append({title: xi18n("FOV Symbols"), objID: fovPopup, type: "popup"}); 0433 } 0434 } 0435 0436 ScrollIndicator.vertical: ScrollIndicator { } 0437 } 0438 0439 ColumnLayout { 0440 anchors { 0441 left: parent.left 0442 right: parent.right 0443 bottom: parent.bottom 0444 } 0445 0446 RowLayout { 0447 id: magnitudeRow 0448 anchors { 0449 leftMargin: 10 0450 left: parent.left 0451 rightMargin: 10 0452 right: parent.right 0453 } 0454 0455 property color magnitudeColor: colorSchemePopup.currentCScheme == "cs_night" ? "white" : "black" 0456 0457 Rectangle { 0458 anchors{ 0459 left: parent.left 0460 bottom: smallestMag.bottom 0461 } 0462 0463 width: 24 0464 height: 24 0465 radius: width * 0.5 0466 color: magnitudeRow.magnitudeColor 0467 } 0468 0469 Rectangle { 0470 anchors{ 0471 horizontalCenter: parent.horizontalCenter 0472 bottom: smallestMag.bottom 0473 } 0474 0475 width: 16 0476 height: 16 0477 radius: width * 0.5 0478 color: magnitudeRow.magnitudeColor 0479 } 0480 0481 Rectangle { 0482 id: smallestMag 0483 0484 anchors { 0485 right: parent.right 0486 verticalCenter: parent.bottom 0487 } 0488 0489 width: 8 0490 height: 8 0491 radius: width * 0.5 0492 color: magnitudeRow.magnitudeColor 0493 } 0494 } 0495 0496 Slider { 0497 id: magSlider 0498 anchors { 0499 left: parent.left 0500 right: parent.right 0501 } 0502 0503 from: 1.18778 0504 to: 5.75954 0505 value: SkyMapLite.magLim 0506 0507 onValueChanged: { 0508 SkyMapLite.magLim = value 0509 } 0510 } 0511 } 0512 } 0513 0514 //Handle back button 0515 Connections { 0516 target: window 0517 onClosing: { 0518 if (Qt.platform.os == "android") { 0519 if(stackView.depth > 1) { 0520 close.accepted = false; 0521 stackView.pop() 0522 } 0523 } 0524 } 0525 } 0526 }