debugging adding an asset
This commit is contained in:
parent
1597bd9522
commit
6e16292f06
6 changed files with 169 additions and 9 deletions
106
qml/Forms/AddAsset.qml
Normal file
106
qml/Forms/AddAsset.qml
Normal file
|
@ -0,0 +1,106 @@
|
|||
// SPDX-FileCopyrightText: 2023 Yury Gubich <blue@macaw.me>
|
||||
// SPDX-License-Identifier: GPL-3.0-or-later
|
||||
|
||||
import QtQuick
|
||||
import QtQuick.Controls
|
||||
|
||||
import magpie.API
|
||||
import magpie.Components as Components
|
||||
|
||||
Item {
|
||||
signal success
|
||||
signal cancel
|
||||
|
||||
Column {
|
||||
id: inner
|
||||
spacing: 5
|
||||
anchors.centerIn: parent
|
||||
|
||||
Label {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
text: qsTr("New asset")
|
||||
font.pixelSize: 14
|
||||
}
|
||||
|
||||
Grid {
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
columns: 2
|
||||
columnSpacing: 10
|
||||
rowSpacing: 5
|
||||
verticalItemAlignment: Grid.AlignVCenter
|
||||
horizontalItemAlignment: Grid.AlignRight
|
||||
|
||||
Label {
|
||||
text: qsTr("Title") + ":";
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: titleField
|
||||
}
|
||||
|
||||
Label {
|
||||
text: qsTr("Icon") + ":";
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: iconField
|
||||
text: "list-add"
|
||||
}
|
||||
|
||||
Label {
|
||||
text: qsTr("Color") + ":";
|
||||
}
|
||||
|
||||
TextField {
|
||||
id: colorField
|
||||
}
|
||||
}
|
||||
|
||||
Row {
|
||||
spacing: 5
|
||||
anchors.horizontalCenter: parent.horizontalCenter
|
||||
Button {
|
||||
text: qsTr("Cancel")
|
||||
onClicked: cancel()
|
||||
}
|
||||
|
||||
Button {
|
||||
text: qsTr("Create")
|
||||
onClicked: inner.send(titleField.text, titleField.text, colorField.text)
|
||||
}
|
||||
}
|
||||
|
||||
Components.Modal {
|
||||
id: modal
|
||||
}
|
||||
|
||||
function send (title, icon, color) {
|
||||
if (modal.inProgress)
|
||||
return;
|
||||
|
||||
titleField.text = title;
|
||||
titleField.text = icon;
|
||||
colorField.text = color;
|
||||
|
||||
modal.inProgress = true;
|
||||
modal.status = qsTr("Creating new asset ") + " " + title + "...";
|
||||
modal.open();
|
||||
|
||||
API.addAsset(title, icon, function (err, result) {
|
||||
if (!modal.inProgress)
|
||||
return;
|
||||
|
||||
modal.inProgress = false;
|
||||
if (err)
|
||||
modal.status = err;
|
||||
else
|
||||
modal.status = qsTr("Success");
|
||||
|
||||
if (!!result) {
|
||||
modal.close();
|
||||
success();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
|
@ -11,6 +11,7 @@ qt_add_qml_module(magpieForms
|
|||
QML_FILES
|
||||
Login.qml
|
||||
Register.qml
|
||||
AddAsset.qml
|
||||
)
|
||||
|
||||
target_link_libraries(magpie PRIVATE magpieForms)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue