Warning, /education/kstars/kstars/kstarslite/qml/indi/DevicePanel.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.8
0005 import QtQuick.Window 2.2
0006 import "../modules"
0007 import "../constants" 1.0
0008 import QtQuick.Layouts 1.2
0009 import QtQuick.Controls 2.0
0010
0011 KSPage {
0012 id: devicesPage
0013 title: devicesPage.deviceName + " - " + tabBar.currentItem.text
0014
0015 property string deviceName
0016 property ImagePreview imagePreview: null
0017
0018 ColumnLayout {
0019 anchors.fill: parent
0020
0021 Item {
0022 anchors {
0023 left: parent.left
0024 right: parent.right
0025 }
0026 height: tabBar.height
0027
0028 KSTabBarArrow {
0029 imgSource: "../images/left-arrow.png"
0030 tabBar: tabBar
0031 state: {
0032 if(!tabBar.contentItem.atXBeginning) {
0033 return "Visible"
0034 } else {
0035 return "Invisible"
0036 }
0037 }
0038 anchors {
0039 left: parent.left
0040 top: parent.top
0041 bottom: parent.bottom
0042 }
0043 }
0044
0045 KSTabBarArrow {
0046 imgSource: "../images/right-arrow.png"
0047 tabBar: tabBar
0048 state: {
0049 if(!tabBar.contentItem.atXEnd) {
0050 return "Visible"
0051 } else {
0052 return "Invisible"
0053 }
0054 }
0055 anchors {
0056 right: parent.right
0057 top: parent.top
0058 bottom: parent.bottom
0059 }
0060 flickSpeed: -1000
0061 }
0062
0063 TabBar {
0064 id: tabBar
0065 Layout.fillHeight: true
0066 anchors {
0067 left: parent.left
0068 right: parent.right
0069 }
0070 clip: true
0071 spacing: 20
0072 Component.onCompleted: {
0073 contentItem.flickDeceleration = 1000
0074 }
0075
0076 background: Rectangle {
0077 color: Num.sysPalette.base
0078 }
0079 }
0080 }
0081
0082 SwipeView {
0083 id: deviceSwipeView
0084 Layout.fillHeight: true
0085 Layout.fillWidth: true
0086 currentIndex: tabBar.currentIndex
0087 clip: true
0088
0089 property var groups: []
0090 property var properties: []
0091 property var tabs: []
0092
0093 onCurrentIndexChanged: {
0094 tabBar.currentIndex = currentIndex
0095 }
0096
0097 Connections {
0098 target: ClientManagerLite
0099 onNewINDIProperty: {
0100 if(devicesPage.deviceName === deviceName) {
0101 if(deviceSwipeView.groups.indexOf(groupName) == -1) {
0102 deviceSwipeView.groups.push(groupName)
0103 var newTabComp = Qt.createComponent("../modules/KSTab.qml");
0104 var newTab = newTabComp.createObject(deviceSwipeView)
0105 newTab.title = groupName
0106
0107 var columnForTab = Qt.createQmlObject('import QtQuick 2.7
0108 import QtQuick.Layouts 1.3
0109 Column {
0110 spacing: 5
0111 }', newTab.contentItem)
0112
0113 newTab.rootItem = columnForTab
0114 var tabButton = Qt.createQmlObject('import QtQuick 2.7;
0115 import QtQuick.Controls 2.0
0116 import "../modules"
0117 KSTabButton {}',
0118 tabBar);
0119 tabButton.text = groupName
0120 if(tabBar.count == 1) {
0121 //Without notifying about adding first item to tabBar title of devicesPage won't be updated
0122 tabBar.currentItemChanged()
0123 }
0124
0125 deviceSwipeView.tabs.push(newTab)
0126 if(groupName == "Motion Control") {
0127 var component = Qt.createComponent("modules/MotionControl.qml");
0128 var motionControl = component.createObject(newTab)
0129 motionControl.deviceName = deviceName
0130 }
0131 }
0132
0133 if(groupName != "Motion Control") {
0134 for(var i = 0; i < deviceSwipeView.tabs.length; ++i) {
0135 var tab = deviceSwipeView.tabs[i]
0136 if(tab.title === groupName) {
0137 var propComp = Qt.createComponent("modules/Property.qml");
0138 var property = propComp.createObject(tab.rootItem)
0139 property.propName = propName
0140 property.label = label
0141 property.deviceName = deviceName
0142 property.parentTab = tab
0143 if(propName == "CCD_EXPOSURE" && devicesPage.imagePreview == null) {
0144 var imgPreviewComp = Qt.createComponent("ImagePreview.qml");
0145 devicesPage.imagePreview = imgPreviewComp.createObject(window)
0146 devicesPage.imagePreview.deviceName = devicesPage.deviceName
0147 }
0148 }
0149 }
0150 }
0151 }
0152 }
0153
0154 onRemoveINDIProperty: {
0155 for(var i = 0; i < deviceSwipeView.tabs.length; ++i) {
0156 var tab = deviceSwipeView.tabs[i]
0157 if(tab.title === groupName && groupName != "Motion Control") {
0158 var contentItem = deviceSwipeView.tabs[i].rootItem
0159 for(var c = 0; c < contentItem.children.length; ++c) {
0160 if(contentItem.children[c].propName === propName) {
0161 contentItem.children[c].destroy()
0162 }
0163 }
0164 if(contentItem.children.length == 0) {
0165 var groups = deviceSwipeView.groups
0166 groups.splice(groups.indexOf(groupName), 1)
0167 tab.destroy()
0168 }
0169 /*if(propName == "CCD_EXPOSURE" && devicesPage.imagePreview != null) {
0170 imgPreview.destroy()
0171 }*/
0172 }
0173 }
0174 }
0175 }
0176 }
0177 }
0178 }