Kstars

DetailsAddLink.qml
1// SPDX-FileCopyrightText: 2016 Artem Fedoskin <afedoskin3@gmail.com>
2// SPDX-License-Identifier: GPL-2.0-or-later
3
4import QtQuick.Controls 2.1
5import QtQuick.Controls 1.4
6import QtQuick 2.7
7import QtQuick.Layouts 1.1
8import "../../constants" 1.0
9import "../../modules"
10
11KSPage {
12 id: addLink
13 title: editMode ? xi18n("%1 - Edit Link", SkyMapLite.clickedObjectLite.getTranslatedName()) : xi18n("%1 - Add a Link", SkyMapLite.clickedObjectLite.getTranslatedName())
14 property bool editMode: false // true if popup is in edit mode. False if in add mode
15 property bool isImage: false //is the object for which this popup was opened an image or information
16 property int itemIndex: -1
17 property TextField description: descField
18 property TextField url: urlField
19
20 function openAdd() {
21 editMode = false
22 stackView.push(this)
23 }
24
25 function openEdit(index, isImage) {
26 editMode = true
27 if(!isImage) {
28 descField.text = DetailDialogLite.infoTitleList[index]
29 urlField.text = DetailDialogLite.getInfoURL(index)
30 } else {
31 descField.text = DetailDialogLite.imageTitleList[index]
32 urlField.text = DetailDialogLite.getImageURL(index)
33 }
34
35 itemIndex = index
36 stackView.push(this)
37 }
38
39 /**
40 closes the page and clears all text fields
41 */
42 function closeAddLink() {
43 descField.clear()
44 urlField.clear()
45 stackView.pop()
46 }
47
48 ColumnLayout {
49 anchors {
50 left: parent.left
51 right: parent.right
52 }
53
54 RowLayout {
55 visible: !editMode
56 RadioButton {
57 checked: true //Set this button to be checked initially
58 id: radioInfo
59 text: xi18n("Information")
60 }
61 RadioButton {
62 id: radioImg
63 text: xi18n("Image")
64 }
65 }
66
67 KSLabel {
68 text: xi18n("Description")
69 }
70
71 KSTextField {
72 id: descField
73 Layout.fillWidth: true
74 }
75
76 KSLabel {
77 text: xi18n("URL")
78 }
79
80 KSTextField {
81 id: urlField
82 Layout.fillWidth: true
83 }
84
85 RowLayout {
86 Button {
87 //enabled:
88 text: editMode ? xi18n("Save") : xi18n("Add")
89 onClicked: {
90 if(descField.text == "" || urlField.text == "") {
91 skyMapLite.notification.showNotification(xi18n("Please, fill in URL and Description"))
92 return
93 }
94
95 if(editMode) {
96 DetailDialogLite.editLink(itemIndex, isImage, descField.text, urlField.text)
97 } else {
98 DetailDialogLite.addLink(urlField.text, descField.text, radioImg.checked)
99 }
100 closeAddLink()
101 }
102 }
103
104 Button {
105 text: xi18n("Cancel")
106 onClicked: {
107 closeAddLink()
108 }
109 }
110 }
111 }
112}
This is the main item that displays all SkyItems.
Definition skymaplite.h:59
Q_INVOKABLE QString getTranslatedName()
QString xi18n(const char *text, const TYPE &arg...)
void clear()
QTextStream & left(QTextStream &stream)
QTextStream & right(QTextStream &stream)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Jul 26 2024 11:59:52 by doxygen 1.11.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.