Warning, /education/kstars/kstars/kstarslite/qml/dialogs/helpers/DetailsAddLink.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.1 0005 import QtQuick.Controls 1.4 0006 import QtQuick 2.7 0007 import QtQuick.Layouts 1.1 0008 import "../../constants" 1.0 0009 import "../../modules" 0010 0011 KSPage { 0012 id: addLink 0013 title: editMode ? xi18n("%1 - Edit Link", SkyMapLite.clickedObjectLite.getTranslatedName()) : xi18n("%1 - Add a Link", SkyMapLite.clickedObjectLite.getTranslatedName()) 0014 property bool editMode: false // true if popup is in edit mode. False if in add mode 0015 property bool isImage: false //is the object for which this popup was opened an image or information 0016 property int itemIndex: -1 0017 property TextField description: descField 0018 property TextField url: urlField 0019 0020 function openAdd() { 0021 editMode = false 0022 stackView.push(this) 0023 } 0024 0025 function openEdit(index, isImage) { 0026 editMode = true 0027 if(!isImage) { 0028 descField.text = DetailDialogLite.infoTitleList[index] 0029 urlField.text = DetailDialogLite.getInfoURL(index) 0030 } else { 0031 descField.text = DetailDialogLite.imageTitleList[index] 0032 urlField.text = DetailDialogLite.getImageURL(index) 0033 } 0034 0035 itemIndex = index 0036 stackView.push(this) 0037 } 0038 0039 /** 0040 closes the page and clears all text fields 0041 */ 0042 function closeAddLink() { 0043 descField.clear() 0044 urlField.clear() 0045 stackView.pop() 0046 } 0047 0048 ColumnLayout { 0049 anchors { 0050 left: parent.left 0051 right: parent.right 0052 } 0053 0054 RowLayout { 0055 visible: !editMode 0056 RadioButton { 0057 checked: true //Set this button to be checked initially 0058 id: radioInfo 0059 text: xi18n("Information") 0060 } 0061 RadioButton { 0062 id: radioImg 0063 text: xi18n("Image") 0064 } 0065 } 0066 0067 KSLabel { 0068 text: xi18n("Description") 0069 } 0070 0071 KSTextField { 0072 id: descField 0073 Layout.fillWidth: true 0074 } 0075 0076 KSLabel { 0077 text: xi18n("URL") 0078 } 0079 0080 KSTextField { 0081 id: urlField 0082 Layout.fillWidth: true 0083 } 0084 0085 RowLayout { 0086 Button { 0087 //enabled: 0088 text: editMode ? xi18n("Save") : xi18n("Add") 0089 onClicked: { 0090 if(descField.text == "" || urlField.text == "") { 0091 skyMapLite.notification.showNotification(xi18n("Please, fill in URL and Description")) 0092 return 0093 } 0094 0095 if(editMode) { 0096 DetailDialogLite.editLink(itemIndex, isImage, descField.text, urlField.text) 0097 } else { 0098 DetailDialogLite.addLink(urlField.text, descField.text, radioImg.checked) 0099 } 0100 closeAddLink() 0101 } 0102 } 0103 0104 Button { 0105 text: xi18n("Cancel") 0106 onClicked: { 0107 closeAddLink() 0108 } 0109 } 0110 } 0111 } 0112 }