Warning, /education/kalgebra/mobile/content/ui/controls/AddPlotDialog.qml is written in an unsupported language. File is not indexed.
0001 // SPDX-FileCopyrightText: 2021 Swapnil Tripathi <swapnil06.st@gmail.com> 0002 // SPDX-FileCopyrightText: 2023 Carl Schwan <carl@carlschwan.eu> 0003 // SPDX-License-Identifier: GPL-2.0-or-later 0004 0005 import QtQuick 0006 import QtQuick.Controls as QQC2 0007 import QtQuick.Layouts 0008 0009 import org.kde.kirigami as Kirigami 0010 import org.kde.kirigamiaddons.delegates as Delegates 0011 import org.kde.kirigamiaddons.components as Components 0012 0013 import org.kde.analitza 0014 import org.kde.kalgebra.mobile 0015 0016 QQC2.Dialog { 0017 id: root 0018 0019 property alias text: input.text 0020 required property int dimension 0021 0022 width: Math.min(parent.width - Kirigami.Units.gridUnit * 2, Kirigami.Units.gridUnit * 30) 0023 height: Math.min(parent.height - Kirigami.Units.gridUnit * 2, Kirigami.Units.gridUnit * 30) 0024 0025 x: Math.round((parent.width - width) / 2) 0026 y: Math.round((parent.height - height) / 2) 0027 z: Kirigami.OverlayZStacking.z 0028 0029 parent: applicationWindow().QQC2.Overlay.overlay 0030 0031 background: Components.DialogRoundedBackground {} 0032 0033 padding: 0 0034 modal: true 0035 0036 contentItem: ColumnLayout { 0037 spacing: 0 0038 RowLayout { 0039 Layout.fillWidth: true 0040 Layout.margins: Kirigami.Units.smallSpacing 0041 spacing: Kirigami.Units.smallSpacing 0042 0043 QQC2.TextField { 0044 id: input 0045 Layout.fillWidth: true 0046 focus: true 0047 Component.onCompleted: selectAll() 0048 Keys.onReturnPressed: { 0049 input.selectAll() 0050 App.functionsModel().addFunction(input.text, root.dimension, App.variables) 0051 } 0052 } 0053 0054 QQC2.Button { 0055 icon.name: "list-add" 0056 text: i18nc("@action:button", "Add") 0057 display: QQC2.Button.IconOnly 0058 onClicked: { 0059 input.selectAll() 0060 App.functionsModel().addFunction(input.text, root.dimension, App.variables) 0061 } 0062 0063 QQC2.ToolTip.text: text 0064 QQC2.ToolTip.visible: hovered 0065 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay 0066 } 0067 0068 QQC2.Button { 0069 text: i18nc("@action:button", "Clear All") 0070 onClicked: { 0071 App.functionsModel().clear(); 0072 view.resetViewport(); 0073 } 0074 0075 QQC2.ToolTip.text: text 0076 QQC2.ToolTip.visible: hovered 0077 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay 0078 } 0079 0080 QQC2.ToolButton { 0081 icon.name: "dialog-close" 0082 text: i18nc("@action:button", "Close dialog") 0083 display: QQC2.Button.IconOnly 0084 onClicked: { 0085 root.close() 0086 } 0087 0088 QQC2.ToolTip.text: text 0089 QQC2.ToolTip.visible: hovered 0090 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay 0091 } 0092 } 0093 0094 Kirigami.Separator { 0095 Layout.fillWidth: true 0096 } 0097 0098 QQC2.ScrollView { 0099 Layout.fillWidth: true 0100 Layout.fillHeight: true 0101 0102 ListView { 0103 id: plotView 0104 0105 model: App.functionsModel() 0106 delegate: Delegates.RoundedItemDelegate { 0107 id: plotDelegate 0108 0109 required property int index 0110 required property string description 0111 0112 text: description 0113 0114 contentItem: RowLayout { 0115 Delegates.DefaultContentItem { 0116 itemDelegate: plotDelegate 0117 Layout.fillWidth: true 0118 } 0119 0120 QQC2.ToolButton { 0121 icon.name: "list-remove" 0122 text: i18nc("@action:button", "Remove plot") 0123 display: QQC2.Button.IconOnly 0124 0125 onClicked: App.functionsModel().removeRows(plotDelegate.index, 1); 0126 0127 QQC2.ToolTip.text: text 0128 QQC2.ToolTip.visible: hovered 0129 QQC2.ToolTip.delay: Kirigami.Units.toolTipDelay 0130 } 0131 } 0132 } 0133 0134 Kirigami.PlaceholderMessage { 0135 width: parent.width - Kirigami.Units.gridUnit * 4 0136 anchors.centerIn: parent 0137 text: i18nc("@info", "No plot available") 0138 visible: plotView.count === 0 0139 } 0140 } 0141 } 0142 } 0143 }