Kstars

LocationsGeoMenu.qml
1 // SPDX-FileCopyrightText: 2016 Artem Fedoskin <[email protected]>
2 // SPDX-License-Identifier: GPL-2.0-or-later
3 
4 import QtQuick.Controls 2.0
5 import QtQuick 2.7
6 import QtQuick.Layouts 1.1
7 import "../../constants" 1.0
8 import "../../modules/"
9 import "../../modules/helpers"
10 
11 Menu {
12  id: locationsMenu
13  modal: true
14  transformOrigin: Menu.Center
15  padding: 0
16  property string locName
17  property bool isReadOnly
18  background: Rectangle {
19  implicitWidth: 200
20  color: Num.sysPalette.base
21  radius: 5
22  }
23 
24  function openMenu(name) {
25  locName = name
26  isReadOnly = LocationDialogLite.isReadOnly(name)
27 
28  open()
29  }
30 
31  Column {
32  width: parent.width
33  spacing: 10
34 
35  KSLabel {
36  id: name
37  text: locName
38  wrapMode: Label.WrapAtWordBoundaryOrAnywhere
39  width: parent.width
40  font.pointSize: 12
41  anchors {
42  left: parent.left
43  leftMargin: 10
44  }
45  }
46 
47  Rectangle {
48  color: "grey"
49  width: parent.width - 10
50  height: 1
51  anchors {
52  horizontalCenter: parent.horizontalCenter
53  }
54  }
55  }
56 
57  KSMenuItem {
58  text: xi18n("Set as my location")
59  onTriggered: {
60  if(LocationDialogLite.setLocation(locName)) {
61  skyMapLite.notification.showNotification(xi18n("Set %1 as the current location", locName))
62  } else {
63  skyMapLite.notification.showNotification(xi18n("Could not set as the current location", locName))
64  }
65  locationDialog.filterCities()
66  }
67  }
68 
69  KSMenuItem {
70  text: isReadOnly ? xi18n("View") : xi18n("Edit")
71  onTriggered: {
72  if(isReadOnly) {
73  locationEdit.openEdit(locName, true)
74  } else {
75  locationEdit.openEdit(locName, false)
76  }
77  }
78  }
79 
80  KSMenuItem {
81  enabled: !isReadOnly
82  text: xi18n("Delete")
83  onTriggered: {
84  LocationDialogLite.deleteCity(locName)
85  skyMapLite.notification.showNotification(xi18n("Deleted location %1", locName))
86  locationDialog.filterCities()
87  }
88  }
89 }
QTextStream & left(QTextStream &stream)
QString xi18n(const char *text, const TYPE &arg...)
QTextStream & left(QTextStream &s)
QString name(StandardShortcut id)
const QList< QKeySequence > & open()
This file is part of the KDE documentation.
Documentation copyright © 1996-2022 The KDE developers.
Generated on Sat Aug 13 2022 04:01:55 by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.