Warning, /education/kstars/kstars/kstarslite/qml/dialogs/menus/LocationsGeoMenu.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.Controls 2.0
0005 import QtQuick 2.7
0006 import QtQuick.Layouts 1.1
0007 import "../../constants" 1.0
0008 import "../../modules/"
0009 import "../../modules/helpers"
0010 
0011 Menu {
0012     id: locationsMenu
0013     modal: true
0014     transformOrigin: Menu.Center
0015     padding: 0
0016     property string locName
0017     property bool isReadOnly
0018     background: Rectangle {
0019         implicitWidth: 200
0020         color: Num.sysPalette.base
0021         radius: 5
0022     }
0023 
0024     function openMenu(name) {
0025         locName = name
0026         isReadOnly = LocationDialogLite.isReadOnly(name)
0027 
0028         open()
0029     }
0030 
0031     Column {
0032         width: parent.width
0033         spacing: 10
0034 
0035         KSLabel {
0036             id: name
0037             text: locName
0038             wrapMode: Label.WrapAtWordBoundaryOrAnywhere
0039             width: parent.width
0040             font.pointSize: 12
0041             anchors {
0042                 left: parent.left
0043                 leftMargin: 10
0044             }
0045         }
0046 
0047         Rectangle {
0048             color: "grey"
0049             width: parent.width - 10
0050             height: 1
0051             anchors {
0052                 horizontalCenter: parent.horizontalCenter
0053             }
0054         }
0055     }
0056 
0057     KSMenuItem {
0058         text: xi18n("Set as my location")
0059         onTriggered: {
0060             if(LocationDialogLite.setLocation(locName)) {
0061                 skyMapLite.notification.showNotification(xi18n("Set %1 as the current location", locName))
0062             } else {
0063                 skyMapLite.notification.showNotification(xi18n("Could not set as the current location", locName))
0064             }
0065             locationDialog.filterCities()
0066         }
0067     }
0068 
0069     KSMenuItem {
0070         text: isReadOnly ? xi18n("View") : xi18n("Edit")
0071         onTriggered: {
0072             if(isReadOnly) {
0073                 locationEdit.openEdit(locName, true)
0074             } else {
0075                 locationEdit.openEdit(locName, false)
0076             }
0077         }
0078     }
0079 
0080     KSMenuItem {
0081         enabled: !isReadOnly
0082         text: xi18n("Delete")
0083         onTriggered: {
0084             LocationDialogLite.deleteCity(locName)
0085             skyMapLite.notification.showNotification(xi18n("Deleted location %1", locName))
0086             locationDialog.filterCities()
0087         }
0088     }
0089 }