Kstars

ContextMenu.qml
1// SPDX-FileCopyrightText: 2016 Artem Fedoskin <afedoskin3@gmail.com>
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4import QtQuick.Controls 2.0
5import QtQuick 2.7
6import QtQuick.Layouts 1.1
7import "../../constants" 1.0
8import "../helpers"
9import "../../modules"
10
11Menu {
12 id: contextMenu
13 modal: true
14 transformOrigin: Menu.Center
15 padding: 5
16 background: Rectangle {
17 implicitWidth: 200
18 color: Num.sysPalette.base
19 radius: 5
20 }
21
22 property bool isPoint: false
23
24 function openPoint() {
25 isPoint = true
26 open()
27 }
28
29 function openObject() {
30 isPoint = false
31 open()
32 }
33
34 Column {
35 width: parent.width
36 spacing: 10
37
38 KSLabel {
39 id: objectName
40 text: isPoint ? xi18n("Empty Sky") : SkyMapLite.clickedObjectLite.translatedName
41 wrapMode: Label.WrapAtWordBoundaryOrAnywhere
42 width: parent.width
43 font.pointSize: 12
44 anchors {
45 left: parent.left
46 leftMargin: 10
47 }
48 }
49
50 Rectangle {
51 color: Num.sysPalette.light
52 width: parent.width - 10
53 height: 1
54 anchors {
55 horizontalCenter: parent.horizontalCenter
56 }
57 }
58 }
59
60 KSMenuItem {
61 text: xi18n("Center and Track")
62 onTriggered: {
63 contextMenu.close()
66 }
67 }
68
69 KSMenuItem {
70 visible: !isPoint
71 text: xi18n("Details")
72 onTriggered: stackView.push(detailsDialog)
73 }
74
75 Item {
76 id: hSpacer
77 height: telescopeCol.isTelescope ? 15 : 0
78 }
79
80 ColumnLayout {
81 id: telescopeCol
82 width: parent.width
83 spacing: 10
84 /*If we don't set height to 0 when telescope is not connected there will be some blank space in the bottom
85 of menu*/
86 height: isTelescope ? implicitHeight : 0
87
88 property bool isTelescope: telescope == null ? false : true
89 property var telescope: null
90
91 Connections {
92 target: ClientManagerLite
93
94 onTelescopeAdded: {
95 if(!telescopeCol.isTelescope) {
96 telescopeCol.telescope = newTelescope
97 telescopeName.text = newTelescope.deviceName
98 }
99 }
100
101 onTelescopeRemoved: {
102 telescopeCol.telescope = null
103 }
104 }
105
106 KSText {
107 id: telescopeName
108 visible: telescopeCol.isTelescope
109 wrapMode: Text.Wrap
110 font.pointSize: 12
111 anchors {
112 left: parent.left
113 leftMargin: 10
114 }
115 }
116
117 Rectangle {
118 color: Num.sysPalette.light
119 visible: telescopeCol.isTelescope
120 width: parent.width - 10
121 height: 1
122 anchors {
123 horizontalCenter: parent.horizontalCenter
124 }
125 }
126 }
127
128 KSMenuItem {
129 visible: telescopeCol.isTelescope
130 text: xi18n("Slew")
131 onTriggered: telescopeCol.telescope.slew(SkyMapLite.clickedObjectLite)
132 }
133
134 KSMenuItem {
135 visible: telescopeCol.isTelescope
136 text: xi18n("Sync")
137 onTriggered: telescopeCol.telescope.sync(SkyMapLite.clickedObjectLite)
138 }
139}
This is the main item that displays all SkyItems.
Definition skymaplite.h:59
void slotCenter()
Center the display at the point ClickedPoint.
bool centerLocked
true if SkyMapLite is centered on an object and only pinch-to-zoom needs to be available
Definition skymaplite.h:74
QString xi18n(const char *text, const TYPE &arg...)
const QList< QKeySequence > & open()
QTextStream & left(QTextStream &stream)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Dec 6 2024 12:09:52 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.